comparison web/log.py @ 45:425af63d584d

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