comparison web/log.py @ 350:03322c38b4a9

Create with a start date so that it works
author Matt Johnston <matt@ucc.asn.au>
date Sat, 23 Jun 2012 23:37:01 +0800
parents d6219df77c41
children 425af63d584d
comparison
equal deleted inserted replaced
346:d6219df77c41 350:03322c38b4a9
19 def all_sensors(): 19 def all_sensors():
20 return [(r, os.path.basename(r[:-4])) 20 return [(r, os.path.basename(r[:-4]))
21 for r in glob.glob('%s/*.rrd' % config.DATA_PATH)] 21 for r in glob.glob('%s/*.rrd' % config.DATA_PATH)]
22 22
23 def create_rrd(sensor_id): 23 def create_rrd(sensor_id):
24 rrdtool.create(sensor_rrd_path(sensor_id), '-s', '300', 24 # start date of 10 seconds into 1970 is used so that we can
25 'DS:temp:GAUGE:600:-10:100', 25 # update with prior values straight away.
26 'RRA:AVERAGE:0.5:1:1051200') 26 args = [sensor_rrd_path(sensor_id),
27 '--start', '10',
28 '--step', '300',
29 'DS:temp:GAUGE:600:-10:100',
30 'RRA:AVERAGE:0.5:1:1051200']
27 31
32 rrdtool.create(*args)
28 33
29 # stolen from viewmtn, stolen from monotone-viz 34 # stolen from viewmtn, stolen from monotone-viz
30 def colour_from_string(str): 35 def colour_from_string(str):
31 def f(off): 36 def f(off):
32 return ord(hashval[off]) / 256.0 37 return ord(hashval[off]) / 256.0
54 '-w', str(config.GRAPH_WIDTH), 59 '-w', str(config.GRAPH_WIDTH),
55 '-h', str(config.GRAPH_HEIGHT), 60 '-h', str(config.GRAPH_HEIGHT),
56 '--slope-mode', 61 '--slope-mode',
57 '--border', '0', 62 '--border', '0',
58 '--color', 'BACK#ffffff', 63 '--color', 'BACK#ffffff',
64 '--alt-y-grid',
59 '--imgformat', 'PNG'] \ 65 '--imgformat', 'PNG'] \
60 + graph_args 66 + graph_args
61 if config.GRAPH_FONT: 67 if config.GRAPH_FONT:
62 args += ['--font', 'DEFAULT:0:%s' % config.GRAPH_FONT] 68 args += ['--font', 'DEFAULT:0:%s' % config.GRAPH_FONT]
63 print>>sys.stderr, args 69 print>>sys.stderr, args