|
8 | 8 | $sensor_color = (Config::get('applied_site_style') == 'dark') ? '#f2f2f2' : '#272b30'; |
9 | 9 | $background_color = (Config::get('applied_site_style') == 'dark') ? '#272b30' : '#ffffff'; |
10 | 10 | $variance_color = (Config::get('applied_site_style') == 'dark') ? '#3e444c' : '#c5c5c5'; |
| 11 | +$unit_label = str_replace('%', '%%', $sensor->unit()); |
11 | 12 |
|
12 | 13 | // Next line is a workaround while rrdtool --left-axis-format doesn't support %S |
13 | 14 | // https://github.com/oetiker/rrdtool-1.x/issues/1271 |
14 | | -//$rrd_options .= ' --left-axis-format "%4.1lF%S' . str_replace('%', '%%', $sensor->unit()) . '"'; |
15 | | -$rrd_options .= ' --left-axis-format "%5.1lf' . str_replace('%', '%%', trim(substr(Number::formatSi($sensor->sensor_current, 0, 0, ''), -1)) . $sensor->unit()) . '"'; |
| 15 | +$rrd_options .= ' --left-axis-format "%5.1lf' . trim(substr(Number::formatSi($sensor->sensor_current, 0, 0, ''), -1) . $unit_label) . '"'; |
16 | 16 | $rrd_options .= ' --vertical-label "' . $sensor->classDescr() . '"'; |
17 | 17 | $rrd_options .= ' DEF:sensor=' . $rrd_filename . ':sensor:AVERAGE'; |
18 | 18 | $rrd_options .= ' DEF:sensor_max=' . $rrd_filename . ':sensor:MAX'; |
19 | 19 | $rrd_options .= ' DEF:sensor_min=' . $rrd_filename . ':sensor:MIN'; |
20 | 20 | $rrd_options .= ' AREA:sensor_max' . $variance_color; |
21 | 21 | $rrd_options .= ' AREA:sensor_min' . $background_color; |
| 22 | +$field = 'sensor'; |
| 23 | +if ($unit_label == '°F') { |
| 24 | + $rrd_options .= ' CDEF:far=9,5,/,sensor,*,32,+ '; |
| 25 | + $field = 'far'; |
| 26 | +} |
22 | 27 |
|
23 | 28 | if ($sensor->hasThresholds()) { |
24 | 29 | $rrd_options .= ' COMMENT:"Alert thresholds\:"'; |
25 | | - $rrd_options .= ($sensor->sensor_limit_low) ? ' LINE1.5:' . $sensor->sensor_limit_low . '#00008b:"low = ' . Number::formatSi($sensor->sensor_limit_low, 2, 3, $sensor->unit()) . '":dashes' : ''; |
26 | | - $rrd_options .= ($sensor->sensor_limit_low_warn) ? ' LINE1.5:' . $sensor->sensor_limit_low_warn . '#005bdf:"low_warn = ' . Number::formatSi($sensor->sensor_limit_low_warn, 2, 3, $sensor->unit()) . '":dashes' : ''; |
27 | | - $rrd_options .= ($sensor->sensor_limit_warn) ? (' LINE1.5:' . $sensor->sensor_limit_warn . '#ffa420:"high_warn = ' . Number::formatSi($sensor->sensor_limit_warn, 2, 3, $sensor->unit()) . '":dashes') : ''; |
28 | | - $rrd_options .= ($sensor->sensor_limit) ? (' LINE1.5:' . $sensor->sensor_limit . '#ff0000:"high = ' . Number::formatSi($sensor->sensor_limit, 2, 3, $sensor->unit()) . '":dashes') : ''; |
| 30 | + $rrd_options .= ($sensor->sensor_limit_low !== null) ? ' LINE1.5:' . $sensor->sensor_limit_low . '#00008b:"low = ' . $sensor->formatValue('sensor_limit_low') . '":dashes' : ''; |
| 31 | + $rrd_options .= ($sensor->sensor_limit_low_warn !== null) ? ' LINE1.5:' . $sensor->sensor_limit_low_warn . '#005bdf:"low_warn = ' . $sensor->formatValue('sensor_limit_low_warn') . '":dashes' : ''; |
| 32 | + $rrd_options .= ($sensor->sensor_limit_warn !== null) ? (' LINE1.5:' . $sensor->sensor_limit_warn . '#ffa420:"high_warn = ' . $sensor->formatValue('sensor_limit_warn') . '":dashes') : ''; |
| 33 | + $rrd_options .= ($sensor->sensor_limit !== null) ? (' LINE1.5:' . $sensor->sensor_limit . '#ff0000:"high = ' . $sensor->formatValue('sensor_limit') . '":dashes') : ''; |
29 | 34 | } |
30 | 35 |
|
31 | 36 | // Workaround because rrdtool has trouble detecting the |
|
40 | 45 |
|
41 | 46 | $rrd_options .= ' COMMENT:"\n"'; |
42 | 47 | $rrd_options .= ' COMMENT:"' . Rrd::fixedSafeDescr('', 25) . ' Now Avg Min Max\n"'; |
43 | | -$rrd_options .= ' LINE2:sensor' . $sensor_color . ':"' . $sensor_descr_fixed . '"'; |
44 | | -$rrd_options .= ' GPRINT:sensor:LAST:%7.1lf%S' . str_replace('%', '%%', $sensor->unit()); |
45 | | -$rrd_options .= ' GPRINT:sensor:AVERAGE:%7.1lf%S' . str_replace('%', '%%', $sensor->unit()); |
46 | | -$rrd_options .= ' GPRINT:sensor:MIN:%7.1lf%S' . str_replace('%', '%%', $sensor->unit()); |
47 | | -$rrd_options .= ' GPRINT:sensor:MAX:%7.1lf%S' . str_replace('%', '%%', $sensor->unit()) . '\\l'; |
| 48 | +$rrd_options .= ' LINE2:' . $field . $sensor_color . ':"' . $sensor_descr_fixed . '"'; |
| 49 | +$rrd_options .= ' GPRINT:' . $field . ':LAST:%7.1lf%S' . $unit_label; |
| 50 | +$rrd_options .= ' GPRINT:' . $field . ':AVERAGE:%7.1lf%S' . $unit_label; |
| 51 | +$rrd_options .= ' GPRINT:' . $field . ':MIN:%7.1lf%S' . $unit_label; |
| 52 | +$rrd_options .= ' GPRINT:' . $field . ':MAX:%7.1lf%S' . $unit_label . '\\l'; |
48 | 53 |
|
49 | 54 | // Linear prediction of trend |
50 | 55 | if ($to > time()) { |
|
0 commit comments