Skip to content

Commit 759b09a

Browse files
murrantStyleCIBotlaf
authored
Per user Fahrenheit temperature display units (librenms#17453)
* Per user Fahrenheit temperature display units Murica units for coworker Alerts and everything is still in Celsius (such as alerts and device sensor settings) and that will not change. Users can format Celsius to Fahrenheit in their alert template if they want. * Apply fixes from StyleCI * Update SensorsController.php --------- Co-authored-by: StyleCI Bot <[email protected]> Co-authored-by: Neil Lathwood <[email protected]>
1 parent fae3448 commit 759b09a

File tree

16 files changed

+141
-115
lines changed

16 files changed

+141
-115
lines changed

LibreNMS/Util/Rewrite.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,9 @@ public static function addIpv6Brackets($ip): ?string
402402
{
403403
return IPv6::isValid($ip) ? "[$ip]" : $ip;
404404
}
405+
406+
public static function celsiusToFahrenheit(float $celsius): float
407+
{
408+
return round($celsius * 1.8 + 32, 2);
409+
}
405410
}

app/Http/Controllers/Table/SensorsController.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Illuminate\Validation\Rule;
1010
use LibreNMS\Enum\Severity;
1111
use LibreNMS\Util\Html;
12-
use LibreNMS\Util\Number;
1312
use LibreNMS\Util\Url;
1413

1514
class SensorsController extends TableController
@@ -79,8 +78,8 @@ public function formatItem($sensor): array
7978
$hostname = Blade::render('<x-device-link :device="$device" />', ['device' => $sensor->device]);
8079
$link = Url::generate(['page' => 'device', 'device' => $sensor['device_id'], 'tab' => 'health', 'metric' => $sensor->sensor_class]);
8180
$descr = Url::graphPopup($graph_array, $sensor->sensor_descr, $link);
82-
$mini_graph = Url::graphPopup($graph_array);
83-
$sensor_current = $sensor->sensor_current === null ? 'NaN' : Html::severityToLabel($sensor->currentStatus(), $sensor->formatValue());
81+
$mini_graph = Url::graphPopup($graph_array, null, $link);
82+
$sensor_current = Html::severityToLabel($sensor->currentStatus(), $sensor->formatValue());
8483
$alert = $sensor->currentStatus() == Severity::Error ? '<i class="fa fa-flag fa-lg" style="color:red" aria-hidden="true"></i>' : '';
8584

8685
// show graph row inline
@@ -98,11 +97,8 @@ public function formatItem($sensor): array
9897
'graph' => $mini_graph,
9998
'alert' => $alert,
10099
'sensor_current' => $sensor_current,
101-
'sensor_limit_low' => is_null($sensor->sensor_limit_low) ? '-' :
102-
'<span class=\'label label-default\'>' . trim(Number::formatSi($sensor->sensor_limit_low, 2, 0, '') . $sensor->unit()) . '</span>',
103-
'sensor_limit' => is_null($sensor->sensor_limit) ? '-' :
104-
'<span class=\'label label-default\'>' . trim(Number::formatSi($sensor->sensor_limit, 2, 0, '') . $sensor->unit()) . '</span>',
105-
100+
'sensor_limit_low' => Html::severityToLabel(Severity::Unknown, $sensor->formatValue('sensor_limit_low')),
101+
'sensor_limit' => Html::severityToLabel(Severity::Unknown, $sensor->formatValue('sensor_limit')),
106102
];
107103
}
108104
}

app/Http/Controllers/UserPreferencesController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function index(Request $request)
7575
'site_style_default' => $styles[$default_style] ?? $default_style,
7676
'site_styles' => $styles,
7777
'timezone' => UserPref::getPref($user, 'timezone'),
78+
'temp_units' => UserPref::getPref($user, 'temp_units'),
7879
'hide_dashboard_editor' => UserPref::getPref($user, 'hide_dashboard_editor') ?? 0,
7980
'global_search_ctrlf_focus' => UserPref::getPref($user, 'global_search_ctrlf_focus'),
8081
];
@@ -117,6 +118,7 @@ public function store(Request $request)
117118
'required',
118119
Rule::in(array_merge(['default'], timezone_identifiers_list())),
119120
],
121+
'temp_units' => 'required|in:default,f',
120122
'hide_dashboard_editor' => 'required|integer',
121123
'global_search_ctrlf_focus' => 'required|integer',
122124
];

app/Models/Sensor.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use LibreNMS\Enum\Severity;
1212
use LibreNMS\Interfaces\Models\Keyable;
1313
use LibreNMS\Util\Number;
14+
use LibreNMS\Util\Rewrite;
1415
use LibreNMS\Util\Time;
1516

1617
class Sensor extends DeviceRelatedModel implements Keyable
@@ -87,6 +88,13 @@ public function classDescrLong(): string
8788

8889
public function unit(): string
8990
{
91+
if ($this->sensor_class == 'temperature') {
92+
/** @var ?User $user */
93+
$user = auth()->user();
94+
95+
return $user && UserPref::getPref($user, 'temp_units') == 'f' ? '°F' : '°C';
96+
}
97+
9098
return __('sensors.' . $this->sensor_class . '.unit');
9199
}
92100

@@ -144,15 +152,24 @@ public function guessLimits(bool $high, bool $low): void
144152
/**
145153
* Format current value for user display including units.
146154
*/
147-
public function formatValue(): string
155+
public function formatValue($field = 'sensor_current'): string
148156
{
149-
$value = $this->sensor_current;
157+
$value = $this->$field;
158+
159+
if ($value === null) {
160+
return $field == 'sensor_current' ? 'NaN' : '-';
161+
}
162+
150163
if (in_array($this->rrd_type, ['COUNTER', 'DERIVE', 'DCOUNTER', 'DDERIVE'])) {
151164
//compute and display an approx rate for this sensor
152165
$value = Number::formatSi(max(0, $value - $this->sensor_prev) / LibrenmsConfig::get('rrd.step', 300), 2, 3, '');
153166
}
154167

168+
/** @var ?User $user */
169+
$user = auth()->user();
170+
155171
return match ($this->sensor_class) {
172+
'temperature' => $user && UserPref::getPref($user, 'temp_units') == 'f' ? Rewrite::celsiusToFahrenheit($value) . ' °F' : "$value °C",
156173
'state' => $this->currentTranslation()?->state_descr ?? 'Unknown',
157174
'current', 'power' => Number::formatSi($value, 3, 0, $this->unit()),
158175
'runtime' => Time::formatInterval($value * 60),
@@ -177,6 +194,10 @@ public function currentStatus(): Severity
177194
return $this->currentTranslation()?->severity() ?? Severity::Unknown;
178195
}
179196

197+
if ($this->sensor_current === null) {
198+
return Severity::Unknown;
199+
}
200+
180201
if ($this->sensor_limit !== null && $this->sensor_current >= $this->sensor_limit) {
181202
return Severity::Error;
182203
}
Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,48 @@
11
<?php
22

3-
require 'includes/html/graphs/common.inc.php';
4-
5-
$col_w = 7 + strlen($unit);
6-
$rrd_options .= " COMMENT:'" . str_pad($unit_long, 19) . str_pad('Cur', $col_w) . str_pad('Min', $col_w) . str_pad('Max', $col_w) . "Avg\\n'";
7-
8-
foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_index`', [$class, $device['device_id']]) as $index => $sensor) {
9-
// FIXME generic colour function
10-
switch ($index % 7) {
11-
case 0:
12-
$colour = 'CC0000';
13-
break;
3+
use App\Models\Sensor;
4+
use LibreNMS\Exceptions\RrdGraphException;
145

15-
case 1:
16-
$colour = '008C00';
17-
break;
18-
19-
case 2:
20-
$colour = '4096EE';
21-
break;
6+
require 'includes/html/graphs/common.inc.php';
227

23-
case 3:
24-
$colour = '73880A';
25-
break;
8+
$sensors = Sensor::where('sensor_class', $class)->where('device_id', $device['device_id'])->orderBy('sensor_descr')->get();
269

27-
case 4:
28-
$colour = 'D01F3C';
29-
break;
10+
if ($sensors->isEmpty()) {
11+
throw new RrdGraphException('No Sensors');
12+
}
3013

31-
case 5:
32-
$colour = '36393D';
33-
break;
14+
$unit_short = $sensors->first()->unit();
15+
$unit_long = $sensors->first()->unitLong();
3416

35-
case 6:
36-
default:
37-
$colour = 'FF0084';
38-
}//end switch
17+
$col_w = 7 + strlen($unit_short);
18+
$rrd_options .= " COMMENT:'" . str_pad($unit_long, 19) . str_pad('Cur', $col_w) . str_pad('Min', $col_w) . str_pad('Max', $col_w) . "Avg\\n'";
3919

40-
$sensor_descr_fixed = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($sensor['sensor_descr'], 12);
20+
foreach ($sensors as $index => $sensor) {
21+
// FIXME generic colour function
22+
$colour = match ($index % 7) {
23+
0 => 'CC0000',
24+
1 => '008C00',
25+
2 => '4096EE',
26+
3 => '73880A',
27+
4 => 'D01F3C',
28+
5 => '36393D',
29+
default => 'FF0084',
30+
};
31+
32+
$sensor_descr_fixed = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($sensor->sensor_descr, 12);
4133
$rrd_filename = get_sensor_rrd($device, $sensor);
42-
$rrd_options .= " DEF:sensor{$sensor['sensor_id']}=$rrd_filename:sensor:AVERAGE";
43-
$rrd_options .= " LINE1:sensor{$sensor['sensor_id']}#$colour:'$sensor_descr_fixed'";
44-
$rrd_options .= " GPRINT:sensor{$sensor['sensor_id']}:LAST:%5.1lf$unit";
45-
$rrd_options .= " GPRINT:sensor{$sensor['sensor_id']}:MIN:%5.1lf$unit";
46-
$rrd_options .= " GPRINT:sensor{$sensor['sensor_id']}:MAX:%5.1lf$unit";
47-
$rrd_options .= " GPRINT:sensor{$sensor['sensor_id']}:AVERAGE:%5.2lf$unit\\l ";
34+
$field = 'sensor' . $sensor->sensor_id;
35+
$rrd_options .= " DEF:$field=$rrd_filename:sensor:AVERAGE";
36+
37+
if ($unit_short == '°F') {
38+
$rrd_options .= " CDEF:far{$sensor->sensor_id}=9,5,/,$field,*,32,+ ";
39+
$field = 'far' . $sensor->sensor_id;
40+
}
41+
42+
$rrd_options .= " LINE1:$field#$colour:'$sensor_descr_fixed'";
43+
$rrd_options .= " GPRINT:$field:LAST:%5.1lf$unit_short";
44+
$rrd_options .= " GPRINT:$field:MIN:%5.1lf$unit_short";
45+
$rrd_options .= " GPRINT:$field:MAX:%5.1lf$unit_short";
46+
$rrd_options .= " GPRINT:$field:AVERAGE:%5.2lf$unit_short\\l ";
4847
$iter++;
4948
}//end foreach

includes/html/graphs/device/temperature.inc.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,5 @@
33
$rrd_options = ' --alt-y-grid';
44

55
$class = 'temperature';
6-
$unit = 'C';
7-
$unit_long = 'Degree C';
86

97
require 'includes/html/graphs/device/sensor.inc.php';

includes/html/graphs/sensor/generic.inc.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,29 @@
88
$sensor_color = (Config::get('applied_site_style') == 'dark') ? '#f2f2f2' : '#272b30';
99
$background_color = (Config::get('applied_site_style') == 'dark') ? '#272b30' : '#ffffff';
1010
$variance_color = (Config::get('applied_site_style') == 'dark') ? '#3e444c' : '#c5c5c5';
11+
$unit_label = str_replace('%', '%%', $sensor->unit());
1112

1213
// Next line is a workaround while rrdtool --left-axis-format doesn't support %S
1314
// 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) . '"';
1616
$rrd_options .= ' --vertical-label "' . $sensor->classDescr() . '"';
1717
$rrd_options .= ' DEF:sensor=' . $rrd_filename . ':sensor:AVERAGE';
1818
$rrd_options .= ' DEF:sensor_max=' . $rrd_filename . ':sensor:MAX';
1919
$rrd_options .= ' DEF:sensor_min=' . $rrd_filename . ':sensor:MIN';
2020
$rrd_options .= ' AREA:sensor_max' . $variance_color;
2121
$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+
}
2227

2328
if ($sensor->hasThresholds()) {
2429
$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') : '';
2934
}
3035

3136
// Workaround because rrdtool has trouble detecting the
@@ -40,11 +45,11 @@
4045

4146
$rrd_options .= ' COMMENT:"\n"';
4247
$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';
4853

4954
// Linear prediction of trend
5055
if ($to > time()) {

includes/html/pages/device/edit/sensors-common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
<td>' . $sensor['sensor_class'] . '</td>
6060
<td>' . $sensor['sensor_type'] . '</td>
6161
<td style="white-space: nowrap">' . $sensor['sensor_descr'] . '</td>
62-
<td>' . $sensor['sensor_current'] . '</td>
62+
<td>' . $sensor['sensor_current'] . ($sensor['sensor_class'] == 'temperature' ? '°C' : '') . '</td>
6363
<td>
6464
<div class="form-group has-feedback">
6565
<input type="text" class="form-control col-sm-1 input-sm sensor" id="high-' . $sensor['device_id'] . '" data-device_id="' . $sensor['device_id'] . '" data-value_type="sensor_limit" data-sensor_id="' . $sensor['sensor_id'] . '" value="' . $sensor['sensor_limit'] . '">

includes/html/pages/device/entphysical.inc.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Illuminate\Database\Eloquent\Builder;
4+
use LibreNMS\Util\Html;
45

56
function printEntPhysical($device, $ent, $level, $class)
67
{
@@ -65,7 +66,7 @@ function printEntPhysical($device, $ent, $level, $class)
6566
echo "<a href='graphs/id=" . $sensor->sensor_id . '/type=sensor_' . $sensor->sensor_class . "/' onmouseover=\"return overlib('<img src=\'graph.php?id=" . $sensor->sensor_id . '&amp;type=sensor_' . $sensor->sensor_class . '&amp;from=-2d&amp;to=now&amp;width=400&amp;height=150&amp;a=' . $ent['entPhysical_id'] . "\'><img src=\'graph.php?id=" . $sensor->sensor_id . '&amp;type=sensor_' . $sensor->sensor_class . '&amp;from=-2w&amp;to=now&amp;width=400&amp;height=150&amp;a=' . $ent['entPhysical_id'] . "\'>', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\">";
6667
//echo "<span style='color: #000099;'>" . $sensor->sensor_class . ': ' . $sensor->sensor_descr . '</span>';
6768
echo ' ';
68-
echo $sensor->sensor_class == 'state' ? get_state_label($sensor->toArray()) : get_sensor_label_color($sensor->toArray());
69+
echo Html::severityToLabel($sensor->currentStatus(), $sensor->formatValue());
6970
echo '</a>';
7071
}
7172
}
@@ -125,7 +126,7 @@ function printEntPhysical($device, $ent, $level, $class)
125126
echo "<a href='graphs/id=" . $sensor->sensor_id . '/type=sensor_' . $sensor->sensor_class . "/' onmouseover=\"return overlib('<img src=\'graph.php?id=" . $sensor->sensor_id . '&amp;type=sensor_' . $sensor->sensor_class . '&amp;from=-2d&amp;to=now&amp;width=400&amp;height=150&amp;a=' . $ent['entPhysical_id'] . "\'><img src=\'graph.php?id=" . $sensor->sensor_id . '&amp;type=sensor_' . $sensor->sensor_class . '&amp;from=-2w&amp;to=now&amp;width=400&amp;height=150&amp;a=' . $ent['entPhysical_id'] . "\'>', LEFT,FGCOLOR,'#e5e5e5', BGCOLOR, '#c0c0c0', BORDER, 5, CELLPAD, 4, CAPCOLOR, '#050505');\" onmouseout=\"return nd();\">";
126127
echo "<span style='color: #000099;'>" . $disp_name . ' ' . $sensor->sensor_class . '</span>';
127128
echo ' ';
128-
echo $sensor->sensor_class == 'state' ? get_state_label($sensor->toArray()) : get_sensor_label_color($sensor->toArray());
129+
echo Html::severityToLabel($sensor->currentStatus(), $sensor->formatValue());
129130
echo '</a><br>';
130131
}
131132
echo '</div>';
Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<?php
22

3-
$row = 1;
3+
use LibreNMS\Enum\Severity;
4+
use LibreNMS\Util\Html;
45

5-
foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_descr`', [$class, $device['device_id']]) as $sensor) {
6-
if (! is_integer($row / 2)) {
6+
$row = 0;
7+
8+
$sensors = \App\Models\Sensor::where('sensor_class', $class)->where('device_id', $device['device_id'])->orderBy('sensor_descr')->get();
9+
10+
foreach ($sensors as $sensor) {
11+
if (! is_integer($row++ / 2)) {
712
$row_colour = \LibreNMS\Config::get('list_colour.even');
813
} else {
914
$row_colour = \LibreNMS\Config::get('list_colour.odd');
@@ -15,29 +20,24 @@
1520
$sensor_descr = $sensor['sensor_descr'];
1621
}
1722

18-
$sensor_current = $graph_type == 'sensor_state' ? get_state_label($sensor) : get_sensor_label_color($sensor);
19-
20-
$sensor_limit = trim(\LibreNMS\Util\Number::formatSi($sensor['sensor_limit'], 2, 0, '') . $unit);
21-
$sensor_limit_low = trim(\LibreNMS\Util\Number::formatSi($sensor['sensor_limit_low'], 2, 0, '') . $unit);
22-
$sensor_limit_warn = trim(\LibreNMS\Util\Number::formatSi($sensor['sensor_limit_warn'], 2, 0, '') . $unit);
23-
$sensor_limit_low_warn = trim(\LibreNMS\Util\Number::formatSi($sensor['sensor_limit_low_warn'], 2, 0, '') . $unit);
23+
$sensor_current = Html::severityToLabel($sensor->currentStatus(), $sensor->formatValue());
2424

2525
echo "<div class='panel panel-default'>
2626
<div class='panel-heading'>
2727
<h3 class='panel-title'>$sensor_descr <div class='pull-right'>$sensor_current";
2828

2929
//Display low and high limit if they are not null (format_si() is changing null to '0')
30-
if (! is_null($sensor['sensor_limit_low'])) {
31-
echo " <span class='label label-default'>low: $sensor_limit_low</span>";
30+
if (! is_null($sensor->sensor_limit_low)) {
31+
echo ' ' . Html::severityToLabel(Severity::Unknown, 'low: ' . $sensor->formatValue('sensor_limit_low'));
3232
}
33-
if (! is_null($sensor['sensor_limit_low_warn'])) {
34-
echo " <span class='label label-default'>low_warn: $sensor_limit_low_warn</span>";
33+
if (! is_null($sensor->sensor_limit_low_warn)) {
34+
echo ' ' . Html::severityToLabel(Severity::Unknown, 'low_warn: ' . $sensor->formatValue('sensor_limit_low_warn'));
3535
}
36-
if (! is_null($sensor['sensor_limit_warn'])) {
37-
echo " <span class='label label-default'>high_warn: $sensor_limit_warn</span>";
36+
if (! is_null($sensor->sensor_limit_warn)) {
37+
echo ' ' . Html::severityToLabel(Severity::Unknown, 'high_warn: ' . $sensor->formatValue('sensor_limit_warn'));
3838
}
39-
if (! is_null($sensor['sensor_limit'])) {
40-
echo " <span class='label label-default'>high: $sensor_limit</span>";
39+
if (! is_null($sensor->sensor_limit)) {
40+
echo ' ' . Html::severityToLabel(Severity::Unknown, 'high: ' . $sensor->formatValue('sensor_limit'));
4141
}
4242

4343
echo '</div></h3>
@@ -50,6 +50,4 @@
5050
include 'includes/html/print-graphrow.inc.php';
5151

5252
echo '</div></div>';
53-
54-
$row++;
5553
}

0 commit comments

Comments
 (0)