[Git][NTPsec/ntpsec][master] Deleted 1 commit: Add pi-cpu-log

Gary E. Miller gitlab at mg.gitlab.com
Fri Aug 19 04:52:44 UTC 2016


Gary E. Miller pushed to branch master at NTPsec / ntpsec


WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below.


Deleted commits:
916800ca by Gary E. Miller at 2016-08-18T21:51:58-07:00
Add pi-cpu-log

A tool to read the CPU temp on a Raspberry pis and output in a format
usefull for temperature logging.

- - - - -


2 changed files:

- contrib/README
- + contrib/pi-temp-log


Changes:

=====================================
contrib/README
=====================================
--- a/contrib/README
+++ b/contrib/README
@@ -5,3 +5,7 @@ efforts.
 cpu-temp-log is a tool to use the output of 'sensors -u' and write the
 motherboard temperatures to stdout.  Usefull to create a log that can be used
 by 'ntpviz --local-cpu-temp'
+
+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.  Usefull
+to create a log that can be used by 'ntpviz --local-cpu-temp'


=====================================
contrib/pi-temp-log
=====================================
--- /dev/null
+++ b/contrib/pi-temp-log
@@ -0,0 +1,47 @@
+#!/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, 
+preceeded by the unix UTC time in seconds.
+
+
+Sample log:
+
+1471582083 56.92
+1471582084 57.458
+1471582085 56.92
+1471582086 56.92
+
+
+Field 1: unix UTC time in seconds
+Field 2: CPU Temerature
+
+Sample crontab usage:
+
+# take and log cpu temp every 5 mins
+*/5 * * * * /usr/local/sbin/pi-temp-log >> /var/log/ntpstats/cputemp
+
+This ONLY works on a Raspberry Pi.  Maybe not all of them.  The way 
+to read your system temperatures will be hardware specific.
+
+"""
+
+
+import sys, time
+
+now = int(time.time())
+sys.stdout.write(  str(now) )
+
+f = open( '/sys/class/thermal/thermal_zone0/temp', 'r')
+for line in f:
+    # just one line
+    temp = float(line)
+
+f.close()
+
+temp /= 1000
+
+sys.stdout.write(  ' ' + str(temp) + '\n' )



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/916800caea9cde4db7de2a4013355e6d8310ffbd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160819/f654d5b1/attachment.html>


More information about the vc mailing list