:global listrik
:global limitmsgon
:global limitmsgoff
/in ethernet monitor ether1.MJGD once do={
:global indikator $status
:if ($indikator = "link-ok") do={:set listrik 1} else={:set listrik 0}
}
:local router [/system identity get name]
:local time [/system clock get time]
:local date [/system clock get date]
:local voltage [/system health get voltage]
:local tegangan (. [:pick $voltage 0 2] . "," . [:pick $voltage 2 3] ." volt")
:local indication "PLN NYALA"
:local indicatioff "PLN MATI"
:local msgon ("[ $router ]%0A" . $indication . " pada : %0A" . $time .", ".$date."%0A"."voltase saat ini $tegangan%0A")
:local msgoff ("[ $router ]%0A" . $indicatioff . " pada : %0A" . $time .", ".$date."%0A"."voltase saat ini $tegangan%0A")
# reset counter
:if ($listrik =1) do={:set limitmsgoff 0;:set limitmsgon ($limitmsgon +1)}
:if ($listrik =0 && $limitmsgon >=5) do={:set limitmsgon 0}
# start pesan listrik nyala
:if (($listrik =1) && ($limitmsgon =2)) do={
/tool fetch url="https://api.telegram.org/bot380992034:AAGn69QpFDuLSOQd3E3JtI5nhfUmgKlKmkls/sendMessage?chat_id=-203xxxxxx&text=$msgon" keep-result=no
}
# start pesan listrik mati
:if ($listrik =0 && $limitmsgoff <5 ) do={
/tool fetch url="https://api.telegram.org/bot380992034:AAGn69QpFDuLSOQd3E3JtI5nhfUmgKlKmkls/sendMessage?chat_id=-203xxxxxx&text=$msgoff" keep-result=no
:set limitmsgoff ($limitmsgoff +1)
}
Saturday, November 3, 2018
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment