SDT Report


pmeyer
 Share

Recommended Posts

  • 1 year later...
On 4/20/2017 at 1:58 PM, pmeyer said:

I want to have a report that will give me all devices that are currently under an SDT, that will show the device name, SDT Start Date, SDT End Date, and the comments of the SDT>

Do you mean within the web GUI?  This functionality exists in the API: https://www.logicmonitor.com/support/rest-api-developers-guide/v1/sdts/get-sdts/

  • Upvote 1
Link to comment
Share on other sites

  • 3 years later...
  • 2 weeks later...
On 4/14/2022 at 3:43 PM, Barb said:

We would also like this feature request 

that will show the device name, SDT Start Date, SDT End Date, and the comments of the SDT also the customer. A report that can be shown to customers. The one that comes from the api is not easily manipulated into excel from STD Output. Any suggestions on how to make this report easier to read.

Link to comment
Share on other sites

Guest Stuart Weenig

This script gets pretty close, I think:

from lm import lm

devices = lm.get_device_list(size=1000).items
sdts = lm.get_sdt_list(size=1000).items

r = {}

for device in devices:
    r[device.id] = {"display_name": device.display_name, "name": device.name}
    r[device.id]["device_sdt"] = [s.to_dict() for s in [sdt for sdt in sdts if sdt.type=="DeviceSDT"] if device.id == s.device_id]
    r[device.id]["group_sdt"] = [s.to_dict() for s in [sdt for sdt in sdts if sdt.type=="DeviceGroupSDT"] if s.device_group_id in [int(i) for i in device.host_group_ids.split(',')]]

print("device_id,display_name,name,sdt_type,sdt_start_time,sdt_end_time,sdt_timezone")
for k,v in r.items():
    for ds in v['device_sdt'] + v['group_sdt']:
        print(f"{k},{v['display_name']},{v['name']},{ds['type']},{ds['start_date_time_on_local']},{ds['end_date_time_on_local']},{ds['timezone']}")

 

Uses my own personal library to build the Python SDK object called lm. Doesn't do pagination on the device, list, but that wouldn't be too hard to build. This also may output multiple lines for a single device, if multiple SDTs apply to the same device. Wouldn't be too complicated to flatten the list.

This is what the output looks like on mine:

device_id,display_name,name,sdt_type,sdt_start_time,sdt_end_time,sdt_timezone
58,LogicMonitor,lmstuartweenig.logicmonitor.com,DeviceGroupSDT,2022-05-02 10:25:00 CDT,2022-05-02 11:25:00 CDT,America/Chicago
62,Zoom,logicmonitor.zoom.us,DeviceGroupSDT,2022-05-02 10:25:00 CDT,2022-05-02 11:25:00 CDT,America/Chicago
78,Skilljar,status.skilljar.com,DeviceGroupSDT,2022-05-02 10:25:00 CDT,2022-05-02 11:25:00 CDT,America/Chicago
103,ConnectWise,staging.connectwisedev.com,DeviceSDT,2022-04-12 12:57:00 CDT,3022-04-12 14:57:00 CDT,America/Chicago
140,api.exchangeratesapi.io,api.exchangeratesapi.io,DeviceSDT,2022-05-06 20:00:00 CDT,2022-05-07 19:45:00 CDT,America/Chicago
140,api.exchangeratesapi.io,api.exchangeratesapi.io,DeviceSDT,2022-05-07 19:45:00 CDT,2022-05-08 19:30:00 CDT,America/Chicago
197,buttonmusic.local,buttonmusic.local,DeviceSDT,2022-03-23 10:23:00 CDT,3022-03-23 12:23:00 CDT,America/Chicago
239,boxxy.local,boxxy.local,DeviceSDT,2022-04-04 14:47:00 CDT,3022-04-04 16:47:00 CDT,America/Chicago

 

Hopefully I'll have some time today to repost my lmwrapper module (i had to pull it off github). 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share