diff options
Diffstat (limited to 'envmon/onewire2graphite.py')
-rwxr-xr-x | envmon/onewire2graphite.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/envmon/onewire2graphite.py b/envmon/onewire2graphite.py new file mode 100755 index 0000000..73e6b8d --- /dev/null +++ b/envmon/onewire2graphite.py @@ -0,0 +1,30 @@ +#!/usr/bin/python + +import time +import sys + +import onewire +import socket + +CARBON_SERVER = 'sonar.local.sublab.org' +CARBON_PORT = 2003 + +prefix = "envmon.beaglebone_local_sublab_org." + +sock = socket.socket() +sock.connect((CARBON_SERVER, CARBON_PORT)) + +while True: + message = '' + for sensor in onewire.sensors(): + try: + message += "%s %f %d\n" % (prefix + sensor, onewire.sensor(sensor).temperature, time.time()) + except Exception: + print >>sys.stderr, "On %s: Could not retrieve temperature for '%s':" % ( + time.strftime('%a, %d %b %Y %T %z'), sensor) + sys.excepthook(*sys.exc_info()) + print >>sys.stderr, '========================================' + if message: + print message + sock.sendall(message) + time.sleep(300-len(onewire.sensors())) |