Community discussions

MikroTik App
 
wifi442
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 83
Joined: Tue Jan 12, 2010 11:01 pm

Check interface script for power outages

Wed Oct 06, 2010 11:51 pm

I have been able to get this script running and so far its working good:
:if ([/interface get [find name="ether1-CAM-NE"] running]=!true) do={:log warning "Possible Power Outage"}
It checks the interface of the webcam at the tower site (its not plugged into the UPS) and lets me know when it is down. I want to check both the webcam (in ether1) and also a router (in ether4, no UPS) to reduce false positives.

How can I make the if statement be "if ether1 and ether4 are not running" do={:log warning "Possible Power Outage"}?

Its probably really simple and i'm missing it. Yes, I know I could ping these with netwatch, but the router does not respond to pings.
 
SurferTim
Forum Guru
Forum Guru
Posts: 4636
Joined: Mon Jan 07, 2008 10:31 pm
Location: Miramar Beach, Florida

Re: Check interface script for power outages

Thu Oct 07, 2010 12:15 am

This should do it. Change the ether4 name to the correct interface name.
:if ([/interface get [find name="ether1-CAM-NE"] running]=false) do={
    :if ([/interface get [find name="ether4-CAM-NE"] running]=false) do={
         :log warning "Possible Power Outage";
    }
}
Or if you want to use and:
:if (([/interface get [find name="ether1-CAM-NE"] running]=false) && ([/interface get [find name="ether4-CAM-NE"] running]=false)) do={
    :log warning "Possible Power Outage";
}
EDIT: I changed the comparisons from "!true" to "false". Makes more sense to me. I also use this for a comparison of array size rather than a boolean.
:if (:len [/interface get [find name="ether1"] running]=0) do={:log warning "Possible Power Outage";}
 
wifi442
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 83
Joined: Tue Jan 12, 2010 11:01 pm

Re: Check interface script for power outages

Thu Oct 07, 2010 12:51 am

Works perfectly! Thank You!


I if I schedule this every 5 minutes, when the power goes out I get log reminders that its down every 5 min :) But at least I am notified. (Been having lots of storms lately in my area).
 
User avatar
matrot2
Frequent Visitor
Frequent Visitor
Posts: 79
Joined: Thu Jun 25, 2009 12:34 pm

Re: Check interface script for power outages

Sat Oct 09, 2010 12:27 am

Works perfectly! Thank You!
I if I schedule this every 5 minutes, when the power goes out I get log reminders that its down every 5 min :) But at least I am notified. (Been having lots of storms lately in my area).
This can be sdelatv Dude.
Rus. :(
http://tandem.ck.ua/dude.php