I would like to create a script that would take all static ip addresses and monitor them for up or down status. Upon a change in up or down, the script would email me the device status. I would like the subject to include the name of the device, and I would like the name to be whatever I have named the static ip address in the comments.
For example, if I have a printer at a static address 10.0.1.20, and in the comments it says “Printer”, I would like the script to have a subject of Printer, either up or down.
Is this something that can be done within the Mikrotik OS?
Yes. Have each netwatch run a unique script on up/down which sets some variables (name, up/down, date/time etc. etc.), then each of these scripts calls one script which does the e-mailing. Easy-peasy.
In a word, no - I’d pretty much have to write it for you. However, the wiki pages on scripting should give you enough information to be able to write it yourself. If you can’t grok it from them, then I am afraid you will probably have to find a consultant to do it for you. The other option is to go for a third party service such as https://www.pingdom.com/ which does it all for you.
Although scripts can help you in getting out of the box solution, but still i suggest you to go with DUDE, it can do much more in a more sophisticated way with details logging , SMS / Email / Voice and other customized actions,
Also Mikrotik DUDE is a FREE Centralized Network Monitoring/Management system. I am using in my company from past few years, and every one including me and management is pleased with its easy accessibility via web/client and extremely modified functions.
You can take a look at its working here http://aacable.wordpress.com/2012/07/02/the-dude-show-us-your-map-series/
Looking at my scripts I could most likely merge them and do what your looking for… would have to be on a recent version of RouterOS so I can use hash arrays… just let me know if you would be interested.
Thanks for doing this. I am on version 5.26. I haven’t upgraded yet because I’m not sure of the stability of the newer versions. Do I need to upgrade to make this work?
Next, is the script going through all of the ip address on the network, or just the static ip addresses?
Next, does this script work with net watch, or is it stand alone? I didn’t see any email output in the script.
Yes, it requires 6.6 (or something) or higher. It uses associative arrays and functions. You could get rid of the functions, but it won’t really help you because it still uses the associative arrays and that will be much harder to get rid of.
Basically the script looks for dhcp-leases that are BOTH STATIC and have a comment that looks like +DPD+. DPD meaning Dead Peer Detection. What it does is finds those hosts… pings them… if they are down it adds one to the counter, if they are up it doesn’t… and then once a host has three sequential dead pings it triggers the linkDown function with the string. Once it recovers it triggers the linkUp function with the string.
You are correct. Just add whatever you want into the linkUp and LinkDown functions… e.g. swap put for /tools email etc…
I am going to hold off on this for now. I want to wait until version 6 (or 7) becomes more stable. I am going to stick with version 5 for now. For now I will just use net watch.