diff --git a/app/Models/Sensor.php b/app/Models/Sensor.php
index 5952f3291d..1434662ff3 100644
--- a/app/Models/Sensor.php
+++ b/app/Models/Sensor.php
@@ -44,6 +44,38 @@ class Sensor extends DeviceRelatedModel
'percent' => 'percent',
];
+ public static $text = [
+ 'airflow' => 'Airflow',
+ 'ber' => 'Bit Error Rate',
+ 'charge' => 'Battery Charge',
+ 'chromatic_dispersion' => 'Chromatic Dispersion',
+ 'cooling' => 'Cooling',
+ 'count' => 'Count',
+ 'current' => 'Current',
+ 'dbm' => 'dBm',
+ 'delay' => 'Delay',
+ 'eer' => 'Energy Efficiency Ratio',
+ 'fanspeed' => 'Fanspeed',
+ 'frequency' => 'Frequency',
+ 'humidity' => 'Humidity',
+ 'load' => 'Load',
+ 'loss' => 'Loss',
+ 'power' => 'Power',
+ 'power_consumed' => 'Power Consumed',
+ 'power_factor' => 'Power Factor',
+ 'pressure' => 'Pressure',
+ 'quality_factor' => 'Quality factor',
+ 'runtime' => 'Runtime remaining',
+ 'signal' => 'Signal',
+ 'snr' => 'SNR',
+ 'state' => 'State',
+ 'temperature' => 'Temperature',
+ 'tv_signal' => 'TV signal',
+ 'voltage' => 'Voltage',
+ 'waterflow' => 'Water Flow Rate',
+ 'percent' => 'Percent',
+ ];
+
// ---- Helper Functions ----
public function classDescr()
diff --git a/includes/html/pages/device/health.inc.php b/includes/html/pages/device/health.inc.php
index 24df27e77e..4c2eb137fd 100644
--- a/includes/html/pages/device/health.inc.php
+++ b/includes/html/pages/device/health.inc.php
@@ -1,9 +1,6 @@
'device',
- 'device' => $device['device_id'],
- 'tab' => 'health',
+/*
+ * Main Sensors
+ */
+
+$main_sensors = [
+ 'storage' => 'Storage',
+ 'ucd_diskio' => 'Disk I/O',
+ 'mempools' => 'Memory pools',
+ 'processors' => 'Processors',
];
-print_optionbar_start();
-
-echo "Health » ";
-
-if (! $vars['metric']) {
- $vars['metric'] = 'overview';
+foreach (array_keys($main_sensors) as $health) {
+ if (dbFetchCell('select count(*) from ' . $health . ' WHERE device_id = ?', [$device['device_id']])) {
+ $datas[] = $health;
+ $type_text[$health] = $main_sensors[$health];
+ }
}
-unset($sep);
-foreach ($datas as $type) {
- echo $sep;
- if ($vars['metric'] == $type) {
- echo '';
- }
-
- $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';
+ foreach (Sensor::getTypes() as $sensor) {
+ if (Sensor::where('device_id', $device['device_id'])
+ ->where('sensor_class', $sensor)
+ ->count()) {
+ $datas[] = $sensor;
+ $type_text[$sensor] = Sensor::$text[$sensor];
}
}
-}
-$pagetitle[] = 'Health';
+ $type_text['qfp'] = 'QFP';
+
+ $link_array = [
+ 'page' => 'device',
+ 'device' => $device['device_id'],
+ 'tab' => 'health',
+ ];
+
+ print_optionbar_start();
+
+ echo "Health » ";
+
+ if (! $vars['metric']) {
+ $vars['metric'] = 'overview';
+ }
+
+ unset($sep);
+ foreach ($datas as $type) {
+ echo $sep;
+ if ($vars['metric'] == $type) {
+ echo '';
+ }
+
+ $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';
+ }
+ }
+ }
+
+ $pagetitle[] = 'Health';