Freitag, 19 Januar 201819:02:46

RaspberryPi CPU Temperature Monitor Script.

This Python Script will do the following

It will periodically check the CPU Temperature of a Raspberry Pi and send a e-Mail in case a thrsold temperature is being reached.

I know, there are a lot of other scripts doing the same, available, but this script will not continously report the high temperature when reached.

If the thresold value is reached, one e-Mail will be sent and the next warn Mail will be sent after a timevalue which can be defined.

the following settings are available:

 

#####--- Configuration START-----------------> Modify your e-Mail and Mailserver Settings
Domain = "@your_domain.local" #Domain String of the MailSender. Exmaple @gmail.com
smptHost = "smtp.gmail.com" #SMTP MailServer used to send Mail. Example: smtp.gmail.com
smtpPort = 465 #SMTP Port of the MailServer used to send Mail. Example: 465 used by GMAIL or 25 unsecure
smtpUser = "Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!"# When using Authentication to send MAil, inert your username. Otherwise leave empty
smtpPassword = "gmail_password" # When using Authentication to send MAil, inert your password. Otherwise leave empty

# E-Mail
#mailSender = Host + Domain  #in case the sender of the mail should be Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!
mailSender = "Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!" # otherwise specify a sender e-Mail Address here
mailReceiver1 = "Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!" # to: E-Mail Address
mailReceiver2 = "" # CC: E-Mail Address # Additional recipient
mailReceiver3 = "" # CC: E-Mail Address # Addtional Recipient

# Temperature Settings
criticalTemperature = 59 # in degree celsius when an alarm mails shouzld be sent
shutdownTemperature = 70 # in degree celsius when system shouold do a safe shutdown
silencebetweenAlarm = 3600 # How many seconds between 2 Alarm Mails

 

Critical Temperature is the Temperature which will cause an alarm Mail

Shutdown Temperature is the Temperature when Raspberry Pi will shutdown

SilencebetweenAlarm is the time in seconds, between 2 Alarm Mais. This will avoid a Massmailing in case the Temperatur is staying over the Warn Temperature. In this case, all 3600 Seconds, an alarm Mail will be sent.

 

Copy the Script wherever you like ( /home/pi/monitoring-cpu-temp.py and call it like this.  ./monitoring-cpu-temp.py

It will display the current CPU Temperature and the Thresold Temperature.

CRON

Insert it into cron, to run it permanently in the background (sudo crontab -e)

*/5  * * * * sudo /usr/bin/python /home/pi/monitoring-cpu-temp.py >/dev/null 2>&1

This script will run every 5 Minutes.

Dateien:
monitoring-cpu-temp.py 1.0 Beliebt
(0 Stimmen)
Lizenz CharitywareTooltip Datum 2015-11-08 Dateigröße 1.54 KB Download 421 Download