comparison web/log.py @ 28:e3e0ed7758f9

hmac
author Matt Johnston <matt@ucc.asn.au>
date Tue, 12 Jun 2012 00:35:23 +0800
parents dbbd503119ba
children 048143905092
comparison
equal deleted inserted replaced
27:dbbd503119ba 28:e3e0ed7758f9
1 import rrdtool 1 import rrdtool
2 import os 2 import os
3 import sys 3 import sys
4 4
5 DATA_PATH='data' 5 import config
6 6
7 def sensor_rrd_path(s): 7 def sensor_rrd_path(s):
8 return '%s/sensor_%s.rrd' % s 8 return '%s/sensor_%s.rrd' % (config.DATA_PATH, s)
9 9
10 def create_rrd(sensor_id): 10 def create_rrd(sensor_id):
11 rrdtool.create(sensor_rrd_path(sensor_id), '-s', '300', 11 rrdtool.create(sensor_rrd_path(sensor_id), '-s', '300',
12 'DS:temp:GAUGE:600:-10:100', 12 'DS:temp:GAUGE:600:-10:100',
13 'RRA:AVERAGE:0.5:1:1051200') 13 'RRA:AVERAGE:0.5:1:1051200')
36 36
37 meas = [] 37 meas = []
38 for s in sensors: 38 for s in sensors:
39 meas.append([]) 39 meas.append([])
40 40
41 def val_scale(v):
42 # convert decidegrees to degrees
43 return 0.1 * v
44
41 for n in xrange(num_measurements): 45 for n in xrange(num_measurements):
42 vals = [int(entries["meas%d" % n].strip().split())] 46 vals = [val_scale(int(entries["meas%d" % n].strip().split()))]
43 if len(vals) != num_sensors: 47 if len(vals) != num_sensors:
44 raise Exception("Wrong number of sensors for measurement %d" % n) 48 raise Exception("Wrong number of sensors for measurement %d" % n)
45 # we make an array of values for each sensor 49 # we make an array of values for each sensor
46 for s in xrange(num_sensors): 50 for s in xrange(num_sensors):
47 meas[s].append(vals[s]) 51 meas[s].append(vals[s])