A. successful temperature script:
Code: Select all
:global "tempstatus"
:global "templaststatus"
:global "cputempstatus"
:global "cputemplaststatus"
:global "systemtemp" [/system health get temperature]
:global "cputemp" [/system health get cpu-temperature]
:if (systemtemp > "45") do={:set "tempstatus" "system temp is too high"}
:if (systemtemp > "60") do={:set "tempstatus" "system temp is critical"}
:if (systemtemp < "45") do={:set "tempstatus" "system temp is within spec"}
:if (cputemp > "65") do={:set "cputempstatus" "cpu temp is too high"}
:if (cputemp > "75") do={:set "cputempstatus" "cpu temp is critical"}
:if (cputemp < "64") do={:set "cputempstatus" "cpu temp is within spec"}
:if ($"tempstatus" != $"templaststatus") do {
/ tool fetch "https://api.telegram.org/bot1111111111:rAndomStrInGof lettersandnumbers/sendMessage?chat_id=-222222222&text=Router $[/system identity get name] has a temperature notification. $[/system clock get date] $[/system clock get time] -> $tempstatus - $systemtemp* Celsius)"
:log info "Telegram notification sent about system $tempstatus status"
:set "templaststatus" $"tempstatus"
}
:if ($"cputempstatus" != $"cputemplaststatus") do {
/ tool fetch "https://api.telegram.org/bot1111111111:rAndomStrInGof lettersandnumbers/sendMessage?chat_id=-222222222&text=Router $[/system identity get name] has a temperature notification. $[/system clock get date] $[/system clock get time] -> $cputempstatus - $cputemp* Celsius)"
:log info "Telegram notification sent about system $cputempstatus status"
:set "cputemplaststatus" $"cputempstatus"
}
/file remove number=[find where name~"Celsius"]
This is what works for email quite nicely in netwatch for the DOWN condition, very simple and works!
B. successful email script in netwatch
Code: Select all
:local sub1 ([/system clock get time])
/tool e-mail send from="myemail@address.com.ca" body="At $sub1 HP Printer is Offline" subject="HP Printer is offline" to="myemail@address.com"
:log info "CHECK HP printer stat!!"
SO I tried TWO iterations and both FAILED. :-( BASICALLY ONE WITH AND ONE WITHOUT closing { and } brackets.
So after the last line of the email part of the script above B., I added:
(1) With brackets
{
/ tool fetch "https://api.telegram.org/bot1111111111:rAndomStrInGof lettersandnumbers/sendMessage?chat_id
=-222222222&text=Router $[/system identity get name] has detected the HP Printer Offline"
:log info "Telegram notification sent about HP Printer offline"
}
and
(2) Without brackets
/ tool fetch "https://api.telegram.org/bot1111111111:t rAndomStrInGof lettersandnumbers/sendMessage?chat_id
=-222222222&text=Router $[/system identity get name] has detected the HP Printer Offline"
:log info "Telegram notification sent about HP Printer offline"
Not only did I not get telegram messages but both FAILED to produce a router log entry about the Telegram Notification, which worked just fine for health/temp script.
PLEASE ADVISE!