[Git][NTPsec/ntpsec][master] 3 commits: Generalize pi-temp-log to zone-temp-log
Gary E. Miller
gitlab at mg.gitlab.com
Tue Dec 13 00:27:20 UTC 2016
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
1c667101 by Richard Laager at 2016-12-12T16:18:07-08:00
Generalize pi-temp-log to zone-temp-log
Now works on any system that supports:
/sys/class/thermal/thermal_zone*/temp
Signed-off-by: Gary E. Miller <gem at rellim.com>
a
- - - - -
fdf7b519 by Gary E. Miller at 2016-12-12T16:23:07-08:00
zone-temp-log: fix log confusion.
/var/log/ntpstats/temp is already used by another program. So log
to /var/log/ntpstats/ztemps.
- - - - -
c66e223a by Gary E. Miller at 2016-12-12T16:26:27-08:00
zone-temp-log: fix file permissions
- - - - -
3 changed files:
- contrib/README
- − contrib/pi-temp-log
- + contrib/zone-temp-log
Changes:
=====================================
contrib/README
=====================================
--- a/contrib/README
+++ b/contrib/README
@@ -9,10 +9,6 @@ by 'ntpviz --local-temps'
gps-log is a tool to log gpsd data and write the data to stdout. Useful
to create a log that can be used by 'ntpviz --local-gps'
-pi-temp-log for the Raspberry Pi. It is a tool to read a magic /sys file
-to get the CPU temperature and write the temperatures to stdout. Useful
-to create a log that can be used by 'ntpviz --local-temps'
-
smartctl-temp-log for hard drives. It is a tool to read a hard drive's
SMART data to get the disk temperature and write the temperature
to stdout. Useful to create a log that can be used by 'ntpviz
@@ -22,3 +18,8 @@ temper-temp-log for TEMPer USB thermometer. Useful for logging room
temperature. This reads the thermometer using the temper-python command
line utility and writes the temperatures to stdout. Useful to create a
log that can be used by 'ntpviz --local-temps'
+
+zone-temp-log reads /sys/class/thermal/thermal_zone*/temp to find the CPU
+temperature. Writes all temperatures found to stdout on one line, preceded by
+the unix UTC time in seconds. This is useful on any Linux system that
+supports the /sys/class/thermal/thermal_zone*/temp interface.
=====================================
contrib/pi-temp-log deleted
=====================================
--- a/contrib/pi-temp-log
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env python
-# coding: utf-8
-"""\
-Usage: pi-temper-log
-
-Reads /sys/class/thermal/thermal_zone0/temp to find the CPU temperature
-on a Raspberry Pi. Writes all temperatures found to stdout on one line,
-preceded by the unix UTC time in seconds.
-
-
-Sample log:
-
-1471582083 PI 56.92
-1471582084 PI 57.458
-1471582085 PI 56.92
-1471582086 PI 56.92
-
-
-Field 1: unix UTC time in seconds
-Field 2: Loug source (PI)
-Field 3: CPU Temperature
-
-Sample crontab usage:
-
-# take and log cpu temp every 5 mins
-*/5 * * * * /usr/local/sbin/pi-temp-log >> /var/log/ntpstats/temps
-
-This ONLY works on a Raspberry Pi. Maybe not all of them. The way
-to read your system temperatures will be hardware specific.
-
-"""
-
-from __future__ import print_function
-
-import time
-
-now = int(time.time())
-
-f = open( '/sys/class/thermal/thermal_zone0/temp', 'r')
-for line in f:
- # just one line
- temp = float(line)
-
-f.close()
-
-temp /= 1000
-
-print( str(now) + ' PI ' + str(temp))
=====================================
contrib/zone-temp-log
=====================================
--- /dev/null
+++ b/contrib/zone-temp-log
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# coding: utf-8
+"""\
+Usage: zone-temper-log
+
+Reads /sys/class/thermal/thermal_zone*/temp to find the CPU temperature.
+Writes all temperatures found to stdout on one line, preceded by the
+unix UTC time in seconds.
+
+
+Sample log:
+
+1471582083 ZONE0 56.92
+1471582084 ZONE0 57.458
+1471582085 ZONE0 56.92
+1471582086 ZONE0 56.92
+
+
+Field 1: unix UTC time in seconds
+Field 2: Log source (ZONE)
+Field 3: CPU Temperature
+
+Sample crontab usage:
+
+# take and log cpu temp every 5 mins
+*/5 * * * * /usr/local/sbin/zone-temp-log >> /var/log/ntpstats/ztemps
+"""
+
+from __future__ import print_function
+
+import time
+
+now = int(time.time())
+
+zone = 0
+while True:
+ try:
+ f = open('/sys/class/thermal/thermal_zone{0}/temp'.format(zone), 'r')
+ except:
+ break
+ for line in f:
+ temp = float(line) / 1000
+ print('{0} ZONE{1} {2}'.format(now, zone, temp))
+ f.close()
+ zone = zone + 1
+
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/b3031adcee16bd6cd997d180a6147aa9299ca70f...c66e223a5a0b4408e191b8573088dca1b99c5191
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161213/ce7a4477/attachment.html>
More information about the vc
mailing list