Community discussions

 
Trezona
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 59
Joined: Wed Feb 22, 2006 6:34 pm

Voltage Monitoring

Fri Jan 22, 2016 9:20 am

Hello,

I have been running a voltage monitoring script with great success for a while now.

I am now trying to run this same script on the latest firmware (6.33.5) and it is not running at all.

Here is my script:

#set lowvoltalarm to desired alarm voltage in tenths of a volt. 125 = 12.5v
:global lowvoltalarm 200
:global highvoltalarm 280
:global highvolt
:global lowvolt
:global starttime
:global hivolttime
:global lovolttime
:global vh
:local thisbox [/system identity get name]
:global voltage [/system health get voltage]
:local thistime [/system clock get time]
:local thisdate [/system clock get date]
:local thishour [:pick $thistime 0 2]
:local emessage ($thisbox . " voltage is: " . [:pick $voltage 0 2] . "." . [:pick $voltage 2 3])
:if ([:len $lowvolt] < 1) do={:set lowvolt 999; :set highvolt 0}
# set your email address in the next line
:if ($voltage <= $lowvoltalarm) do={/tool e-mail send to="test@test.com" subject="$thisbox Voltage Statistics" body=$emessage}
:if ($voltage >= $highvoltalarm) do={/tool e-mail send to="test@test.com" subject="$thisbox Voltage Statistics" body=$emessage}
:if ($voltage > $highvolt) do={:set highvolt $voltage; :set hivolttime ($thistime . " " . $thisdate)}
:if ($voltage < $lowvolt) do={:set lowvolt $voltage; :set lovolttime ($thistime . " " . $thisdate)}
:if ([:len $vh] > 0) do={:set vh ([:toarray $voltage] + $vh)} else={:set vh [:toarray $voltage]}
:if ([:len $starttime] < 1) do={:set starttime ($thistime . " " . $thisdate)}
:if ($thishour = "23") do={:execute voltreport}

I run this every 30 minutes.

Could somone one please tell me why this now does not work on all versions higher than 6.30?

Thanks.
 
plisken
Forum Guru
Forum Guru
Posts: 2421
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Voltage Monitoring

Sun Jan 24, 2016 7:36 pm

I have try this script and indeed it don't work.
Who can help us?
 
mperdue
Member Candidate
Member Candidate
Posts: 288
Joined: Wed Jun 30, 2004 8:18 pm

Re: Voltage Monitoring

Sun Jan 24, 2016 8:31 pm

Along the same idea, I'm wanting a script that would monitor voltage and if it droped below a set value it would disable the poe on a single ethernet port. Anyone have that script?
 
marrold
Member
Member
Posts: 406
Joined: Wed Sep 04, 2013 10:45 am

Re: Voltage Monitoring

Sun Jan 24, 2016 9:05 pm

I have try this script and indeed it don't work.
Who can help us?
Run it line by line and see where it fails, or add some lines to indicate where if fails, e.g -
:put "The script has made it this far [1]"
:put "The script has made it this far [2]"
I'm a SIP / VoIP engineer. Feel free to ask questions...
 
User avatar
PaulsMT
MikroTik Support
MikroTik Support
Posts: 283
Joined: Tue Feb 10, 2015 3:21 pm

Re: Voltage Monitoring

Mon Jan 25, 2016 12:02 pm

There is an error in last line:
:if ($thishour = "23") do={:execute voltreport}

if voltreport is supposed to a variable - then it is missing $ and also it is not defined.

If you change this line, then the script works fine in 6.33.5
 
plisken
Forum Guru
Forum Guru
Posts: 2421
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Voltage Monitoring

Mon Jan 25, 2016 12:11 pm

Where must $ comming in the line?
Can you make the last line please
 
User avatar
PaulsMT
MikroTik Support
MikroTik Support
Posts: 283
Joined: Tue Feb 10, 2015 3:21 pm

Re: Voltage Monitoring

Mon Jan 25, 2016 12:47 pm

Where must $ comming in the line?
Can you make the last line please
:if ($thishour = "23") do={:execute $voltreport}

$voltreport is the second script or function which is not defined here.

Here you will find step by step instructions how this script works:
http://wiki.mikrotik.com/wiki/Monitor_i ... B333/433AH
 
Trezona
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 59
Joined: Wed Feb 22, 2006 6:34 pm

Re: Voltage Monitoring

Tue Jan 26, 2016 8:36 am

Thanks Paul,

Its working great now!

I am actually not using the second part of the script so i just hashed it out!

Thanks once again for you help!

Clive.
 
plisken
Forum Guru
Forum Guru
Posts: 2421
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Voltage Monitoring

Tue Jan 26, 2016 2:38 pm

Working like a charm Paul
Thank you
 
p3rad0x
Long time Member
Long time Member
Posts: 603
Joined: Fri Sep 18, 2015 5:42 pm
Location: South Africa
Contact:

Re: Voltage Monitoring

Tue Feb 02, 2016 12:05 pm

I use this line,
:if ($thishour = "23") do={/system script run voltreport}
There you go then you touched something ;-) : it only takes a change in wind direction to screw with your nat :-)
 
BobcatGuy
Member Candidate
Member Candidate
Posts: 224
Joined: Thu Apr 19, 2007 7:41 am

Re: Voltage Monitoring

Thu Jul 07, 2016 9:55 am

If anyone is handy with scripting and willing to help a buddy out....  I am looking for a way to monitor voltage, to use as a notification if the power went out.  Basically the same script idea, but with a couple twists.

The point it to monitor volts, while AC power is on and power supply provides 13.5 volts exactly, when the AC power goes off, the power supply switched to 12 volt battery, and provides power at about 12.8 volts.  So, that's the easy part to do that.  I can hack this script apart and get that to work, but it would send an email every time the script is run, say I have it set to run every 5 minutes.

I would like to only send the email one time, until power is restored, volts goes back up, then another email is sent stating, power is back on.  Basically I guess it would be a "compare $lastvolts to $currentvolts and if current volts is less than $alarmvolts, and variable of $lastvolts was also less than $alarmvolts to then send email.  That's the jist, basicaly compare the last check and if it was already on battery, to not send email again,  emails every 5 minutes would get annoying.

Would be nice to also set a value for "critical Low" level, say 11.0 Volts, will also send an email.. This way you know that the battery is at critical level, and may not send any more notifications.  Also a notification that its back up to the charge voltage to indicate battery is charging and AC back on.

Any other cool ideas too if anyone has them.
poor mans UPS :-)

Thanks.
 
n21roadie
Forum Guru
Forum Guru
Posts: 1887
Joined: Fri Aug 07, 2009 10:36 pm
Location: Limerick,Ireland

Re: Voltage Monitoring

Fri Jul 08, 2016 1:06 am

If anyone is handy with scripting and willing to help a buddy out....  I am looking for a way to monitor voltage, to use as a notification if the power went out.  Basically the same script idea, but with a couple twists.

The point it to monitor volts, while AC power is on and power supply provides 13.5 volts exactly, when the AC power goes off, the power supply switched to 12 volt battery, and provides power at about 12.8 volts.  So, that's the easy part to do that.  I can hack this script apart and get that to work, but it would send an email every time the script is run, say I have it set to run every 5 minutes.

I would like to only send the email one time, until power is restored, volts goes back up, then another email is sent stating, power is back on.  Basically I guess it would be a "compare $lastvolts to $currentvolts and if current volts is less than $alarmvolts, and variable of $lastvolts was also less than $alarmvolts to then send email.  That's the jist, basicaly compare the last check and if it was already on battery, to not send email again,  emails every 5 minutes would get annoying.

Would be nice to also set a value for "critical Low" level, say 11.0 Volts, will also send an email.. This way you know that the battery is at critical level, and may not send any more notifications.  Also a notification that its back up to the charge voltage to indicate battery is charging and AC back on.

Any other cool ideas too if anyone has them.
poor mans UPS :-)

Thanks.
Because all of our network has battery back up, AC monitor from a routerboard was not the best solution, however using a simple GSM Alarm / relay unit which serves two purposes was our solution, (1) it automatically sends SMS text alert of AC outage and AC power restoration  (2) We can use the built in relay to disconnect DC power to locked up boards so they can restart ? 
N21roadie,
Network 100% MT for Now?
 
BobcatGuy
Member Candidate
Member Candidate
Posts: 224
Joined: Thu Apr 19, 2007 7:41 am

Re: Voltage Monitoring

Sat Jul 09, 2016 10:43 am

Hmm found a simple solution.  Added global variable :global lastvoltage
And modified the two lines as seen below.

:if ($voltage <= $lowvoltalarm and $lastvoltage > $lowvoltalarm) do={/tool e-mail send to="myemail@domain.com" subject="$thisbox Voltage Statistics" body=$emessage}

:if ($voltage >= $lowvoltalarm and $lastvoltage < $lowvoltalarm) do={/tool e-mail send to="myemail@domain.com" subject="$thisbox Voltage Statistics" body=$emessage}


Then added
:set $lastvoltage $voltage
as the last line so that the two lines above compare the values. Basically if it was in low volt already, and the last time the script ran, it will not send the email, since all conditions are not met. I am running this on a 12 volt system, so I have it set to 12.4 volts, when the AC power fails, it switches to battery.  The 12.4 volts is because this particular unit I was testing on had about 75 feet of cat 5 and the voltage was lower at the MT board.  Adjust it to your desired voltage.

I will tweek this script a bit more for my use and might post it later.  I would like to set it up so that it reports the voltage every hour as well while on battery, so that I can monitor its state and know when it will shut down. 


#set lowvoltalarm to desired alarm voltage in tenths of a volt. 125 = 12.5v
:global lowvoltalarm 124
:global highvoltalarm 280
:global highvolt
:global lowvolt
:global starttime
:global hivolttime
:global lovolttime
:global vh
:global lastvoltage
:local thisbox [/system identity get name]
:global voltage [/system health get voltage]
:local thistime [/system clock get time]
:local thisdate [/system clock get date]
:local thishour [:pick $thistime 0 2]
:local emessage ($thisbox . "Voltage is: " . [:pick $voltage 0 2] . "." . [:pick $voltage 2 3])
:if ([:len $lowvolt] < 1) do={:set lowvolt 999; :set highvolt 0}
# set your email address in the next line
:if ($voltage <= $lowvoltalarm and $lastvoltage > $lowvoltalarm) do={/tool e-mail send to="myemail@domain.com" subject="$thisbox Voltage Statistics" body=$emessage}
:if ($voltage >= $lowvoltalarm and $lastvoltage < $lowvoltalarm) do={/tool e-mail send to="myemail@domain.com" subject="$thisbox Voltage Statistics" body=$emessage}
:if ($voltage >= $highvoltalarm) do={/tool e-mail send to="myemail@domain.com" subject="$thisbox Voltage Statistics" body=$emessage}
:if ($voltage > $highvolt) do={:set highvolt $voltage; :set hivolttime ($thistime . " " . $thisdate)}
:if ($voltage < $lowvolt) do={:set lowvolt $voltage; :set lovolttime ($thistime . " " . $thisdate)}
:if ([:len $vh] > 0) do={:set vh ([:toarray $voltage] + $vh)} else={:set vh [:toarray $voltage]}
:if ([:len $starttime] < 1) do={:set starttime ($thistime . " " . $thisdate)}
:if ($thishour = "23") do={:execute $voltreport}
:set $lastvoltage $voltage

 
 
eliemacho
just joined
Posts: 12
Joined: Thu May 02, 2019 12:20 pm

Re: Voltage Monitoring

Sat May 11, 2019 1:17 pm

@bobcatguy

thanks dude it works very well
 
plisken
Forum Guru
Forum Guru
Posts: 2421
Joined: Sun May 15, 2011 12:24 am
Location: Belgium
Contact:

Re: Voltage Monitoring

Mon May 13, 2019 4:35 pm

Thanks Bobcatguy good work and a appresiate that.

Who is online

Users browsing this forum: MSN [Bot] and 14 guests