Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

80 lines
3.7 KiB
PHP
Raw Permalink Normal View History

<?php
2020-09-21 15:40:17 +02:00
$sensors = dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND device_id = ? ORDER BY `group`, `sensor_descr`, `sensor_oid`, `sensor_index`', [$sensor_class, $device['device_id']]);
2016-02-26 23:40:34 +01:00
2011-05-16 12:48:50 +00:00
if (count($sensors)) {
2019-01-20 13:37:08 -06:00
$icons = \App\Models\Sensor::getIconMap();
$sensor_fa_icon = 'fa-' . (isset($icons[$sensor_class]) ? $icons[$sensor_class] : 'delicious');
2018-11-29 19:23:40 -06:00
echo '
2015-02-26 09:31:24 -07:00
<div class="row">
2014-02-26 22:33:45 +00:00
<div class="col-md-12">
<div class="panel panel-default panel-condensed">
<div class="panel-heading">';
2021-03-28 17:25:30 -05:00
echo '<a href="device/device=' . $device['device_id'] . '/tab=health/metric=' . strtolower($sensor_type) . '/"><i class="fa ' . $sensor_fa_icon . ' fa-lg icon-theme" aria-hidden="true"></i><strong> ' . \LibreNMS\Util\StringHelpers::niceCase($sensor_type) . '</strong></a>';
2014-02-26 22:33:45 +00:00
echo ' </div>
<table class="table table-hover table-condensed table-striped">';
2019-01-11 16:42:56 -06:00
$group = '';
2011-05-16 12:48:50 +00:00
foreach ($sensors as $sensor) {
2016-02-09 14:20:36 -06:00
if (! isset($sensor['sensor_current'])) {
2012-05-02 15:06:12 +00:00
$sensor['sensor_current'] = 'NaN';
}
2011-05-17 19:21:20 +00:00
2019-01-11 16:42:56 -06:00
if ($group != $sensor['group']) {
$group = $sensor['group'];
echo "<tr><td colspan='3'><strong>$group</strong></td></tr>";
}
2012-05-25 12:24:34 +00:00
// FIXME - make this "four graphs in popup" a function/include and "small graph" a function.
// FIXME - So now we need to clean this up and move it into a function. Isn't it just "print-graphrow"?
// FIXME - DUPLICATED IN health/sensors
2011-09-17 19:14:44 +00:00
$graph_array = [];
$graph_array['height'] = '100';
$graph_array['width'] = '210';
2019-06-23 00:29:12 -05:00
$graph_array['to'] = \LibreNMS\Config::get('time.now');
2011-09-17 19:14:44 +00:00
$graph_array['id'] = $sensor['sensor_id'];
$graph_array['type'] = $graph_type;
2019-06-23 00:29:12 -05:00
$graph_array['from'] = \LibreNMS\Config::get('time.day');
2011-09-17 19:14:44 +00:00
$graph_array['legend'] = 'no';
2011-09-20 14:37:54 +00:00
$link_array = $graph_array;
$link_array['page'] = 'graphs';
2011-09-17 19:14:44 +00:00
unset($link_array['height'], $link_array['width'], $link_array['legend']);
2021-03-28 17:25:30 -05:00
$link = \LibreNMS\Util\Url::generate($link_array);
2016-08-18 20:28:22 -05:00
if ($sensor['poller_type'] == 'ipmi') {
$sensor['sensor_descr'] = substr(ipmiSensorName($device['hardware'], $sensor['sensor_descr']), 0, 48);
} else {
$sensor['sensor_descr'] = substr($sensor['sensor_descr'], 0, 48);
}
2011-09-17 19:14:44 +00:00
$overlib_content = '<div class=overlib><span class=overlib-text>' . $device['hostname'] . ' - ' . $sensor['sensor_descr'] . '</span><br />';
2011-09-17 19:14:44 +00:00
foreach (['day', 'week', 'month', 'year'] as $period) {
2019-06-23 00:29:12 -05:00
$graph_array['from'] = \LibreNMS\Config::get("time.$period");
2021-03-28 17:25:30 -05:00
$overlib_content .= str_replace('"', "\'", \LibreNMS\Util\Url::graphTag($graph_array));
2015-07-13 20:10:26 +02:00
}
2011-09-17 19:14:44 +00:00
$overlib_content .= '</div>';
$graph_array['width'] = 80;
$graph_array['height'] = 20;
$graph_array['bg'] = 'ffffff00';
// the 00 at the end makes the area transparent.
2019-06-23 00:29:12 -05:00
$graph_array['from'] = \LibreNMS\Config::get('time.day');
2021-03-28 17:25:30 -05:00
$sensor_minigraph = \LibreNMS\Util\Url::lazyGraphTag($graph_array);
$sensor_current = $graph_type == 'sensor_state' ? get_state_label($sensor) : get_sensor_label_color($sensor);
2019-01-22 17:06:27 -06:00
echo '<tr>
2021-03-28 17:25:30 -05:00
<td class="col-md-4">' . \LibreNMS\Util\Url::overlibLink($link, \LibreNMS\Util\Rewrite::shortenIfType($sensor['sensor_descr']), $overlib_content, $sensor_class) . '</td>
<td class="col-md-4">' . \LibreNMS\Util\Url::overlibLink($link, $sensor_minigraph, $overlib_content, $sensor_class) . '</td>
<td class="col-md-4">' . \LibreNMS\Util\Url::overlibLink($link, $sensor_current, $overlib_content, $sensor_class) . '</td>
</tr>';
}//end foreach
2011-03-16 23:10:10 +00:00
echo '</table>';
2014-02-26 22:33:45 +00:00
echo '</div>';
echo '</div>';
echo '</div>';
}//end if