I setup simple netwatch script for sending me message in telegram if no ping on my pihole server and switching to another ip.
Code: Select all
:local status "UP"
:local deviceName [/system identity get name]
:local deviceDate [/system clock get date]
:local deviceTime [/system clock get time]
:local PIHOLE "<pi_hole_server>"
:local Google "8.8.8.8"
:local TelegramBotToken "<bot_token>";
:local TelegramChatID "<chat_id>";
:local TGSendMessage do={
:local tgUrl "https://api.telegram.org/bot$Token/sendMessage?chat_id=-$ChatID&text=$Text";
/tool fetch http-method=get url=$tgUrl keep-result=no;
}
:local textSent "\F0\9F\9F\A2 $deviceName%0A$deviceDate $deviceTime : %0A$PIHOLE is $status %0ADNS = $PIHOLE %0A\E2\9C\85"
/ip dns set servers=$PIHOLE
/ip dns cache flush
$TGSendMessage Token=$TelegramBotToken ChatID=$TelegramChatID Text=$textSent;
For example I have these messages in mail box :
1. system,info,account user <username> logged in from <myLocal_ip> via winbox
2. system,critical,info cloud change time Dec/15/2022 11:45:46 => Dec/16/2022 17:45:02
3. dhcp,error defconf: failed to give out IP address: pool <default-dhcp> is empty
And extra question
4. Is it possible to somehow write script that will notify me if router is turned on? Pretty actual now when electricity infrastructure was ruined by f2cking russians and I want to know if my home router is working again or still no electricity at home.
And last question: where can I get all commands similar to [/system identity get name] ? For example I want to get cpu temp or cpu loading in current time.