So I’m looking to develop/improve some code and I need it to detect if any port has POE output active.
To do some testing I’ve hacked together a bit of code which I can just dump into a ssh console to test.
Code to test
[
:put ("--- POE Status Report ---");
:foreach line in=[/interface ethernet poe monitor [find] as-value once] do={
:local status ($line->"poe-out-status");
:local interfaceName ($line->"name");
:if ($status = "powered-on") do={
:put ("Interface: " . $interfaceName . " | Status: " . $status);
}
}
:put ("---------------------------");
]
On a CRS328-24P-4S+ this spits back a logical result.
On a RB951Ui-2nD or RB952Ui-5ac2nD this script fails to spit out the correct (in my head at least) output.
If I dig a little deeper and just run this snippet below, all three devices show a logical output and all three have an interface with poe-out-status=powered-on
So the question is, what am I missing about the “code to test” that stops it from finding the “poe-out-status” field in the RB951’s. I’ve been going around in circles for about a day and I could really use some help.
Your code works fine on my RB951Ui-2HnD. Perhaps your interfaces have bad characters in their names. For example, my ether5_camera port prevented the script from working, but the ether5camera port worked.
I am running 7.20.6, if this is another ‘feature’ I might just have to fork my eyes out..
One of the RB’s has “ether5” as the name. I would have thought that should work.
The other had something more complicated which I modified, it didn’t change the outcome.
I tried a couple of more devices. A hAP ac and a L009UiGS, both behave the same as the RB951’s. So yeah maybe your on to something with the thought of it working on devices with all POE ports.
I tried your script but it fails to catch anything, even on the CRS328.
I recommend not renaming interfaces to indicate their usage, but instead use comments for that.
I know that renaming the interface makes it automatically propagate to other places like setting an IP address, but having nonstandard names can also be a nuisance.
Right, @safelogj good thing I went to bed. I didn’t even spot your snippet was sending the output to the log rather than putting out to console. That is working on all the four devices. Thanks a bunch.
@pe1chl I take it you have been on the receiving end of interface renaming issues? I’ve learnt from either yourself or one of the other masters around here to at least not to have spaces in names.
Well, when it is the cause of a problem it would be best to undo it. But anyway, WHEN you rename them at least make sure you do not use any special characters. Anything that makes it into a quoted name in an export should certainly be avoided.
Out example on CRS112-8P-4S (yes, is like RouterOS style):
Flags: D - Disabled, E - Enabled, N - Not PoE capable, P - PoE Capable
NAME PRIORITY POE-OUT INPUT STATUS CURRENT VOLTAGE POWER
E P ;;; PTP
ether1 10 auto-on low powered-on 227mA 26500mV 6000mW
E P ;;; (non collegato)
ether2 20 auto-on low waiting-for-load
E P ;;; DIFF
ether3 30 auto-on low powered-on 240mA 26500mV 6300mW
E P ;;; DIFF
ether4 40 auto-on low powered-on 142mA 26600mV 3700mW
E P ;;; DIFF
ether5 50 auto-on low powered-on 139mA 26600mV 3600mW
E P ;;; [PoE OFF] - RISERVA - DIFF
ether6 60 off low
E P ;;; (non collegato)
ether7 70 auto-on low waiting-for-load
E P ;;; [PoE OFF] - CLI
ether8 80 off low
E N ;;; (nessun modulo)
sfp9 =
E N ;;; (nessun modulo)
sfp10 =
E N ;;; (nessun modulo)
sfp11 =
E N ;;; (nessun modulo)
sfp12 =
Out example on CRS318-16P-2S+
Flags: D - Disabled, E - Enabled, N - Not PoE capable, P - PoE Capable
NAME PRIORITY POE-OUT INPUT STATUS CURRENT VOLTAGE POWER
E P ether1 10 forced-on low powered-on 239mA 25700mV 6100mW
E P ether2 20 forced-on low powered-on 347mA 25700mV 8900mW
E P ether3 30 auto-on low powered-on 164mA 25700mV 4200mW
E P ether4 40 auto-on auto powered-on 175mA 49300mV 8600mW
E P ether5 50 forced-on low powered-on 226mA 25700mV 5800mW
E P ether6 60 off auto
E P ether7 70 off low
E P ether8 80 off low
E P ether9 89 auto-on low powered-on 160mA 25800mV 4100mW
E P ether10 90 auto-on low powered-on 156mA 25800mV 4000mW
E P ether11 91 auto-on low powered-on 155mA 25800mV 3900mW
E P ether12 92 forced-on low powered-on 357mA 25600mV 9100mW
E P ether13 93 forced-on low powered-on 355mA 25700mV 9100mW
E P ether14 94 off low
E P ether15 95 auto-on low powered-on 113mA 25800mV 2900mW
E P ether16 96 auto-on low waiting-for-load
E N sfp-sfpplus1 =
E N sfp-sfpplus2 =
Out example on RB960PGS (PowerBox Pro)
Flags: D - Disabled, E - Enabled, N - Not PoE capable, P - PoE Capable
NAME PRIORITY POE-OUT INPUT STATUS CURRENT VOLTAGE POWER
E N ether1 =
E P ;;; PTP
ether2 10 auto-on = powered-on 149mA 27700mV 4100mW
E P ;;; DIFF
ether3 20 auto-on = powered-on 161mA 27700mV 4400mW
E P ;;; DIFF
ether4 30 auto-on = powered-on 157mA 27700mV 4300mW
E P ;;; DIFF
ether5 40 auto-on = powered-on 221mA 27700mV 6100mW
E N ;;; (nessun modulo)
sfp1