2010-02-07 14:17:02 +00:00
|
|
|
<?php
|
2009-05-11 13:58:05 +00:00
|
|
|
|
2022-01-08 18:17:08 +01:00
|
|
|
use App\Models\Sensor;
|
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
$storage = dbFetchCell('select count(*) from storage WHERE device_id = ?', [$device['device_id']]);
|
|
|
|
$diskio = dbFetchRows('SELECT * FROM `ucd_diskio` WHERE device_id = ? ORDER BY diskio_descr', [$device['device_id']]);
|
|
|
|
$mempools = dbFetchCell('select count(*) from mempools WHERE device_id = ?', [$device['device_id']]);
|
|
|
|
$processor = dbFetchCell('select count(*) from processors WHERE device_id = ?', [$device['device_id']]);
|
2010-07-07 14:34:44 +00:00
|
|
|
|
2019-10-05 11:10:34 +02:00
|
|
|
/*
|
|
|
|
* QFP count for cisco devices
|
|
|
|
*/
|
|
|
|
$qfp = 0;
|
|
|
|
if ($device['os_group'] == 'cisco') {
|
|
|
|
$component = new LibreNMS\Component();
|
2020-09-21 15:40:17 +02:00
|
|
|
$components = $component->getComponents($device['device_id'], ['type'=> 'cisco-qfp']);
|
2019-10-05 11:10:34 +02:00
|
|
|
$components = $components[$device['device_id']];
|
|
|
|
$qfp = count($components);
|
|
|
|
}
|
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
$count = dbFetchCell("select count(*) from sensors WHERE sensor_class='count' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$temperatures = dbFetchCell("select count(*) from sensors WHERE sensor_class='temperature' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$humidity = dbFetchCell("select count(*) from sensors WHERE sensor_class='humidity' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$fans = dbFetchCell("select count(*) from sensors WHERE sensor_class='fanspeed' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$volts = dbFetchCell("select count(*) from sensors WHERE sensor_class='voltage' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$current = dbFetchCell("select count(*) from sensors WHERE sensor_class='current' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$freqs = dbFetchCell("select count(*) from sensors WHERE sensor_class='frequency' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$runtime = dbFetchCell("select count(*) from sensors WHERE sensor_class='runtime' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$power = dbFetchCell("select count(*) from sensors WHERE sensor_class='power' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$power_consumed = dbFetchCell("select count(*) from sensors WHERE sensor_class='power_consumed' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$power_factor = dbFetchCell("select count(*) from sensors WHERE sensor_class='power_factor' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$dBm = dbFetchCell("select count(*) from sensors WHERE sensor_class='dBm' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$states = dbFetchCell("select count(*) from sensors WHERE sensor_class='state' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$charge = dbFetchCell("select count(*) from sensors WHERE sensor_class='charge' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$load = dbFetchCell("select count(*) from sensors WHERE sensor_class='load' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$loss = dbFetchCell("select count(*) from sensors WHERE sensor_class='loss' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$signal = dbFetchCell("select count(*) from sensors WHERE sensor_class='signal' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$airflow = dbFetchCell("select count(*) from sensors WHERE sensor_class='airflow' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$snr = dbFetchCell("select count(*) from sensors WHERE sensor_class='snr' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$pressure = dbFetchCell("select count(*) from sensors WHERE sensor_class='pressure' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$cooling = dbFetchCell("select count(*) from sensors WHERE sensor_class='cooling' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$delay = dbFetchCell("select count(*) from sensors WHERE sensor_class='delay' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$quality_factor = dbFetchCell("select count(*) from sensors WHERE sensor_class='quality_factor' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$chromatic_dispersion = dbFetchCell("select count(*) from sensors WHERE sensor_class='chromatic_dispersion' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$ber = dbFetchCell("select count(*) from sensors WHERE sensor_class='ber' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$eer = dbFetchCell("select count(*) from sensors WHERE sensor_class='eer' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$waterflow = dbFetchCell("select count(*) from sensors WHERE sensor_class='waterflow' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$percent = dbFetchCell("select count(*) from sensors WHERE sensor_class='percent' AND device_id = ?", [$device['device_id']]);
|
|
|
|
$tv_signal = dbFetchCell("select count(*) from sensors WHERE sensor_class='tv_signal' AND device_id = ?", [$device['device_id']]);
|
2022-01-08 18:17:08 +01:00
|
|
|
$bitrate = Sensor::where('sensor_class', 'bitrate')->where('device_id', $device['device_id'])->count();
|
2021-07-11 14:08:14 +02:00
|
|
|
|
|
|
|
unset($datas);
|
|
|
|
$datas[] = 'overview';
|
|
|
|
if ($processor) {
|
|
|
|
$datas[] = 'processor';
|
|
|
|
}
|
|
|
|
|
2019-10-05 11:10:34 +02:00
|
|
|
if ($qfp) {
|
|
|
|
$datas[] = 'qfp';
|
|
|
|
}
|
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($mempools) {
|
|
|
|
$datas[] = 'mempool';
|
|
|
|
}
|
2017-12-13 03:27:10 +01:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($storage) {
|
|
|
|
$datas[] = 'storage';
|
|
|
|
}
|
2018-01-18 21:50:19 +01:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($diskio) {
|
|
|
|
$datas[] = 'diskio';
|
|
|
|
}
|
2018-01-18 21:50:19 +01:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($charge) {
|
|
|
|
$datas[] = 'charge';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($temperatures) {
|
|
|
|
$datas[] = 'temperature';
|
2020-05-31 01:24:43 +02:00
|
|
|
}
|
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($humidity) {
|
|
|
|
$datas[] = 'humidity';
|
|
|
|
}
|
2020-10-20 17:11:12 -07:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($fans) {
|
|
|
|
$datas[] = 'fanspeed';
|
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($volts) {
|
|
|
|
$datas[] = 'voltage';
|
|
|
|
}
|
2012-04-26 16:32:34 +00:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($freqs) {
|
|
|
|
$datas[] = 'frequency';
|
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($runtime) {
|
|
|
|
$datas[] = 'runtime';
|
|
|
|
}
|
2012-04-06 13:56:23 +00:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($current) {
|
|
|
|
$datas[] = 'current';
|
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($power) {
|
|
|
|
$datas[] = 'power';
|
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($power_consumed) {
|
|
|
|
$datas[] = 'power_consumed';
|
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($power_factor) {
|
|
|
|
$datas[] = 'power_factor';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($dBm) {
|
|
|
|
$datas[] = 'dbm';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($states) {
|
|
|
|
$datas[] = 'state';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($count) {
|
|
|
|
$datas[] = 'count';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($load) {
|
|
|
|
$datas[] = 'load';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($signal) {
|
|
|
|
$datas[] = 'signal';
|
|
|
|
}
|
2009-05-11 13:58:05 +00:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($tv_signal) {
|
|
|
|
$datas[] = 'tv_signal';
|
|
|
|
}
|
|
|
|
|
2022-01-08 18:17:08 +01:00
|
|
|
if ($bitrate) {
|
|
|
|
$datas[] = 'bitrate';
|
|
|
|
}
|
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
if ($airflow) {
|
|
|
|
$datas[] = 'airflow';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($snr) {
|
|
|
|
$datas[] = 'snr';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($pressure) {
|
|
|
|
$datas[] = 'pressure';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($cooling) {
|
|
|
|
$datas[] = 'cooling';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($delay) {
|
|
|
|
$datas[] = 'delay';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($quality_factor) {
|
|
|
|
$datas[] = 'quality_factor';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($chromatic_dispersion) {
|
|
|
|
$datas[] = 'chromatic_dispersion';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($ber) {
|
|
|
|
$datas[] = 'ber';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($eer) {
|
|
|
|
$datas[] = 'eer';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($waterflow) {
|
|
|
|
$datas[] = 'waterflow';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($loss) {
|
|
|
|
$datas[] = 'loss';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($percent) {
|
|
|
|
$datas[] = 'percent';
|
|
|
|
}
|
|
|
|
|
|
|
|
$type_text['overview'] = 'Overview';
|
|
|
|
$type_text['charge'] = 'Battery Charge';
|
|
|
|
$type_text['temperature'] = 'Temperature';
|
|
|
|
$type_text['humidity'] = 'Humidity';
|
|
|
|
$type_text['mempool'] = 'Memory';
|
|
|
|
$type_text['storage'] = 'Disk Usage';
|
|
|
|
$type_text['diskio'] = 'Disk I/O';
|
|
|
|
$type_text['processor'] = 'Processor';
|
|
|
|
$type_text['voltage'] = 'Voltage';
|
|
|
|
$type_text['fanspeed'] = 'Fanspeed';
|
|
|
|
$type_text['frequency'] = 'Frequency';
|
|
|
|
$type_text['runtime'] = 'Runtime remaining';
|
|
|
|
$type_text['current'] = 'Current';
|
|
|
|
$type_text['power'] = 'Power';
|
|
|
|
$type_text['power_consumed'] = 'Power Consumed';
|
|
|
|
$type_text['power_factor'] = 'Power Factor';
|
|
|
|
$type_text['dbm'] = 'dBm';
|
|
|
|
$type_text['state'] = 'State';
|
|
|
|
$type_text['count'] = 'Count';
|
|
|
|
$type_text['load'] = 'Load';
|
|
|
|
$type_text['signal'] = 'Signal';
|
|
|
|
$type_text['tv_signal'] = 'TV signal';
|
2022-01-08 18:17:08 +01:00
|
|
|
$type_text['bitrate'] = 'Bitrate';
|
2021-07-11 14:08:14 +02:00
|
|
|
$type_text['airflow'] = 'Airflow';
|
|
|
|
$type_text['snr'] = 'SNR';
|
|
|
|
$type_text['pressure'] = 'Pressure';
|
|
|
|
$type_text['cooling'] = 'Cooling';
|
|
|
|
$type_text['delay'] = 'Delay';
|
|
|
|
$type_text['quality_factor'] = 'Quality factor';
|
|
|
|
$type_text['chromatic_dispersion'] = 'Chromatic Dispersion';
|
|
|
|
$type_text['ber'] = 'Bit Error Rate';
|
|
|
|
$type_text['eer'] = 'Energy Efficiency Ratio';
|
|
|
|
$type_text['waterflow'] = 'Water Flow Rate';
|
|
|
|
$type_text['loss'] = 'Loss';
|
|
|
|
$type_text['qfp'] = 'QFP';
|
|
|
|
$type_text['percent'] = 'Percent';
|
|
|
|
|
|
|
|
$link_array = [
|
|
|
|
'page' => 'device',
|
|
|
|
'device' => $device['device_id'],
|
|
|
|
'tab' => 'health',
|
|
|
|
];
|
|
|
|
|
|
|
|
print_optionbar_start();
|
|
|
|
|
|
|
|
echo "<span style='font-weight: bold;'>Health</span> » ";
|
|
|
|
|
|
|
|
if (! $vars['metric']) {
|
|
|
|
$vars['metric'] = 'overview';
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($sep);
|
|
|
|
foreach ($datas as $type) {
|
|
|
|
echo $sep;
|
|
|
|
if ($vars['metric'] == $type) {
|
|
|
|
echo '<span class="pagemenu-selected">';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo generate_link($type_text[$type], $link_array, ['metric' => $type]);
|
|
|
|
if ($vars['metric'] == $type) {
|
|
|
|
echo '</span>';
|
2021-07-10 14:31:43 +02:00
|
|
|
}
|
2015-07-13 20:10:26 +02:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
$sep = ' | ';
|
|
|
|
}
|
|
|
|
|
|
|
|
print_optionbar_end();
|
|
|
|
|
|
|
|
$metric = basename($vars['metric']);
|
|
|
|
if (is_file("includes/html/pages/device/health/$metric.inc.php")) {
|
|
|
|
include "includes/html/pages/device/health/$metric.inc.php";
|
|
|
|
} else {
|
|
|
|
foreach ($datas as $type) {
|
|
|
|
if ($type != 'overview') {
|
|
|
|
$graph_title = $type_text[$type];
|
|
|
|
$graph_array['type'] = 'device_' . $type;
|
|
|
|
include 'includes/html/print-device-graph.php';
|
2015-07-13 20:10:26 +02:00
|
|
|
}
|
|
|
|
}
|
2021-07-11 14:08:14 +02:00
|
|
|
}
|
2011-10-18 14:27:21 +00:00
|
|
|
|
2021-07-11 14:08:14 +02:00
|
|
|
$pagetitle[] = 'Health';
|