Hi, i have the following 2 scripts running on my Mikrotik RB750up on a solar site to monitor battery levels.
I basically copy and modified them from the internet for my needs as i’m not really a script writer.
But the issue i have is that i need the info sent through 7am each morning, not 11pm each night.
This is so i can see if my wind generator did anything over-night, as i know my solar wouldn’t have contributed overnight!
So if anyone could help me change these, that would be awesome ![]()
[OR even better, set a “variable??” where i can set the hour, if that’s possible??]
VOLTMONITOR
#set lowvoltalarm to desired alarm voltage in tenths of a volt. 125 = 12.5v
:global lowvoltalarm 112
:global earlyvoltwarn 114
: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] ." // " . [:pick $voltage 0 2] . “.” . [:pick $voltage 2 3]+5)
:if ([:len $lowvolt] < 1) do={:set lowvolt 999; :set highvolt 0}set your email address in the next line
:if ($thishour >= “17” and $voltage = $earlyvoltwarn) do={/tool e-mail send to=“emailaddress” subject=“!-EARLY LOW VOLT WARN-! $thishour pm $emessage” body=$emessage from=RB750UP start-tls=yes}
:if ($voltage <= $lowvoltalarm) do={/tool e-mail send to=“emailaddress” subject=“!-LOW VOLT NOW-! $emessage” body=$emessage from=RB750UP start-tls=yes}
: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}
VOLTREPORT
:global highvolt
:global lowvolt
:global hivolttime
:global lovolttime
:global starttime
:global vh
:local tvolt
:local thisbox [/system identity get name]
:local thisdate [/system clock get date]
:local thishour
:local emessage “Voltage report for $thisbox on $thisdate\n\n”
:if ([:len $vh] > 0) do={
:for x from=0 to=([:len $vh]-1) step=1 do={
:set tvolt [:tostr [:pick $vh $x]]
:set thishour [:tostr (23 - $x)]
:while ([:len $thishour] < 2) do={:set thishour (“0” . $thishour)}
:set emessage ($emessage . $thishour . ":00 = " . [:pick $tvolt 0 2] . “.” . [:pick $tvolt 2 3] . “\n”)
}
:set emessage ($emessage . "\nSince voltmonitor started on " . $starttime . “\n”)
:set tvolt [:tostr $highvolt]
:set emessage ($emessage . "Maximum = " . [:pick $tvolt 0 2] . “.” . [:pick $tvolt 2 3] . "v at " . $hivolttime . “\n”)
:set tvolt [:tostr $lowvolt]
:set emessage ($emessage . "Minimum = " . [:pick $tvolt 0 2] . “.” . [:pick $tvolt 2 3] . "v at " . $lovolttime . “\n”)set email address in next line
/tool e-mail send to=“emailaddress” subject=“$thisbox Voltage Report” body=$emessage from=emailaddress start-tls=yes
}remark out the next line for testing to avoid resetting the voltage array
:set vh
