LM SDK API v3 - get_device_list not responding
Hello, My script that was running without issue yesterday now just indefinitely hangs, if i interrupt it it looks like it just times out code: import logicmonitor_sdk from logicmonitor_sdk.rest import ApiException import json import sys from pprint import pprint from rich.console import Console import time company = 'company' id = 'abc' token = 'lma_' configuration = logicmonitor_sdk.Configuration() configuration.company = company configuration.access_id = id configuration.access_key = token lm = logicmonitor_sdk.LMApi(logicmonitor_sdk.ApiClient(configuration)) def get_devices(): try: devices = [] end_found = False offset = 0 size = 100 while not end_found: current = lm.get_device_list(size=size, start=offset).items devices += current offset += len(current) end_found = len(current) != size pprint(devices) return devices except ApiException as e: print('Exception Caught: %s\n' % e) Traceback: ^CTraceback (most recent call last): File "/Users/lee/dev/logic_monitor/test.py", line 155, in <module> get_devices() ~~~~~~~~~~~^^ File "/Users/lee/dev/logic_monitor/test.py", line 28, in get_devices current = lm.get_device_list(size=size, start=offset).items ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/logicmonitor_sdk/api/lm_api.py", line 16986, in get_device_list (data) = self.get_device_list_with_http_info(**kwargs) # noqa: E501 File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/logicmonitor_sdk/api/lm_api.py", line 17070, in get_device_list_with_http_info return self.api_client.call_api( ~~~~~~~~~~~~~~~~~~~~~~~~^ '/device/devices', 'GET', ^^^^^^^^^^^^^^^^^^^^^^^^^ ...<11 lines>... _request_timeout=params.get('_request_timeout'), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ collection_formats=collection_formats) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/logicmonitor_sdk/api_client.py", line 333, in call_api return self.__call_api(resource_path, method, ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ path_params, query_params, header_params, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ...<2 lines>... _return_http_data_only, collection_formats, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _preload_content, _request_timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/logicmonitor_sdk/api_client.py", line 162, in __call_api response_data = self.request( method, url, query_params=query_params, headers=header_params, post_params=post_params, body=body, _preload_content=_preload_content, _request_timeout=_request_timeout) File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/logicmonitor_sdk/api_client.py", line 355, in request return self.rest_client.GET(url, ~~~~~~~~~~~~~~~~~~~~^^^^^ query_params=query_params, ^^^^^^^^^^^^^^^^^^^^^^^^^^ _preload_content=_preload_content, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _request_timeout=_request_timeout, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ headers=headers) ^^^^^^^^^^^^^^^^ File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/logicmonitor_sdk/rest.py", line 231, in GET return self.request("GET", url, ~~~~~~~~~~~~^^^^^^^^^^^^ headers=headers, ^^^^^^^^^^^^^^^^ _preload_content=_preload_content, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _request_timeout=_request_timeout, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ query_params=query_params) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/logicmonitor_sdk/rest.py", line 206, in request r = self.pool_manager.request(method, url, fields=query_params, preload_content=_preload_content, timeout=timeout, headers=headers) File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/urllib3/_request_methods.py", line 135, in request return self.request_encode_url( ~~~~~~~~~~~~~~~~~~~~~~~^ method, ^^^^^^^ ...<3 lines>... **urlopen_kw, ^^^^^^^^^^^^^ ) ^ File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/urllib3/_request_methods.py", line 182, in request_encode_url return self.urlopen(method, url, **extra_kw) ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/urllib3/poolmanager.py", line 443, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/urllib3/connectionpool.py", line 787, in urlopen response = self._make_request( conn, ...<10 lines>... **response_kw, ) File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/urllib3/connectionpool.py", line 534, in _make_request response = conn.getresponse() File "/Users/lee/dev/logic_monitor/venv/lib/python3.13/site-packages/urllib3/connection.py", line 516, in getresponse httplib_response = super().getresponse() File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/http/client.py", line 1428, in getresponse response.begin() ~~~~~~~~~~~~~~^^ File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/http/client.py", line 331, in begin version, status, reason = self._read_status() ~~~~~~~~~~~~~~~~~^^ File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/http/client.py", line 292, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/socket.py", line 719, in readinto return self._sock.recv_into(b) ~~~~~~~~~~~~~~~~~~~~^^^ File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ssl.py", line 1304, in recv_into return self.read(nbytes, buffer) ~~~~~~~~~^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/python@3.13/3.13.1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ssl.py", line 1138, in read return self._sslobj.read(len, buffer) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^ KeyboardInterrupt If i call another endpoint say get_alert_list, i have no issues and get a response.Solved65Views0likes2CommentsSDK install deprecated
Got this on a recent reinstall of logicmonitor_sdk using pip. DEPRECATION: logicmonitor_sdk is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559 The part that worries me is that pip 23.1 will enforce the pyproject.toml and given the rate that LM publishes updates the SDK, pip installs will break at some point. For me that point is pretty soon because 23.1 is the current version of pip. Luckily, I haven’t upgraded my pip from 22.3.1 to 23.1 like it’s prompting me to. Anybody else tried pip installing it while already on 23.1? Guess I’ll mock it up in docker.Solved109Views3likes4CommentsPython SDK - JSON
Hi All, Apologies if this is a simple question, however I cannot find any documentation that can assist. My goal here is to have severity 3 alerts in a JSON file, however I am unable to convert this list ‘alerts’ to JSON and I cannot find any documentation in the SDK v3 that could address this. # create an instance of the API class api_instance = logicmonitor_sdk.LMApi(logicmonitor_sdk.ApiClient(configuration)) id = 138 # Integer | size = 1000 # Integer | (optional) offset = 0 # Integer | (optional) filter = f'severity:3,cleared:true,startEpoch>:{startEpoch},endEpoch<:{endEpoch}' # String | (optional) #Loop shiznit alerts = [] end_found = False while not end_found: current = api_instance.get_alert_list_by_device_group_id(id, size=size, offset=offset, filter=filter).items alerts += current offset += len(current) end_found = len(current) != size #Print and encode result to json. This allows you to use this variable later in an API Put. with open('./customer/json/cleared_sev3_alerts.json', 'w') as content_output_json: result_encoded = json.JSONEncoder(sort_keys=False, indent =4).encode(alerts) content_output_json.write(str(alerts)) content_output_json.close() print(len(alerts)) Whenever I try to encode this I get the following alert. TypeError: Object of type Alert is not JSON serializable Doing a jsonDump gives us the same output and I’ve scoured stackoverflow for a way to fix this, but no luck. Does anyone know how I can get around this? Thank you so muchSolved132Views3likes1Commentv3 Python SDK outdated?
Hello, I’m trying to use the Python SDK to add websites for monitoring. For my current use case, the primary reason for this is to gain some alerting on our SSL expiry times. Using the SDK has been a generally frustrating experience all around so far, however I’ve noticed that the v3 API is returning fields which aren’t supported or documented by the SDK or API docs. Specifically, for the Website endpoints (GET/POST/PUT), the top-level fields `schema`, `trigger_ssl_expiration_alert` and `trigger_ssl_status_alert` are all unsupported in the 3.0.172 SDK. Unfortunately these also all sound like the fields I need to be setting in order to get SSL monitoring set up. It also appears that the top-level `schema` field is required to enable HTTPS monitoring, as the `schema` field in the `steps` is ignored. I can see that this top-levle field is set to https when toggling the schema in the web UI, when using dev tools to inspect the request. I’ve already done a fair bit of work using the SDK, so I’d hate to have to rip it out at this point and start building all my requests manually in order to support this. I’m using logicmonitor_sdk 3.0.172 at present, which is the latest available release via Pip and tarball. I can see that these fields have been added on the master branch in Github. Is there a timeline for the release of these changes? While I’m here, can I also ask that this functionality is added to your Terraform provider, because that would save me a lot of hours and stress going forward. 😉95Views1like4Comments