I recently got a 750up router with the capability to turn on and off power to ports 2-5. Looking for a script to ping that port and if it doesnt reply after so many try’s or minutes that it will cycle the power to that port.
Any love on this? I could use a script like this one, would be handy if someone already had one written.
This should be trivial. A netwatch job to ping the address, and a one-liner script to turn off and on the power to that port.
http://wiki.mikrotik.com/wiki/Manual:Tools/Netwatch
and the command to run from Netwatch:
[admin@MikroTik] /interface ethernet> set ether1 poe-out=off
I wrote a little script that restarts power based on the port status, but it doesn’t work because find for poe value doesn’t work. I believe this is a bug.
:local iface;
:foreach i in=[/interface ethernet find poe-out=forced-on] do={
:set iface [/interface ethernet get $i value-name=name];
/interface ethernet monitor $i once do={
:if ($status="!link-ok") do={
:log info "poe-watch restarting: $iface";
/interface ethernet set poe-out=off $iface;
/delay 2s
/interface ethernet set poe-out=forced-on $iface;
:log info "poe-watch status: $status, restarted: $iface";
/delay 60s
}
}
}
I then run this on a 1 second schedule.