Forum Discussion

EvanTempel's avatar
EvanTempel
Icon for Neophyte rankNeophyte
2 days ago

LM API

Interesting in hearing some use cases you guys have for the LM API?

I have a few scripts setup for mass device manipulation in the case of a change, mass auto discovery, automatically add a Windows server based off AD group, and automated internal ping scans based off a few parameters.

Curious to see use cases you guys are using.

  • We've build a whole suite of products around the LogicMonitor API!  Alert integration, CMDB sync, customer reporting, fully-automated provisioning. It really is very powerful.

    To make things easier for us and the .NET development community, we've created an MIT-licensed, open source library (in .NET terms, a "nuget").  You can find that here: https://www.nuget.org/packages/LogicMonitor.Api 

    There's even a free (as in beer) Datmart for SQL Server or Postgres, which you can find here: https://www.panoramicdata.com/open-source/logicmonitor-datamart/ .  Runs in docker, or you can even use the library for free as part of your own commercial product (we certainly do).

    Most of our pro services end up using it in some way or another!

    Automate all the things!

  • While you are on the scripts topic :) I'm needing some help please :) I'm trying to rename a group of devices to use FQDN on the name property and its not quiet working. deviceName gets the response i want, it returns 'server.somedomain.local' but when i try to use deviceName in the data variable value of "name" its not working it returns '("name":deviceName)' I know I'm missing something simple ??

    #Loop through each device & update name
    for i in jsonResponse['data']['items']:
        deviceId = str(i['id'])
        deviceName = str(i['displayName']) + ".somedommain.local"
    
        #Request Info
        httpVerb ='PATCH'
        resourcePath = '/device/devices/'+deviceId
        queryParams ='?patchFields=name'
        data = '("name":deviceName)'
    
        #Construct URL
        url = 'https://'+ Company +'.logicmonitor.com/santaba/rest' + resourcePath +queryParams

     

  • Some of the use cases that I personally have done:

    1) Make device turn-ups in one system reach out to LM via API to create devices and set custom properties.

    2) Use the API to create devices from info in an EMS (when Netscan isn't sufficient).

    3) Grab all collectors, pull their resource context, pull custom properties from the resource context, then set or update custom properties on the collector objects, for more custom "collector down" alert integrations.

    4) Scan resources for 90+ day host down, and use team-specific custom properties to generate custom device list CSVs to different teams.

    5) Rename devices based on a concatenation of existing snmp info and resource properties.

    6) Switch preferred collector to autobalanced mode on every resource in a specified auto-balanced collector group, due to old manual UI settings blocking the devices from UI-based re-balance.

    7) Edit netscans in bulk, because updating 90 netscans in the UI would be terrible.

    etc etc

     

    • Barb's avatar
      Barb
      Icon for Advisor rankAdvisor

      Point 5 is exactly what i need pretty please :)😇

  • As part of a MSP, the majority of the API work I used to do is related to onboarding new customers/environments. Had several scripts to add standard groups, add devices, deploy dashboard templates (some predate dashboard tokens), specific customizations, etc. Had some script that checks for "invalid" configurations, either items that cause problems (like device names with newlines in them from CSV import) or not following our conventions/policies like location property not matching CMDB, hoststatus check disabled, wrong collector, etc. Also had some limited reporting stuff and integrations into other systems like ticketing.