Automating the World

 
User avatar
timwiser
Geek
Topic Author
Posts: 145
Joined: Thu Oct 08, 2015 3:28 pm
Current LT Agent Count: 3000+
Location: Nottingham, UK
Contact:

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

Fri Dec 09, 2016 6:06 am

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.
Layin' down tweets at @timmitwiser
 
CapstoneWorks
Posts: 9
Joined: Sat Feb 08, 2014 8:35 pm
Current LT Agent Count: 1000+
Location: Cedar Park, TX
Contact:

Re: Quick and easy network device up/down script for your pr

Sun Dec 25, 2016 6:50 pm

I'd love to get a copy of this.

chuck.adams.ltg@capstoneworks.com

Sent from my SM-G935V using Tapatalk
 
Mathesonian
Geek
Posts: 35
Joined: Tue Nov 05, 2013 6:21 am
Current LT Agent Count: 7500+

Re: Quick and easy network device up/down script for your pr

Thu Dec 29, 2016 9:20 am

I'd love a copy of this as well.
 
dcomitini
Posts: 24
Joined: Wed Oct 26, 2016 10:40 am
Current LT Agent Count: 3000+

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

Wed Jan 04, 2017 8:45 am

Hi Tim, would like to test this script out - how can I get a copy?
 
dcomitini
Posts: 24
Joined: Wed Oct 26, 2016 10:40 am
Current LT Agent Count: 3000+

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

Mon Jan 09, 2017 1:10 pm

timwiser wrote:
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
You do not have the required permissions to view the files attached to this post.
 
Gavsto
Geek
Posts: 96
Joined: Tue Dec 08, 2015 7:35 am

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

Wed Jan 11, 2017 6:12 am

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!
 
User avatar
timwiser
Geek
Topic Author
Posts: 145
Joined: Thu Oct 08, 2015 3:28 pm
Current LT Agent Count: 3000+
Location: Nottingham, UK
Contact:

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

Thu Jan 12, 2017 8:43 am

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.
Layin' down tweets at @timmitwiser
 
User avatar
timwiser
Geek
Topic Author
Posts: 145
Joined: Thu Oct 08, 2015 3:28 pm
Current LT Agent Count: 3000+
Location: Nottingham, UK
Contact:

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

Thu Jan 12, 2017 9:27 am

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.
You do not have the required permissions to view the files attached to this post.
Last edited by timwiser on Mon Jan 30, 2017 3:23 am, edited 1 time in total.
Layin' down tweets at @timmitwiser
 
dcomitini
Posts: 24
Joined: Wed Oct 26, 2016 10:40 am
Current LT Agent Count: 3000+

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

Thu Jan 12, 2017 3:02 pm

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!
 
User avatar
timwiser
Geek
Topic Author
Posts: 145
Joined: Thu Oct 08, 2015 3:28 pm
Current LT Agent Count: 3000+
Location: Nottingham, UK
Contact:

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

Mon Jan 16, 2017 11:04 am

Glad you like it :)
Layin' down tweets at @timmitwiser
 
User avatar
HickBoy
Posts: 5
Joined: Fri Aug 21, 2015 9:51 pm

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

Mon Jan 23, 2017 10:18 am

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)
Image

Screenshot #2 (EDF Tabs)
Image

Screenshot #3 (Network Device)
Image

Steve
 
User avatar
timwiser
Geek
Topic Author
Posts: 145
Joined: Thu Oct 08, 2015 3:28 pm
Current LT Agent Count: 3000+
Location: Nottingham, UK
Contact:

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

Tue Jan 24, 2017 4:20 am

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!
Layin' down tweets at @timmitwiser
 
TClayton
Posts: 4
Joined: Tue Jan 28, 2014 3:26 pm
Current LT Agent Count: 200+

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

Wed Jan 25, 2017 9:22 am

Subscribed...
 
User avatar
timwiser
Geek
Topic Author
Posts: 145
Joined: Thu Oct 08, 2015 3:28 pm
Current LT Agent Count: 3000+
Location: Nottingham, UK
Contact:

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

Mon Jan 30, 2017 3:25 am

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.
Layin' down tweets at @timmitwiser
 
acanais85
Posts: 1
Joined: Thu Aug 03, 2017 8:58 am
Current LT Agent Count: 100+

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

Tue Aug 22, 2017 10:50 am

timwiser wrote:
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.