Community discussions

 
helipos
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 75
Joined: Sat Jun 25, 2016 11:32 am

Reading POE status with script

Mon Apr 22, 2019 5:22 am

Hello,

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
[admin@Work Router] > /interface ethernet poe monitor
numbers: 0
            name: ether5
         poe-out: auto-on
  poe-out-status: waiting-for-load
but I have to get that and still get it in to a variable.

If anyone can provide any assistance that would be greatly appreciated.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1131
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Reading POE status with script

Mon Apr 22, 2019 9:47 am

Try this:
[
:local variable ([/interface ethernet poe monitor]->"poe-out")
:put $variable 
]
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
helipos
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 75
Joined: Sat Jun 25, 2016 11:32 am

Re: Reading POE status with script

Mon Apr 22, 2019 1:42 pm

[
:global test ([/interface ethernet poe monitor];0;->"poe-out";0)
:put $test
]
0
Q
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.
 
nostromog
Member Candidate
Member Candidate
Posts: 124
Joined: Wed Jul 18, 2018 3:39 pm

Re: Reading POE status with script

Mon Apr 22, 2019 2:06 pm

This works for me:
{
  :local test ([/interface ethernet poe monitor ether5 once as-value ]->"poe-out");
  :put $test
}
It needs once to ensure it finishes, and as-value to return the resulting data structure.
 
helipos
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 75
Joined: Sat Jun 25, 2016 11:32 am

Re: Reading POE status with script

Thu Apr 25, 2019 12:01 pm

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.
 
helipos
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 75
Joined: Sat Jun 25, 2016 11:32 am

Re: Reading POE status with script

Sun Jul 14, 2019 7:37 am

Right, after waiting ages for an update to come out from Mikrotik the script ran and failed.
So I found some inspiration https://wiki.mikrotik.com/wiki/Manual:S ... ime_errors and modified it.to fit in my script.

: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.

The auto update script is here.
viewtopic.php?f=8&t=122839

Who is online

Users browsing this forum: No registered users and 3 guests