Jump to content
timwiser

Quick and easy network device up/down script for your probes

Recommended Posts

I've been working on a script that some of you might find useful if you want to get a basic level of network monitoring up and running very quickly. I spent ages setting up probe discovery jobs for all our locations and then going through all the discovered devices and setting their device type, giving them a name, clicking the "Send alert when unit is down" checkbox and specifying an alert template only to find that (a) tickets don't close automatically when devices come back online again, and (b) we got tickets about MAC addresses changing due to ARP tables on routers. So a lot of noise on the service board.

 

Essentially, all we care about at the moment is "Is this switch pinging? Yes, or no"

 

So I ended up writing a script which I schedule on probes every 15 minutes. The script pulls a SQL dataset of network devices that have the "Send alert when unit is down" checkbox ticked and whether the probe scan has detected if it's online or not. If a device is down the script then performs a ping test against the device IP (this is configurable via an EDF to be 1, 5, 10 or 20 packets). A ticket is then created with the results of the ping test as a comment. If the device is found to be online during a later run of the script, the ticket is closed.

 

You can turn on the alerting for devices very easily:

 

UPDATE networkdevices SET alert = 1 WHERE devicetype = X

 

Where X is:

 

1= Terminal

2= Printer

3= Computer

4= NAS Disk

5= VoIP device

6= Camera

7= Router

8= Firewall

9= Bridge

10= Network switch

11= WiFi access point

12= Multimedia device

13= Home automation

14= PLC

15= UPS

 

You don't need to set an alert template on devices for the script to work. It just works on the "Send alert when unit is down" checkbox.

 

UPDATE 13th Dec, it now supports flapping detection and creation of a ticket when a device is flapping down and up regularly through a day. This is configurable via an EDF.

 

If anyone's interested, drop me an email and I'm happy to share.

Share this post


Link to post
Share on other sites
I've been working on a script that some of you might find useful if you want to get a basic level of network monitoring up and running very quickly. I spent ages setting up probe discovery jobs for all our locations and then going through all the discovered devices and setting their device type, giving them a name, clicking the "Send alert when unit is down" checkbox and specifying an alert template only to find that (a) tickets don't close automatically when devices come back online again, and (b) we got tickets about MAC addresses changing due to ARP tables on routers. So a lot of noise on the service board.

 

Essentially, all we care about at the moment is "Is this switch pinging? Yes, or no"

 

So I ended up writing a script which I schedule on probes every 15 minutes. The script pulls a SQL dataset of network devices that have the "Send alert when unit is down" checkbox ticked and whether the probe scan has detected if it's online or not. If a device is down the script then performs a ping test against the device IP (this is configurable via an EDF to be 1, 5, 10 or 20 packets). A ticket is then created with the results of the ping test as a comment. If the device is found to be online during a later run of the script, the ticket is closed.

 

You can turn on the alerting for devices very easily:

 

UPDATE networkdevices SET alert = 1 WHERE devicetype = X

 

Where X is:

 

1= Terminal

2= Printer

3= Computer

4= NAS Disk

5= VoIP device

6= Camera

7= Router

8= Firewall

9= Bridge

10= Network switch

11= WiFi access point

12= Multimedia device

13= Home automation

14= PLC

15= UPS

 

You don't need to set an alert template on devices for the script to work. It just works on the "Send alert when unit is down" checkbox.

 

UPDATE 13th Dec, it now supports flapping detection and creation of a ticket when a device is flapping down and up regularly through a day. This is configurable via an EDF.

 

If anyone's interested, drop me an email and I'm happy to share.

 

Hi Tim,

 

This idea was very interesting to me for ease of use. I went ahead and mocked up a pair of scripts to setup and monitor network probes based on a new group membership with autojoin search "Agents\Agent Probe"

 

Under the location, in a new tab i've added 15 EDFs one for each device type. The setup script checks these EDFs then sets the "Send alert when unit is down" setting for the device type. This script is set to run daily against the group - i'd like to set up some logic as to if this script has already been run, maybe a "setup complete" edf to check similar to onboarding. The monitor script gets a sql dataset for specific columns IPAddress, DeviceType, DeviceName - loops through each row, attempts to ping the device and if it fails creates a ticket.

 

This is a very basic script and untested, I'm still interested in seeing your script - curious about the logic you added in for flapping and how you went about closing tickets when the devices come back online. If anybody has any input it would be appreciated! thanks

 

EDIT: Uploaded wrong script version, it omitted a setup script step

 

Disclaimer: You are downloading a script that's only been through limited testing - download at your own risk

Network Probe - Monitor v2.zip

Share this post


Link to post
Share on other sites

Just posting a message on Tim's behalf - there appears to be logon problems here but he's working on getting access back and will reply then!

  • Like 1

Share this post


Link to post
Share on other sites

Hi guys, I've just managed to get in. I'm currently working on making my script more easily shareable as it now uses custom ticket categories and so forth. Once I've finished making it easier to implement I'll post it on here for you to try.

  • Like 1

Share this post


Link to post
Share on other sites

1. Click Dashboard > Config > Configuration > Information Base Categories

2. Add the following categories *exactly* as shown. These allow the script to use proper categories for network devices which you can then use for elevating tickets based on the type of device.

 

Net-Bridge

Net-Camera\Scanner

Net-Computer

Net-Firewall

Net-Home Automation

Net-Multimedia Device

Net-NAS Disk

Net-Network Device

Net-Printer

Net-Programmable Logic Controller

Net-Router

Net-SAN

Net-Terminal

Net-UPS

Net-VoIP Device

Net-Wi-Fi Access Point

 

3. Import the script to Labtech using Tools > Import > LT XML Extension

4. Open the script in the script editor

5. Click the 'Globals and Parameters' tab

6. Change TICKETEMAIL to be an email address that can be used when creating tickets

7. Change ADMINTICKETS to be the category ID number to use when creating an admin-related ticket. Set this to 115 if you're not sure what to put here

8. Change FLAPPINGEMAIL to be an email address to notify if a device starts flapping. A ticket will also be created if this occurs, the email is just for information

9. BE CAREFUL HERE!! Locate every 'Comment Ticket' or 'Finish Ticket' line and open them up. Use the drop-down menu for the 'User ID' field to pick a user from your system. *** DO NOT just type the username in. Whilst this will appear to work, you may find that you hit a bug in Labtech and corrupt the script when you come to save it ***

10. Once they're all changed, save the script.

11. Go to Dashboard > Config > Additional Field Defaults

12. Within this section, click the Network Device tab

13. Set the Flapping Tolerance dropdown to 5

14. Set the Flaps Today field to 0

15. Set the Ping Test Aggression field to 5

16. Click the Save Additional Information button

17. Navigate to a probe

18. Click the Network Probe tab

19. Check the "Use custom scan" option at the bottom left section

20. Go to the probe's location in the navigation tree and expand Network Devices

21. For each device that you want to be alerted on, set the device "Name" and "Type" fields, check "Send alert when unit is down" checkbox, then click Save. Note that it's here that the flapping tolerance and ping test (number of packets sent during the offline test) can be changed. It's also where you can see how many times a device has 'flapped' since midnight last night.

22. Wait about 10 minutes and then run the script against the probe server. You should see information about the scan get logged into the Scripts tab - when the scan starts, ends, any tickets that've been created and how many devices have been tested.

 

A 'flapping' ticket should be created if a device goes down/up more than the tolerance level specified against the device.

InfrastructureScanner.zip

Edited by Guest
  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites

Hi Tim,

 

Thank you for putting this together and sharing, a much more robust script than mine. When creating my script I hadn't even considered using ping.exe for more granular results rather than labtech's ping script step. Some of the other logic will help me in the future when writing other scripts.

 

Thanks!

Share this post


Link to post
Share on other sites

Hi Tim,

 

I am having some issues implementing this and was wondering if a screenshot of your System Dashboard > Config > Configurations > Additional Fields > Network Devices Tab would solve my issue?

The issue I am having is that I am unable to perform steps #11 - #16 because the Additional Data Fields (EDF's) are not appearing in my Dashboard.

If the Import of the script was supposed to create them, it did not. I closed/opened Control Center but did not see anything added. I can create them manually, but I am unsure of how you configure them based on your post so I would like to see how to set them up. I believe I only need to see the correct fields added to Screenshot #1 below.

 

Below are screenshots of my system (after I imported the script) and as you can see, I don't have any extra EDF's auto created other than the stock ones that come with LT.

Please let me know if I missed something or if there's more information I can provide.

 

Screenshot #1 (Dashboard EDF)

aeXsdbu.png

 

Screenshot #2 (EDF Tabs)

EGVXV0f.png

 

Screenshot #3 (Network Device)

3Vu9uCw.png

 

Steve

Share this post


Link to post
Share on other sites

Harrumpf! I was fully expecting the EDFs to be auto-created for you. Perhaps network device EDFs are not auto-created like they are on computers. I'll log a ticket with LT support and see what they have to say.

Watch this space!

Share this post


Link to post
Share on other sites

OK, I've worked with Support to get the script so that the EDFs are created when you import it. The reason they were not being created is because the script uses direct SQL queries to retrieve the values instead of ExtraData Get lines. That meant that the EDFs were not being included when the script was exported to an XML file. The script has been confirmed as "importable" and the EDFs were created successfully when Support imported it into one of their dev systems.

Download the updated version from the original post.

Any problems, please let me know.

Share this post


Link to post
Share on other sites
Hi guys, I've just managed to get in. I'm currently working on making my script more easily shareable as it now uses custom ticket categories and so forth assurances obsèques. Once I've finished making it easier to implement I'll post it on here for you to try.

Well, I wish you courage because it makes you. I abandoned for some time lacking inspiration I think.

Share this post


Link to post
Share on other sites

Sooooo..... I'm hoping someone is watching the thread and can provide some help. I'm new to Automate of only a few month into using it and trying to add what I can do for customers and potential customers. I've imported it (it didn't say LT XML Extension, just XML Extension) But where is the Script Editor? If I look at Scripts under the Tree should I be looking for a specific one?

Share this post


Link to post
Share on other sites

Tom:

 


  • 1. Right-Click the scripts and select "find" to search for the script name.
    NOTE: You can always determine what the name will be by looking at the XML file you downloaded with a program like NotePad++ that allows easy vewing of the XML.
     
    2.Watch the scripting videos for LabTech on YouTube or the ConnectWise University here:
https://university.connectwise.com/University/training/videolibrary.aspx

 

If this is your first taste of scripting then this specific script may be a bit much to chew as it includes not only scripting but links to Network devices, modifying EDF's etc.

My two cents.

 

Steve

Share this post


Link to post
Share on other sites

Hi @timwiser

I've imported the script, but where did it go? What is the name of it & what folder is it in?

Is there an easy to find this out when importing someone else's script, without going through all the folders looking one-by-one?

Thanks,

Steve.

Share this post


Link to post
Share on other sites

Thanks for this @timwiser. Bringing a little bit of ncentral in. ;)

Now if only you can make it constantly Ping and graph latency 24/7 for the last 3 months for us. Haha. 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the script Tim, I'm having some issues with it running. I've followed your instructions and wondered do I need to change the device type from 'Router' to 'Net-Router' for example? I've switched on the script engine debugging and can see it's going through the network devices I've ticked the box for send alerts on but it's not creating the tickets for the devices that are actually down. Any ideas?

 

Nevermind I've got this working, seems like I just needed to leave it overnight and it's now happy. I'm going to write a script that will set alert = 1 on network devices I run it on to save me having to open each device by hand! Thanks again

Edited by melodic

Share this post


Link to post
Share on other sites

Is there any way to find out what exact device is failing?  We are new to automate.  I am using a custom monitor pinging network devices.  All I get in the alert is a site name.  Aside from going to every device in the probe and selecting the notify box.. is there any way to determine what failed ping?

Share this post


Link to post
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.


×
×
  • Create New...