Normally I can bash my way through a script but this one has me stumped.
I’m trying to modify my autoupdate script so it can detect if there are POE powered devices.
If it supplies POE I’ll make it delay its own reboot by some minutes to ensure the fed device can install it’s firmware without the supplying device rebooting and cutting power off half way through.
What I’m struggling with is how can I can detect if there are POE devices.
Generally the supplying devices are 951Ui-2nD’s
I was thinking to use something like this
:global FWstatus [/system package update get status];
but i can’t find an equivalent for POE status. I can get the information using
/interface ethernet poe monitor 0
The zero is required to tell the monitor command which port to look at.
The Q tells it to quit what looks like a live monitor session.
If I don’t put the 0 and Q in it doesn’t create the “test” variable.
So I tried that in a script.
Unfortunately it doesn’t write anything to the ‘test’ variable.
If I can read the code correctly I guess you wanted to run “/interface ethernet poe monitor” but filter the result for “poe-out” and enter that in to the test variable?
I think the issue lies in the fact the monitor command needs extra entries 0 and Q to operate correctly.
Ok, I’m not sure where my retard skill set let me down, but its working. I’ll trying it in the new autoupdate script and when I’m happy with it I’ll post it back up here.
:do {:global POEstatus ([/interface ethernet poe monitor ether5 once as-value ]->“poe-out-status”);} on-error={:global POEstatus “fail”}
That will work and if POE capability doesn’t exist in the unit, instead of aborting the script it will inject a “fail” message.
Last year we have installed about 1000 swithes as managed PoE sources to wireless Aps.
As you noted, PoE related commands are not very useful or informational.
Winbox UI is more frendly, until you need to power cycle all connected devices.
So, i made this code.
It defines 2 global function.
So you can place it into scheduler to load on device reload, and next execute directly from cli:
:if ([system routerboard get model]~"CRS328") do={
:global showPoeST do={
:put ("Interface\tPoE status ");
for i from 1 to 24 step 1 do {
:local ethpoest ([/interface ethernet poe monitor [find name=("ether" . $i)] once as-value ]->"poe-out-status");
:set ("$test"->("ether" . $i)) $ethpoest ;
:put ("ether" . $i . "\t\t" . $ethpoest)
}}
:global poeRELOAD do={
for i from 1 to 24 step 1 do {
:local ethpoest ([/interface ethernet poe monitor [find name=("ether" . $i)] once as-value ]->"poe-out-status");
if ($ethpoest="powered-on") do= {
/interface ethernet poe power-cycle [find name=("ether" . $i)] duration=30s;
:put ("Power-reset on interface ether" . $i) }}}
} else={ :if ([system routerboard get model]~"CRS112") do={
:global showPoeST do={
:put ("Interface\tPoE status ");
for i from 1 to 8 step 1 do {
:local ethpoest ([/interface ethernet poe monitor [find name=("ether" . $i)] once as-value ]->"poe-out-status");
:set ("$test"->("ether" . $i)) $ethpoest ;
:put ("ether" . $i . "\t\t" . $ethpoest)
}}
:global poeRELOAD do={
for i from 1 to 8 step 1 do {
:local ethpoest ([/interface ethernet poe monitor [find name=("ether" . $i)] once as-value ]->"poe-out-status");
if ($ethpoest="powered-on") do= {
/interface ethernet poe power-cycle [find name=("ether" . $i)] duration=30s;
:put ("Power-reset on interface ether" . $i) }
}}
}}
Ive tried to get interface count directly from cli, unfortunately "for" cycle, defined by some variables cant be imported into environment variable (but works perfectly if you execute code directly).
So I have to make model check and define static number of interfaces for each one.
Just as an update. This bit of code is what I’ve been using for some months. It will detect any port using POE and update a global variable. I mainly use that global variable to delay an upgrade because there might be a POE device doing an upgrade at the same time.
A link to that script if your interested.