Community discussions

MikroTik App
 
msteil
just joined
Topic Author
Posts: 20
Joined: Mon Nov 18, 2013 1:10 am

Health/Voltage shutdown script

Tue May 20, 2014 5:05 am

Hello,

Does/has anyone ever tried to create a script that runs continuously monitoring the health voltage, and at a specified voltage execute a graceful shutdown of the system? I have venue where we need to create a WI-FI mesh network for an event, but there is no readily available source of electricity. I have several RB 411s running on 12 volt batteries and I want to shut the AP down before the batteries are damaged from too deep a discharge cycle. Any help or examples would be greatly appreciated.

Thanks in advance.
 
jarda
Forum Guru
Forum Guru
Posts: 7756
Joined: Mon Oct 22, 2012 4:46 pm

Re: Health/Voltage shutdown script

Tue May 20, 2014 12:09 pm

Hi,
even I am not doing shutdown, I am using following script for monitoring/logging health values:

ros code

# Define global variables
:global TempLast 
:global VoltLast 

# Define and fill actual values
:local TempAct [/system health get temperature]
:local VoltRAW [/system health get voltage]

# Divide voltage by 10 as it is 10 times multiplicated
:local VoltAct [ ($VoltRAW / 10) ]

# Calculate differences between last and actual values
:local TempDiff [ ($TempAct - $TempLast) ]
:local VoltDiff [ ($VoltAct - $VoltLast) ]
:tonum TempDiff
:tonum VoltDiff

# Calculate absolute values of differences
:if ( $TempDiff < 0 ) do={ :set TempDiff [ ( 0 - $TempDiff ) ] } 
:if ( $VoltDiff < 0 ) do={ :set VoltDiff [ ( 0 - $VoltDiff ) ] } 

# Do the reporting
:if ( $TempDiff >= 1 ) do={ :log info ("Environment: Last Temperature was $TempLast C. Actual Temperature is $TempAct C.") } 
:if ( $VoltDiff >= 1 ) do={ :log info ("Environment: Last Voltage was $VoltLast V. Actual Voltage is $VoltAct V.") } 

:if ( $TempDiff >= 1 ) do={ :set TempLast $TempAct } 
:if ( $VoltDiff >= 1 ) do={ :set VoltLast $VoltAct } 

# Debugging info below....
#:log info $TempAct
#:log info $VoltAct
#:log info $TempDiff
#:log info $VoltDiff

#:log info ("Environment: Actual Temperature is $TempAct C. Voltage is $VoltAct V.")
You can get ispired and add conditional system shutdown.

Remember, that you need somehow to start the system, as after shutdown the device needs power recycle to start up, otherwise it stays swithed off...
 
vaio
just joined
Posts: 5
Joined: Wed Oct 12, 2011 10:52 am

Re: Health/Voltage shutdown script

Sun Oct 20, 2019 2:10 pm

Hi,
even I am not doing shutdown, I am using following script for monitoring/logging health values:

ros code

# Define global variables
:global TempLast 
:global VoltLast 

# Define and fill actual values
:local TempAct [/system health get temperature]
:local VoltRAW [/system health get voltage]

# Divide voltage by 10 as it is 10 times multiplicated
:local VoltAct [ ($VoltRAW / 10) ]

# Calculate differences between last and actual values
:local TempDiff [ ($TempAct - $TempLast) ]
:local VoltDiff [ ($VoltAct - $VoltLast) ]
:tonum TempDiff
:tonum VoltDiff

# Calculate absolute values of differences
:if ( $TempDiff < 0 ) do={ :set TempDiff [ ( 0 - $TempDiff ) ] } 
:if ( $VoltDiff < 0 ) do={ :set VoltDiff [ ( 0 - $VoltDiff ) ] } 

# Do the reporting
:if ( $TempDiff >= 1 ) do={ :log info ("Environment: Last Temperature was $TempLast C. Actual Temperature is $TempAct C.") } 
:if ( $VoltDiff >= 1 ) do={ :log info ("Environment: Last Voltage was $VoltLast V. Actual Voltage is $VoltAct V.") } 

:if ( $TempDiff >= 1 ) do={ :set TempLast $TempAct } 
:if ( $VoltDiff >= 1 ) do={ :set VoltLast $VoltAct } 

# Debugging info below....
#:log info $TempAct
#:log info $VoltAct
#:log info $TempDiff
#:log info $VoltDiff

#:log info ("Environment: Actual Temperature is $TempAct C. Voltage is $VoltAct V.")
You can get ispired and add conditional system shutdown.

Remember, that you need somehow to start the system, as after shutdown the device needs power recycle to start up, otherwise it stays swithed off...
Hi all ...
I want to ask, could we create a script to monitor the voltage and send alarms to the Telegram?
Namely:
Enter the VoltAlarmMAX and VoltAlarmMIN script variables
to find out the current voltage
The script will sense the voltage at 10 intervals when it detects a drop below VoltAlarmMIN sends a message, then begins monitoring and each time it drops by 0.5Volt, it sends a message with current voltage, (example: WARNING, power failure - current voltage is xyVolt), and It will send it until the power comes on, ie If the voltage level is bigger to or equal to VoltAlarmMAX, then it sends a message (example: Power restored - current voltage is xyVolt), no more messages are sent, only if the voltage drops below VoltAlarmMIN, and the cycle repeats ...
Last edited by vaio on Sun Oct 20, 2019 2:52 pm, edited 1 time in total.
 
msatter
Forum Guru
Forum Guru
Posts: 2951
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: Health/Voltage shutdown script

Sun Oct 20, 2019 2:23 pm

English is the language used in this forum.