comparison web/log.py @ 378:16f96019a9e0

merge
author Matt Johnston <matt@ucc.asn.au>
date Sat, 30 Jun 2012 22:00:46 +0800
parents 55710361804b
children 0a8639039453
comparison
equal deleted inserted replaced
376:41c3d817878d 378:16f96019a9e0
60 if 'avrtemp' in sensor: 60 if 'avrtemp' in sensor:
61 continue 61 continue
62 if 'voltage' in sensor: 62 if 'voltage' in sensor:
63 have_volts = True 63 have_volts = True
64 vname = 'scalevolts' 64 vname = 'scalevolts'
65 graph_args = ['DEF:rawvolts=%(rrdfile)s:temp:AVERAGE:step=3600' % locals(), 65 graph_args.append('DEF:%(vname)s=%(rrdfile)s:temp:AVERAGE:step=3600' % locals())
66 'CDEF:scalevolts=rawvolts,2,-,0.1,/'] + graph_args
67 else: 66 else:
68 vname = 'temp%d' % n 67 vname = 'temp%d' % n
69 graph_args.append('DEF:%(vname)s=%(rrdfile)s:temp:AVERAGE' % locals()) 68 graph_args.append('DEF:raw%(vname)s=%(rrdfile)s:temp:AVERAGE' % locals())
69 graph_args.append('CDEF:%(vname)s=raw%(vname)s,0.1,*,2,+' % locals())
70 width = config.LINE_WIDTH 70 width = config.LINE_WIDTH
71 legend = config.SENSOR_NAMES.get(sensor, sensor) 71 legend = config.SENSOR_NAMES.get(sensor, sensor)
72 colour = config.SENSOR_COLOURS.get(legend, colour_from_string(sensor)) 72 colour = config.SENSOR_COLOURS.get(legend, colour_from_string(sensor))
73 graph_args.append('LINE%(width)f:%(vname)s#%(colour)s:%(legend)s' % locals()) 73 graph_args.append('LINE%(width)f:%(vname)s#%(colour)s:%(legend)s' % locals())
74 74
88 '-e', str(end), 88 '-e', str(end),
89 '-w', str(config.GRAPH_WIDTH), 89 '-w', str(config.GRAPH_WIDTH),
90 '-h', str(config.GRAPH_HEIGHT), 90 '-h', str(config.GRAPH_HEIGHT),
91 '--slope-mode', 91 '--slope-mode',
92 '--border', '0', 92 '--border', '0',
93 '--vertical-label', 'Temperature', 93 '--vertical-label', 'Voltage',
94 '--y-grid', '1:1', 94 '--y-grid', '0.1:1',
95 '--dynamic-labels',
95 '--grid-dash', '1:0', 96 '--grid-dash', '1:0',
96 '--color', 'GRID#00000000', 97 '--color', 'GRID#00000000',
97 '--color', 'MGRID#aaaaaa', 98 '--color', 'MGRID#aaaaaa',
98 '--color', 'BACK#ffffff', 99 '--color', 'BACK#ffffff',
99 '--disable-rrdtool-tag', 100 '--disable-rrdtool-tag',
101 '--imgformat', 'PNG'] \ 102 '--imgformat', 'PNG'] \
102 + graph_args 103 + graph_args
103 args += ['--font', 'DEFAULT:12:%s' % config.GRAPH_FONT] 104 args += ['--font', 'DEFAULT:12:%s' % config.GRAPH_FONT]
104 args += ['--font', 'WATERMARK:10:%s' % config.GRAPH_FONT] 105 args += ['--font', 'WATERMARK:10:%s' % config.GRAPH_FONT]
105 if have_volts: 106 if have_volts:
106 args += ['--right-axis', '0.1:2', # matches the scalevolts CDEF above 107 args += ['--right-axis', '10:-20', # matches the scalevolts CDEF above
107 '--right-axis-format', '%.2lf', 108 '--right-axis-format', '%.2lf',
108 '--right-axis-label', 'Voltage'] 109 '--right-axis-label', 'Temperature']
109 110
110 rrdtool.graph(*args) 111 rrdtool.graph(*args)
111 return tempf.read() 112 return tempf.read()
112 113
113 def sensor_update(sensor_id, measurements, first_real_time, time_step): 114 def sensor_update(sensor_id, measurements, first_real_time, time_step):