Hi, everyone!
I setup simple netwatch script for sending me message in telegram if no ping on my pihole server and switching to another ip.
: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;
My question - is it possible to receive all messages which I usually getting from mikrotik by email, but in telegram? I setup logging for ‘account’, ‘critical’ and ‘error’ topics.
For example I have these messages in mail box :
- system,info,account user logged in from <myLocal_ip> via winbox
- system,critical,info cloud change time Dec/15/2022 11:45:46 => Dec/16/2022 17:45:02
- dhcp,error defconf: failed to give out IP address: pool is empty
And extra question - 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.