tiras

Members
  • Content Count

    4
  • Joined

  • Last visited

Community Reputation

0 Neutral

About tiras

  • Rank
    Community Member
  1. Thank you Sarah I had tried `getHost`, but it seems to not cover my need. I would like to see the `vm` level of it. I have no idea that by technically it is possible or not. At least you response does confirm my understand. No worry I will manage to survive Best regards Sarit
  2. Hi I want to extract my information according to this interface example_notification_data = {
 'host': "10.10.10.86",
 'host_name': "Debian-App",
 'incident_created': "2016-10-10T02:27:47+07:00", 'component_type': "server",
 'component_status': 0, } host is an local IP address host_name is string hostname incident_created is timestamp with timezone format is ISO8601 component_type is "server" or "vm" base on the component type. It is OK to hardcode by "server" because NOC has to investigate in detail component_status is always 0. Because my customer would like to see the critical case and first developer from that endpoint refuses me to change his format. He claims "I had 3 times changed which is enough". Therefore I have to leave this key in json payload for historical purpose. Here is my Python script and import json import pprint from urllib import parse, request from config import (USER, PASSWORD, COMPANY) def rpc(action, params): """ Make a call to the LogicMonitor RPC library and return the response Reference: https://www.logicmonitor.com/support/rpc-api-developers-guide/overview/using-logicmonitors-rpc-api/ """ print("Calling action: {action}".format(action=action)) print("Parameters: {params}".format(params=params)) param_str = parse.urlencode(params) creds = parse.urlencode({"c": COMPANY, "u": USER, "p": PASSWORD}) if param_str: param_str = param_str + "&" param_str = param_str + creds try: url = "https://{0}.logicmonitor.com/santaba/rpc/{1}?{2}" f = request.urlopen(url.format(COMPANY, action, param_str)) return f.read() except IOError as ioe: print(ioe) def main(): pp = pprint.PrettyPrinter(indent=4) response = rpc("getAlerts", {"level": "critical"}) tmp_text = response.decode("utf-8") instance = json.loads(tmp_text) msg = instance.get('data').get('alerts') pp.pprint(msg) if __name__ == "__main__": main() Here is my response [ { '_id_': 'LMD8983', 'ackComment': 'OK', 'acked': True, 'ackedBy': 'wisut.j@cloudhm.co.th', 'ackedOn': 1475652110, 'ackedOnLocal': '2016-10-05 14:21:50 ICT', 'active': True, 'alertEscalationChainName': 'default', 'alertRecipients': '', 'alertRuleId': 3, 'alertRuleName': 'Critical', 'clearValue': '', 'dataPoint': 'idleInterval', 'dataSource': 'HostStatus', 'dataSourceDisplayName': 'Host Status', 'dataSourceId': 128, 'dataSourceInstance': 'HostStatus', 'dataSourceInstanceDescription': '', 'dataSourceInstanceId': 4911958, 'dataSourceType': 'DS', 'displayName': 'Host Status', 'duration': '52h 31m', 'endOn': 0, 'endOnLocal': '', 'escalationChainId': 1, 'escalationSubChainId': 0, 'host': 'VC-TCCT', 'hostDataSourceId': 393, 'hostGroups': [ { 'alertEnable': True, 'appliesTo': '', 'createdOn': 0, 'description': 'root folder', 'fullPath': '', 'groupType': 0, 'id': 1, 'name': 'cloudhm', 'parentId': 0}], 'hostId': 8, 'id': 74, 'inSDT': True, 'level': 'critical', 'nextRecipient': 0, 'sdt': [ { 'admin': 'wisut.j@cloudhm.co.th', 'category': {'name': 'HostSDT'}, 'comment': '', 'duration': 0, 'endDateTime': { 'day': 31, 'hour': 12, 'minute': 30, 'month': 10, 'weekDay': 2, 'year': 2016}, 'endHour': 0, 'endMinute': 0, 'hostId': 8, 'hour': 0, 'id': 1, 'isEffective': True, 'minute': 0, 'monthDay': 0, 'sdtType': 1, 'startDateTime': { 'day': 5, 'hour': 13, 'minute': 43, 'month': 10, 'weekDay': 4, 'year': 2016}, 'type': 'onetime', 'weekDay': 1}], 'startOn': 1475644129, 'startOnLocal': '2016-10-05 12:08:49 ICT', 'thresholds': '> 300 300 300', 'type': 'alert', 'uniqueId': 'LMD74', 'value': '189439.44'}, { '_id_': 'LMD8979', 'ackComment': 'OK', 'acked': True, 'ackedBy': 'wisut.j@cloudhm.co.th', 'ackedOn': 1475652110, 'ackedOnLocal': '2016-10-05 14:21:50 ICT', 'active': True, 'alertEscalationChainName': 'default', 'alertRecipients': '', 'alertRuleId': 3, 'alertRuleName': 'Critical', 'clearValue': '', 'dataPoint': 'PingLossPercent', 'dataSource': 'Ping', 'dataSourceDisplayName': 'Ping', 'dataSourceId': 31, 'dataSourceInstance': 'Ping', 'dataSourceInstanceDescription': '', 'dataSourceInstanceId': 4911957, 'dataSourceType': 'DS', 'displayName': 'Ping', 'duration': '52h 36m', 'endOn': 0, 'endOnLocal': '', 'escalationChainId': 1, 'escalationSubChainId': 0, 'host': 'VC-TCCT', 'hostDataSourceId': 388, 'hostGroups': [ { 'alertEnable': True, 'appliesTo': '', 'createdOn': 0, 'description': 'root folder', 'fullPath': '', 'groupType': 0, 'id': 1, 'name': 'cloudhm', 'parentId': 0}], 'hostId': 8, 'id': 69, 'inSDT': True, 'level': 'critical', 'nextRecipient': 0, 'sdt': [ { 'admin': 'wisut.j@cloudhm.co.th', 'category': {'name': 'HostSDT'}, 'comment': '', 'duration': 0, 'endDateTime': { 'day': 31, 'hour': 12, 'minute': 30, 'month': 10, 'weekDay': 2, 'year': 2016}, 'endHour': 0, 'endMinute': 0, 'hostId': 8, 'hour': 0, 'id': 1, 'isEffective': True, 'minute': 0, 'monthDay': 0, 'sdtType': 1, 'startDateTime': { 'day': 5, 'hour': 13, 'minute': 43, 'month': 10, 'weekDay': 4, 'year': 2016}, 'type': 'onetime', 'weekDay': 1}], 'startOn': 1475643859, 'startOnLocal': '2016-10-05 12:04:19 ICT', 'thresholds': '> 20 70 90', 'type': 'alert', 'uniqueId': 'LMD69', 'value': '100.00'}] Question: How to get the value of host, host_name, incident_created, component_type, component_status. Since I have not found any relation between result and the details? I have read https://www.logicmonitor.com/support/rpc-api-developers-guide/manage-devices/get-devices/ But I do not know how to link it each other FYI: 1. I can not put 'host' to my 'host_name' because it is the same and endpoint API will confuse Best regards Sarit
  3. Thank you Sarah. My customer raises a new issue and would like me an alternative approach I will come back to forum again with new question Thanks Sarit
  4. Hi I want to POST an critical issue count to my API server. My python script is as follow. import json from urllib import parse, request from config import (USER, PASSWORD, COMPANY) def rpc(action, params): """ Make a call to the LogicMonitor RPC library and return the response Reference: https://www.logicmonitor.com/support/rpc-api-developers-guide/overview/using-logicmonitors-rpc-api/ """ print("Calling action: {action}".format(action=action)) print("Parameters: {params}".format(params=params)) param_str = parse.urlencode(params) creds = parse.urlencode({"c": COMPANY, "u": USER, "p": PASSWORD}) if param_str: param_str = param_str + "&" param_str = param_str + creds try: url = "https://{0}.logicmonitor.com/santaba/rpc/{1}?{2}" f = request.urlopen(url.format(COMPANY, action, param_str)) return f.read() except IOError as ioe: print(ioe) # end try # end rpc def main(): response = rpc("getAlerts", {"level": "critical"}) tmp_text = response.decode("utf-8") instance = json.loads(tmp_text) count = len(instance.get('data').get('alerts')) if __name__ == "__main__": main() I know to do this job in python webserver, but I want to use `LogicMonitor` integration. How can I convert it to `Custom HTTP Delivery`? I have been reading the docs for a while, but it seems not answer exactly what I want at all Hope communities can support me figure out how to finish this job Best regards Sarit