Mercurial > templog
comparison web/log.py @ 464:c3926e7cfb0c
LHS axis scaling easily changeable
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 21 Jan 2013 07:25:29 +0800 |
parents | 94932e7051e5 |
children | 30390852cb5d |
comparison
equal
deleted
inserted
replaced
458:94932e7051e5 | 464:c3926e7cfb0c |
---|---|
67 os.environ['MATT_PNG_BODGE_FILTER'] = 'paeth' | 67 os.environ['MATT_PNG_BODGE_FILTER'] = 'paeth' |
68 rrds = all_sensors() | 68 rrds = all_sensors() |
69 | 69 |
70 graph_args = [] | 70 graph_args = [] |
71 have_volts = False | 71 have_volts = False |
72 | |
73 ## volts = temp * volts_div + volts_shift | |
74 #volts_div = 10 | |
75 #volts_shift = 2 | |
76 volts_div = 1 | |
77 volts_shift = 0 | |
78 | |
79 volts_mult = 1.0/volts_div | |
80 | |
72 for n, (rrdfile, sensor) in enumerate(rrds): | 81 for n, (rrdfile, sensor) in enumerate(rrds): |
73 unit = None | 82 unit = None |
74 if 'avrtemp' in sensor: | 83 if 'avrtemp' in sensor: |
75 continue | 84 continue |
76 if 'voltage' in sensor: | 85 if 'voltage' in sensor: |
84 graph_args.append('CDEF:%(vname)s=raw%(vname)s,-0.2,*,3,+' % locals()) | 93 graph_args.append('CDEF:%(vname)s=raw%(vname)s,-0.2,*,3,+' % locals()) |
85 else: | 94 else: |
86 vname = 'temp%d' % n | 95 vname = 'temp%d' % n |
87 graph_args.append('DEF:raw%(vname)s=%(rrdfile)s:temp:AVERAGE' % locals()) | 96 graph_args.append('DEF:raw%(vname)s=%(rrdfile)s:temp:AVERAGE' % locals()) |
88 # limit max temp to 50 | 97 # limit max temp to 50 |
89 graph_args.append('CDEF:%(vname)s=raw%(vname)s,35,GT,UNKN,raw%(vname)s,0.1,*,2,+,IF' % locals()) | 98 graph_args.append('CDEF:%(vname)s=raw%(vname)s,38,GT,UNKN,raw%(vname)s,%(volts_mult)f,*,%(volts_shift)f,+,IF' % locals()) |
90 unit = '<span face="Liberation Serif">º</span>C' | 99 unit = '<span face="Liberation Serif">º</span>C' |
91 | 100 |
92 format_last_value = None | 101 format_last_value = None |
93 if unit: | 102 if unit: |
94 try: | 103 try: |
122 '-w', str(config.GRAPH_WIDTH), | 131 '-w', str(config.GRAPH_WIDTH), |
123 '-h', str(config.GRAPH_HEIGHT), | 132 '-h', str(config.GRAPH_HEIGHT), |
124 '--slope-mode', | 133 '--slope-mode', |
125 '--border', '0', | 134 '--border', '0', |
126 # '--vertical-label', 'Voltage', | 135 # '--vertical-label', 'Voltage', |
127 '--y-grid', '0.1:1', | 136 '--y-grid', '%(volts_mult)f:1' % locals(), |
128 '--dynamic-labels', | 137 '--dynamic-labels', |
129 '--grid-dash', '1:0', | 138 '--grid-dash', '1:0', |
130 '--zoom', str(config.ZOOM), | 139 '--zoom', str(config.ZOOM), |
131 '--color', 'GRID#00000000', | 140 '--color', 'GRID#00000000', |
132 '--color', 'MGRID#aaaaaa', | 141 '--color', 'MGRID#aaaaaa', |
137 '--imgformat', 'PNG'] \ | 146 '--imgformat', 'PNG'] \ |
138 + graph_args | 147 + graph_args |
139 args += ['--font', 'DEFAULT:12:%s' % config.GRAPH_FONT] | 148 args += ['--font', 'DEFAULT:12:%s' % config.GRAPH_FONT] |
140 args += ['--font', 'WATERMARK:10:%s' % config.GRAPH_FONT] | 149 args += ['--font', 'WATERMARK:10:%s' % config.GRAPH_FONT] |
141 if have_volts: | 150 if have_volts: |
142 args += ['--right-axis', '10:-20', # matches the scalevolts CDEF above | 151 volts_shift_div = volts_div * volts_shift |
143 '--right-axis-format', '%.0lf', | 152 args += ['--right-axis', '%(volts_div)f:-%(volts_shift_div)f' % locals(), |
153 # '--right-axis-format', '%.0lf', | |
144 # '--right-axis-label', 'Temperature' | 154 # '--right-axis-label', 'Temperature' |
145 ] | 155 ] |
146 | 156 |
147 print>>sys.stderr, ' '.join("'%s'" % s for s in args) | 157 print>>sys.stderr, ' '.join("'%s'" % s for s in args) |
148 rrdtool.graph(*args) | 158 rrdtool.graph(*args) |