Hi!
Is there a way to automatically monitor the temperature and make DietPi send an email when the rPi's temperature exceeds a certain threshold?
Temperature by email Topic is solved
Re: Temperature by email
Hi,
currently there is no Email notification function on DietPi.
There are a couple of tutorials on the web describing how to setup an email function as well as a temp monitoring script.
currently there is no Email notification function on DietPi.
There are a couple of tutorials on the web describing how to setup an email function as well as a temp monitoring script.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Re: Temperature by email
Thank you.
I thought there would be a DietPi method, but true, there are many scripts and ideas throughout the internet. I was unsure how to run a script like every few minutes, but I totally overlooked there is cronjobs for that haha ... should be feasible then 


Re: Temperature by email
Yes you could use DietPi cron function to schedule your job
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Re: Temperature by email
I installed lm-sensors on my system...actually on all my linux systems...it's nice to be able to see the temps of different temperature sensors on a machine, but not sure how it can email if temps get out of specs.
https://github.com/lm-sensors/lm-sensors
I did find this though
https://www.linux.com/tutorials/jazz-lm ... cations-0/
https://github.com/lm-sensors/lm-sensors
I did find this though
https://www.linux.com/tutorials/jazz-lm ... cations-0/
Re: Temperature by email
Okay, I got it to work to send an email.
The email arrives and tells the CPU temperature.
However, the cronjob doesn't seem to work. It's strange. Manually calling the monitoring script from the command line works like a charm and the email gets delivered within seconds, but calling the script by cronjob doesn't seem to cause anything, even after a reboot of rPi. Mmh ...
Here's the cronjob line, the script should be run every two seconds:
Is there something wrong with it?

However, the cronjob doesn't seem to work. It's strange. Manually calling the monitoring script from the command line works like a charm and the email gets delivered within seconds, but calling the script by cronjob doesn't seem to cause anything, even after a reboot of rPi. Mmh ...
Here's the cronjob line, the script should be run every two seconds:
Code: Select all
*/2 * * * * bash /usr/local/bin/temp_mon
Re: Temperature by email
I wrote a little bash script and use package "dma" (including sendmail) to send emails.WarHawk wrote: ↑Thu Feb 06, 2020 5:01 am I installed lm-sensors on my system...actually on all my linux systems...it's nice to be able to see the temps of different temperature sensors on a machine, but not sure how it can email if temps get out of specs.
https://github.com/lm-sensors/lm-sensors
I did find this though
https://www.linux.com/tutorials/jazz-lm ... cations-0/
Re: Temperature by email
Cron only allows for a minimum of one minute. What you could do is write a shell script with an infinite loop that runs your task, and then sleeps for 2 seconds. That way your task would be run more or less every 2 seconds, depending on how long the task itself takes.
Code: Select all
#!/bin/bash
while true; do
# Do something
sleep 2;
done
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Re: Temperature by email
Sorry, this was a typo. I meant minute instead of second. Later I want to run the script only like every 10 Minutes or so.
But apart from that, the current cronjob command doesn't seem to run at all, no matter if I set it to 1 minute or 2 minutes or whatever. I can execute the script manually, but cronjob fails. No clue why.
But apart from that, the current cronjob command doesn't seem to run at all, no matter if I set it to 1 minute or 2 minutes or whatever. I can execute the script manually, but cronjob fails. No clue why.