Facebook  -  Twitter      

Questo forum fa uso dei cookie
Questo forum utilizza i cookie per memorizzare i dettagli del tuo login o della tua ultima visita. I cookie sono piccoli files di testo salvati nel computer; i cookie da noi utilizzati sono relativi unicamente ai servizi da noi forniti direttamente o dai banner pubblicitari. I cookie su questo forum salvano inoltre i dettagli relativi alle discussioni lette e alle tue preferenze personali. Sei pregato di selezionare il tasto OKAY se sei consapevole della presenza di questi files e ci autorizzi ad utilizarli per le informazioni specificate.

Indipendentemente dalla tua scelta un cookie verrà salvato per memorizzare nel tuo pc la risposta a questo form. Puoi modificare le impostazioni relative ai cookie nelle preferenze del tuo browser.

  • 0 voto(i) - 0 media
  • 1
  • 2
  • 3
  • 4
  • 5
[Mikrotik] Monitor input voltage on RB333/433AH

#1
Information 
Hourly monitor and report via email low voltage warnings and daily voltage levels.

This applies to the RB333 and RB433AH with V3.11 or greater ONLY!

Low Voltage Report

This report is sent hourly to the email address in the voltmonitor script when the input voltage is at or below the alarm voltage.

Codice:
ThisBox voltage is 12.5
Daily Voltage Report

This report is sent daily at 11PM to the email address in the voltreport script.

Codice:
Daily voltage report for ThisBox on aug/29/2008


Codice:
23:00 = 12.8

Codice:
22:00 = 12.8

Codice:
21:00 = 12.9

Codice:
20:00 = 13.0

Codice:
19:00 = 13.0

Codice:
18:00 = 13.3

Codice:
17:00 = 14.1

Codice:
16:00 = 14.0

Codice:
15:00 = 14.0

Codice:
14:00 = 13.9

Codice:
13:00 = 13.9

Codice:
12:00 = 13.9

Codice:
11:00 = 13.9

Codice:
10:00 = 13.5

Codice:
09:00 = 13.2

Codice:
08:00 = 12.6

Codice:
07:00 = 12.5

Codice:
06:00 = 12.5

Codice:
05:00 = 12.5

Codice:
04:00 = 12.6

Codice:
03:00 = 12.6

Codice:
02:00 = 12.6

Codice:
01:00 = 12.7

Codice:
00:00 = 12.7


Codice:
Since voltmonitor started on 13:00:00 aug/28/2008

Codice:
Maximum = 14.2v at 13:00:00 aug/28/2008

Codice:
Minimum = 12.5v at 05:00:00 aug/29/2008


Requirements
/tool e-mail must be set correctly to send email,
/system ntp client must be set correctly for the correct time after a reboot,
/system identity should be set to identify the router in the Low Voltage Report,
and the following two scripts:
voltmonitor
The first is voltmonitor. It should be scheduled to run once every hour on the hour (or within a minute after) in /system schedule.

Codice:
#set lowvoltalarm to desired alarm voltage in tenths of a volt. 125 = 12.5v

Codice:
:global lowvoltalarm 125

Codice:
:global highvolt

Codice:
:global lowvolt

Codice:
:global starttime

Codice:
:global hivolttime

Codice:
:global lovolttime

Codice:
:global vh

Codice:
:local thisbox [/system identity get name]

Codice:
:global voltage [/system health get voltage]

Codice:
:local thistime [/system clock get time]

Codice:
:local thisdate [/system clock get date]

Codice:
:local thishour [:pick $thistime 0 2]

Codice:
:local emessage ($thisbox . " voltage is " . [:pick $voltage 0 2] . "." . [:pick $voltage 2 3])

Codice:
:if ([:len $lowvolt] < 1) do={:set lowvolt 999; :set highvolt 0}

Codice:
# set your email address in the next line

Codice:
:if ($voltage <= $lowvoltalarm) do={/tool e-mail send to="youremail@yourdomain.com" subject="$thisbox low voltage" body=$emessage}

Codice:
:if ($voltage > $highvolt) do={:set highvolt $voltage; :set hivolttime ($thistime . " " . $thisdate)}

Codice:
:if ($voltage < $lowvolt) do={:set lowvolt $voltage; :set lovolttime ($thistime . " " . $thisdate)}

Codice:
:if ([:len $vh] > 0) do={:set vh ([:toarray $voltage] + $vh)} else={:set vh [:toarray $voltage]}

Codice:
:if ([:len $starttime] < 1) do={:set starttime ($thistime . " " . $thisdate)}

Codice:
:if ($thishour = "23") do={:execute voltreport}


voltreport
The second is voltreport. It does not need to be scheduled. It is executed by voltmonitor at 11PM every day.
Codice:
:global highvolt

Codice:
:global lowvolt

Codice:
:global hivolttime

Codice:
:global lovolttime

Codice:
:global starttime

Codice:
:global vh

Codice:
:local tvolt

Codice:
:local thisbox [/system identity get name]

Codice:
:local thisdate [/system clock get date]

Codice:
:local thishour

Codice:
:local emessage "Daily voltage report for $thisbox on $thisdate\n\n"

Codice:
:if ([:len $vh] > 0) do={

Codice:
   :for x from=0 to=([:len $vh]-1) step=1 do={

Codice:
       :set tvolt [:tostr [:pick $vh $x]]

Codice:
       :set thishour [:tostr (23 - $x)]

Codice:
       :while ([:len $thishour] < 2) do={:set thishour ("0" . $thishour)}

Codice:
       :set emessage ($emessage . $thishour . ":00 = " . [:pick $tvolt 0 2] . "." . [:pick $tvolt 2 3] .  "\n")

Codice:
   }

Codice:
   :set emessage ($emessage . "\nSince voltmonitor started on " . $starttime . "\n")

Codice:
   :set tvolt [:tostr $highvolt]

Codice:
   :set emessage ($emessage . "Maximum = " . [:pick $tvolt 0 2] . "." . [:pick $tvolt 2 3] . "v at " . $hivolttime . "\n")

Codice:
   :set tvolt [:tostr $lowvolt]

Codice:
   :set emessage ($emessage . "Minimum = " . [:pick $tvolt 0 2] . "." . [:pick $tvolt 2 3] . "v at " . $lovolttime . "\n")

Codice:
# set email address in next line

Codice:
   /tool e-mail send to="youremail@yourdomain.com" subject="$thisbox Voltage Report" body=$emessage

Codice:
}

Codice:
# remark out the next line for testing to avoid resetting the voltage array


HowTo
Command Line:
Login to your router with ssh with your terminal console. I use Konsole in this example.
Highlight the script text for voltmonitor above and copy to clipboard. (Select and Copy).
Then in your router:

Codice:
/system script add name=voltmonitor

Codice:
/system script edit voltmonitor source


In the Konsole toolbar, select "Edit/Paste". The script should be inserted correctly without any typos. The Control-y paste in the terminal window does not paste from the clipboard.
Edit the email address to your email address.
Press Control-o to save and exit the editor.
Do the same for voltreport.
Then add the voltmonitor script to the system schedule:

Codice:
/system schedule add name=voltmonitor on-event=voltmonitor start-time=00:00:00 interval=1h

Cita messaggio


[-]
Condividi/Segnala (Mostra tutti)
Facebook Linkedin Twitter

Discussioni simili
Discussione Autore Risposte Letto Ultimo messaggio
Information [Mikrotik] Monitor logs, send email alert / run script berryberry 0 728 16-06-2015, 10:55
Ultimo messaggio: berryberry
Information [Mikrotik] Script to monitor unexpected script failure berryberry 0 273 09-06-2015, 11:34
Ultimo messaggio: berryberry

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Utenti che stanno guardando questa discussione:
1 Ospite(i)


Powered by MyBB, © 2002-2017 MyBB Group.