dcaccount
Posts: 159
Joined: Sun Jan 15, 2017 11:56 am

CPU temperature a system status monitor

Sat Mar 25, 2017 10:37 am

Hello,
I have configured my Rpi3 as FTP server under RASPBIAN JESSIE LITE.

I would like to keep track or to monitor from time to time the CPU temperature and clock, being the Rpi3 hidden in a box.

Is there a piece of software to keep track or to report this information?

Thanks a lot,
daniele

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: CPU temperature a system status monitor

Sat Mar 25, 2017 10:55 am

cat /sys/class/thermal/thermal_zone0/temp

You can read that in python

Code: Select all

#!/usr/bin/python3
from time import sleep
while True:
  sleep(300)
  with open('/sys/class/thermal/thermal_zone0/temp') as temp:
    curCtemp = float(temp.read()) / 1000
    curFtemp = ((curCtemp / 5) * 9) + 32
    print ("C:", curCtemp, " F:", curFtemp)
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

dcaccount
Posts: 159
Joined: Sun Jan 15, 2017 11:56 am

Re: CPU temperature a system status monitor

Sat Mar 25, 2017 11:11 am

DougieLawson wrote:cat /sys/class/thermal/thermal_zone0/temp

You can read that in python

Code: Select all

#!/usr/bin/python3
from time import sleep
while True:
  sleep(300)
  with open('/sys/class/thermal/thermal_zone0/temp') as temp:
    curCtemp = float(temp.read()) / 1000
    curFtemp = ((curCtemp / 5) * 9) + 32
    print ("C:", curCtemp, " F:", curFtemp)
Thank you for advising.
You mean that the current temperature is stored in the file:
/sys/class/thermal/thermal_zone/temp?

User avatar
rpdom
Posts: 15418
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: CPU temperature a system status monitor

Sat Mar 25, 2017 12:46 pm

dcaccount wrote:You mean that the current temperature is stored in the file:
/sys/class/thermal/thermal_zone/temp?
It's not a real file. It's a direct interface to the internal temperature measuring system. It takes a reading every time you read the "file".

User avatar
DougieLawson
Posts: 36322
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: CPU temperature a system status monitor

Sat Mar 25, 2017 2:22 pm

/sys, /proc and /dev are all virtual filesystems that are generated automagically by the Linux kernel.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

no3rpi
Posts: 13
Joined: Fri Mar 31, 2017 11:44 am

Re: CPU temperature a system status monitor

Mon Apr 03, 2017 6:37 am

I made on my RPI3 a small bash script that is running every 15 min and save the CPU temp in a file located in a share that can be accessed remotely ( by www or samba/ftp... ).
Change your paths ( for save data and stored scripts ) as you need:

Code: Select all

#!/bin/sh
CPUD=`/opt/vc/bin/vcgencmd measure_temp`
data=`date +"%d-%m-%y %T"`

echo $data $CPUD >> /var/www/html/status/cpu-temp.txt

#CPUT=${CPUD%.*}
#CPUT=${CPUT##*=}
#echo $CPUT

exit
and add to cron: crontab -e

Code: Select all

#check & save cpu temp every 15 min
*/15 * * * * /root/scripts/cputemp.sh
edit:
if you want a permanent monitoring solution have a look at monit.

itsmedoofer
Posts: 359
Joined: Wed Sep 25, 2013 8:43 am

Re: CPU temperature a system status monitor

Mon Apr 03, 2017 11:28 am

Hi,

If you have an Android device, there is a nice little App called RasPi Check that will query all this and more.... It's in the PlayStore...

Return to “Raspbian”