Check interface script for power outages

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.

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";}

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 :slight_smile: But at least I am notified. (Been having lots of storms lately in my area).

This can be sdelatv Dude.
Rus. :frowning:
http://tandem.ck.ua/dude.php