I've put togther some scripts that I've been using with the ScienceLogic API I have created functions for the request calls, within this file you will need to update the SL1 API URL, username and password.
Work in progress, bare with me please....
- Start by copying 'sciencelogic_api_functions.py' to your Python working folder, or to your ...\Python\3.x.x\Lib\ folder.
- Edit the file and update the root URL to reflect your SL1 server, then add in suitable credentials.
- Any new python scripts can then import sciencelogic_api_functions.
- get_api(uri) - the basic get device_details = get_api('/api/device/1')
- get_api2(uri) - adds the total and returned values from the search devices, total, returned = get_api2('/api/device?filter.0.organization.eq=22')
- get_slow(uri) - Good for cleared events, as it can timeout cleared_events = get_slow('/api/cleared_events')
- post_api(uri,data) - posting JSON to a URI post_api('/api/device/1', {"alerts": "0"})
- post_api2(uri,data) The same as above but with no html headers. I can't remember the use case but I needed it once.
- delete_api(url) - remove an entitiy by URI delete_api('/api/device/1')
- epoch2human(string) - becasue epoch timestamps suck timestamp = epoch2human('1730377347')
- get_classes() - Returns a large dictionary of device classes, saves looking stuff up.
- get_cugs() - Dictionary of the CUGs
- get_orgs() - Dictionary of Organisations
- alert_status(severity) - Translate eseverity (numerical string) to English (minor,major, etc)
- post_gql(gql) - Post QGL to SL As it says, I wanted a Pythonic way to post QGL.
Any script starting with the word Graph does just that, graph data. I've included a few examples that hopefully deal with the various data structures that SL1 returns. You'll need Pandas and Matplotlib installed to plot the graphs and Dominate for the html creation.