Notification when the device temperature rises above the threshold. Sends notification to email or Telegram message.
The script sends the temperature of the MikroTik device and the CPU load. If the temperature of the device has exceeded the threshold value, and the processor load of the device is minimal, there may be a problem in the external environment (for example, the failure of an air conditioner in a server room).
Functions used:
MikroTik script is suitable for devices equipped with a temperature sensor. Tested on Mikrotik RB3011UiAS-RM, RouterOS 6.46.4 (stable).
The safe value of the CPU temperature will be different for each model of MikroTik devices, set the value of the script trigger temperature (MaxCPUTemp) depending on the model of your device (see the specification).
Article in other languages:
?? – MikroTik Scripts: Notificación de sobrecalentamiento del dispositivo
?? – MikroTik Скрипты: Уведомление о перегреве устройства
?? – Scripts MikroTik: Notification de surchauffe de l’appareil
?? – MikroTik-Scripts: Benachrichtigung über Überhitzung des Geräts
?? – MikroTik-scripts: Melding over oververhitting van het apparaat
Create script
The MaxCPUTemp parameter is the device temperature threshold after which a notification will be sent.
For the script to work, checking the device temperature requires permissions: read, write, test, policy.
[System] -> [Scripts] -> [+] -> [Name: DeviceOverheatingScript] -> [Policy: read, write, test, policy]
Script code:
# Name: DeviceOverheatingNotification v1
# Description: Notification when the device temperature rises above the threshold. Sends notification to email or Telegram message.
# Author: Yun Sergey, MHelp.pro 2020
# License: GPL-3.0 License
# Description, purpose and questions: https://mhelp.pro/mikrotik-scripts-device-overheating-notification/
# More scripts Mikrotik: https://mhelp.pro/tag/mikrotik-scripts/
# Verified: RouterBOARD 3011UiAS, RouterOS 6.47.8 (stable)
:local MaxCPUTemp 65;
:local CurrentTemp [/system health get temperature];
:local CurrentCPULoad [/system resource get cpu-load];
:local DeviceName [/system identity get name ];
:local Time [/system clock get time];
:local Date [/system clock get date];
#:log info "Script DeviceOverheatingNotification - start.";
:if ($CurrentTemp > $MaxCPUTemp) do={
#:log info "Script DeviceOverheatingNotification - Temperature threshold exceeded! Send Telegram message.";
# START Send Telegram Message
:local MessageText "\F0\9F\94\B4 <b>CRITICAL: $DeviceName Device Overheating!</b> %0D%0A Device Temperature: $CurrentTemp %C2%B0 C %0D%0A CPU Load: $CurrentCPULoad %";
:local SendTelegramMessage [:parse [/system script get MyTGBotSendMessage source]];
$SendTelegramMessage MessageText=$MessageText;
# END Send Telegram Message
#:log info "Script DeviceOverheatingNotification - Temperature threshold exceeded! Send Email.";
# START Send Email
:local SendTo "notify@mhelp.pro";
:local Subject "\F0\9F\94\B4 CRITICAL: $DeviceName [$Date $Time]";
:local MessageText "Device Temperature: $CurrentTemp °C, CPU Load: $CurrentCPULoad %";
:local FileName "";
:local SendEmail [:parse [/system script get SendEmailFunction source]];
$SendEmail SendTo=$SendTo TextMail=$MessageText Subject=$Subject FileName=$FileName;
# END Send Email
}
#:log info "Script DeviceOverheatingNotification - end.";
Add script to Scheduler
To run the script to check the temperature of the MikroTik device, permissions are required: read, write, test, policy.
[System] -> [Schedule] -> [+] -> [Name:CheckDeviceOverheating] —> [Interval: 00:01:00] -> [Policy: read, write, policy, test]
Or enter in a terminal:
/system scheduler add name=CheckDeviceOverheating policy=read,write,policy,test on-event="/system script run DeviceOverheatingScript" interval=1m comment="Checking device overheating"
Now you can increase control over your device by monitoring an important parameter – device temperature!
? How to create a script to check the overheating of a MikroTik device and send a notification to an email or Telegram message has been discussed in this article. I hope now you can get notification about MikroTik device overheating and CPU load on time. However, if you run into any problems while configuring the script, feel free to write in the comments. I will try to help.
RB5009
has a temperature sensor
BERNARD – did not work 🙁
Not all MikroTik devices have a temperature sensor. What is your device model?
My hardware Model: Metal G-52SHPacn.
: local CurrentTemp [ /system health get [ find name=temperature ] value ]; # By example : 31
: log warning “$CurrentTemp °C “; # ==> 31 °C
Same structure the Voltage
: local CurrentVoltage [ /system health get [ find name=voltage ] value ]; # By example : 23.8
: log warning “$CurrentVoltage VDC “; # ==> 23.8 VDC
Greetings
Bernard
Replace the original line :
:local CurrentTemp [/system health get temperature];
by the following hereafter:
: local CurrentTemp [ /system health get [find name=temperature] value ];
BERNARD
Próbowałem :local CurrentTemp [/system health get [find where name=”cpu-temperature”] value=value]; ale nie działa :/
Welcome back
You could do a script update ?
System temperature [/system health get temperature]
Cpu temperature [/system health get cpu-temperature]
In my case, the processor temperature is given.
Can I count on help and script improvement?
Best regards, Tomek from Poland
In my opinion it is
https://zapodaj.net/b8b59cc2bfb09.jpg.html
Hello
This scrypt doesn’t work for me.
My device is RB5009 with ver 7.1.1
I corrected one parameter:: local CurrentTemp [/ system health get temperature]; na: local CurrentTemp [/ system health get cpu-temperature];
but unfortunately it still doesn’t work. The ParseLogLoginFailure and ParseLogAccountEvents scripts work fine.
Hello, does this model have a temperature sensor?
Moim zdaniem jest
https://zapodaj.net/b8b59cc2bfb09.jpg.html