Temperature by email Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Temperature by email

Post by huidbui25 »

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?
User avatar
Joulinar
Posts: 2023
Joined: Sat Nov 16, 2019 12:49 am

Re: Temperature by email

Post by Joulinar »

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.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: Temperature by email

Post by huidbui25 »

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 :)
User avatar
Joulinar
Posts: 2023
Joined: Sat Nov 16, 2019 12:49 am

Re: Temperature by email

Post by Joulinar »

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
User avatar
WarHawk
Posts: 606
Joined: Thu Jul 20, 2017 8:55 am

Re: Temperature by email

Post by WarHawk »

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/
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: Temperature by email

Post by huidbui25 »

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:

Code: Select all

*/2 * * * * bash /usr/local/bin/temp_mon
Is there something wrong with it?
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: Temperature by email

Post by huidbui25 »

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/
I wrote a little bash script and use package "dma" (including sendmail) to send emails.
User avatar
WarHawk
Posts: 606
Joined: Thu Jul 20, 2017 8:55 am

Re: Temperature by email

Post by WarHawk »

neat..post it up!
User avatar
Joulinar
Posts: 2023
Joined: Sat Nov 16, 2019 12:49 am

Re: Temperature by email

Post by Joulinar »

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
huidbui25
Posts: 32
Joined: Tue May 07, 2019 7:07 pm
Location: DE

Re: Temperature by email

Post by huidbui25 »

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.
Post Reply