Files
librenms-librenms/includes/html/pages/device/apps/smart.inc.php

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

191 lines
6.2 KiB
PHP
Raw Normal View History

<?php
print_optionbar_start();
$link_array = [
'page' => 'device',
'device' => $device['device_id'],
'tab' => 'apps',
'app' => 'smart',
];
$drives = [];
update SMART monitoring to the use JSON (#15132) * rework into a json app and support the old style * working now * add health checking * add some datapoints to make writing alerts easy * add a few missing item for has checks * rework the app page * use the right var for id9 * print the self test log if we have it * add a graph for the max temp * display the max temp graph * display the health pass in the disk list if we have the data * fix legacy handling and set app as ok * replace id190 and id194 with the more useful maxtemp graph on the apps page * don't print the additional info area for legacy extends * add id232 * add id252 graph support * properly display id232 now * do not display SSD graphs for non-SSD disks * for legacy extends, make sure we don't have a bad line * add missing label for Product value * fix metrics * rework the metrics stuff a bit more * typo fix * more smart metrics cleanup * add exit info to metrics * style cleanup and logic checking for when disks are all now fine * fix checking for no more health errors * update the docs for SMART for v1 and remove slightly pointless notes about useSN * update the docs * initial test stuff * add missing tests for the legacy code * save if it it is legacy or not * style cleanup * update the smart legacy test * style cleanup * more test tweaking * some more style cleanup * more test fixes * correct the disk ID for the legacy test da0 -> Z304VCFY * more tests update * more test cleanup * begin cleanup of the v1 tests * more v1 test updates * more tests for v1 * more test cleanup * fix exit_nonzero and add unhealthy metric * add smart alerts * add the metric unhealthy to the stat test * use app data for the smart-common.inc.php
2023-07-24 10:03:45 -05:00
$app_data = $app->data;
array_multisort(array_keys($app_data['disks']), SORT_ASC, $app_data['disks']);
update SMART monitoring to the use JSON (#15132) * rework into a json app and support the old style * working now * add health checking * add some datapoints to make writing alerts easy * add a few missing item for has checks * rework the app page * use the right var for id9 * print the self test log if we have it * add a graph for the max temp * display the max temp graph * display the health pass in the disk list if we have the data * fix legacy handling and set app as ok * replace id190 and id194 with the more useful maxtemp graph on the apps page * don't print the additional info area for legacy extends * add id232 * add id252 graph support * properly display id232 now * do not display SSD graphs for non-SSD disks * for legacy extends, make sure we don't have a bad line * add missing label for Product value * fix metrics * rework the metrics stuff a bit more * typo fix * more smart metrics cleanup * add exit info to metrics * style cleanup and logic checking for when disks are all now fine * fix checking for no more health errors * update the docs for SMART for v1 and remove slightly pointless notes about useSN * update the docs * initial test stuff * add missing tests for the legacy code * save if it it is legacy or not * style cleanup * update the smart legacy test * style cleanup * more test tweaking * some more style cleanup * more test fixes * correct the disk ID for the legacy test da0 -> Z304VCFY * more tests update * more test cleanup * begin cleanup of the v1 tests * more v1 test updates * more tests for v1 * more test cleanup * fix exit_nonzero and add unhealthy metric * add smart alerts * add the metric unhealthy to the stat test * use app data for the smart-common.inc.php
2023-07-24 10:03:45 -05:00
foreach ($app_data['disks'] as $label => $disk_data) {
$disk = $label;
if ($vars['disk'] == $disk) {
$label = '<span class="pagemenu-selected">' . $label . '</span>';
}
update SMART monitoring to the use JSON (#15132) * rework into a json app and support the old style * working now * add health checking * add some datapoints to make writing alerts easy * add a few missing item for has checks * rework the app page * use the right var for id9 * print the self test log if we have it * add a graph for the max temp * display the max temp graph * display the health pass in the disk list if we have the data * fix legacy handling and set app as ok * replace id190 and id194 with the more useful maxtemp graph on the apps page * don't print the additional info area for legacy extends * add id232 * add id252 graph support * properly display id232 now * do not display SSD graphs for non-SSD disks * for legacy extends, make sure we don't have a bad line * add missing label for Product value * fix metrics * rework the metrics stuff a bit more * typo fix * more smart metrics cleanup * add exit info to metrics * style cleanup and logic checking for when disks are all now fine * fix checking for no more health errors * update the docs for SMART for v1 and remove slightly pointless notes about useSN * update the docs * initial test stuff * add missing tests for the legacy code * save if it it is legacy or not * style cleanup * update the smart legacy test * style cleanup * more test tweaking * some more style cleanup * more test fixes * correct the disk ID for the legacy test da0 -> Z304VCFY * more tests update * more test cleanup * begin cleanup of the v1 tests * more v1 test updates * more tests for v1 * more test cleanup * fix exit_nonzero and add unhealthy metric * add smart alerts * add the metric unhealthy to the stat test * use app data for the smart-common.inc.php
2023-07-24 10:03:45 -05:00
if (isset($app_data['disks'][$disk]['health_pass'])) {
if ($app_data['disks'][$disk]['health_pass'] == 1) {
$health_status = '(OK)';
} else {
$health_status = '(FAIL)';
}
}
array_push($drives, generate_link($label, $link_array, ['disk' => $disk]) . $health_status);
}
printf('%s | drives: %s', generate_link('All Drives', $link_array), implode(', ', $drives));
print_optionbar_end();
if (isset($vars['disk'])) {
update SMART monitoring to the use JSON (#15132) * rework into a json app and support the old style * working now * add health checking * add some datapoints to make writing alerts easy * add a few missing item for has checks * rework the app page * use the right var for id9 * print the self test log if we have it * add a graph for the max temp * display the max temp graph * display the health pass in the disk list if we have the data * fix legacy handling and set app as ok * replace id190 and id194 with the more useful maxtemp graph on the apps page * don't print the additional info area for legacy extends * add id232 * add id252 graph support * properly display id232 now * do not display SSD graphs for non-SSD disks * for legacy extends, make sure we don't have a bad line * add missing label for Product value * fix metrics * rework the metrics stuff a bit more * typo fix * more smart metrics cleanup * add exit info to metrics * style cleanup and logic checking for when disks are all now fine * fix checking for no more health errors * update the docs for SMART for v1 and remove slightly pointless notes about useSN * update the docs * initial test stuff * add missing tests for the legacy code * save if it it is legacy or not * style cleanup * update the smart legacy test * style cleanup * more test tweaking * some more style cleanup * more test fixes * correct the disk ID for the legacy test da0 -> Z304VCFY * more tests update * more test cleanup * begin cleanup of the v1 tests * more v1 test updates * more tests for v1 * more test cleanup * fix exit_nonzero and add unhealthy metric * add smart alerts * add the metric unhealthy to the stat test * use app data for the smart-common.inc.php
2023-07-24 10:03:45 -05:00
if (! isset($app_data['legacy'])) {
print_optionbar_start();
if (isset($app_data['disks'][$vars['disk']]['disk'])) {
echo 'Disk: ' . $app_data['disks'][$vars['disk']]['disk'] . "<br>\n";
}
if (isset($app_data['disks'][$vars['disk']]['serial'])) {
echo 'Serial: ' . $app_data['disks'][$vars['disk']]['serial'] . "<br>\n";
}
if (isset($app_data['disks'][$vars['disk']]['vendor'])) {
echo 'Vendor: ' . $app_data['disks'][$vars['disk']]['vendor'] . "<br>\n";
}
if (isset($app_data['disks'][$vars['disk']]['product'])) {
echo 'Product: ' . $app_data['disks'][$vars['disk']]['product'] . "<br>\n";
}
if (isset($app_data['disks'][$vars['disk']]['model_family'])) {
echo 'Model Family: ' . $app_data['disks'][$vars['disk']]['model_family'] . "<br>\n";
}
if (isset($app_data['disks'][$vars['disk']]['model_number'])) {
echo 'Model Number: ' . $app_data['disks'][$vars['disk']]['model_number'] . "<br>\n";
}
if (isset($app_data['disks'][$vars['disk']]['device_model'])) {
echo 'Device Model: ' . $app_data['disks'][$vars['disk']]['device_model'] . "<br>\n";
}
if (isset($app_data['disks'][$vars['disk']]['revision'])) {
echo 'Revision: ' . $app_data['disks'][$vars['disk']]['revision'] . "<br>\n";
}
if (isset($app_data['disks'][$vars['disk']]['fw_version'])) {
echo 'FW Version: ' . $app_data['disks'][$vars['disk']]['fw_version'] . "<br>\n";
}
if (isset($app_data['disks'][$vars['disk']]['selftest_log'])) {
echo '<pre>' . str_replace('n#', "\n#", $app_data['disks'][$vars['disk']]['selftest_log']) . "</pre><br>\n";
}
}
print_optionbar_end();
$graphs = [
'smart_big5' => 'Reliability / Age',
'smart_temp' => 'Temperature',
'smart_ssd' => 'SSD-specific',
'smart_other' => 'Other',
'smart_tests_status' => 'S.M.A.R.T self-tests results',
'smart_tests_ran' => 'S.M.A.R.T self-tests run count',
'smart_runtime' => 'Power On Hours',
];
update SMART monitoring to the use JSON (#15132) * rework into a json app and support the old style * working now * add health checking * add some datapoints to make writing alerts easy * add a few missing item for has checks * rework the app page * use the right var for id9 * print the self test log if we have it * add a graph for the max temp * display the max temp graph * display the health pass in the disk list if we have the data * fix legacy handling and set app as ok * replace id190 and id194 with the more useful maxtemp graph on the apps page * don't print the additional info area for legacy extends * add id232 * add id252 graph support * properly display id232 now * do not display SSD graphs for non-SSD disks * for legacy extends, make sure we don't have a bad line * add missing label for Product value * fix metrics * rework the metrics stuff a bit more * typo fix * more smart metrics cleanup * add exit info to metrics * style cleanup and logic checking for when disks are all now fine * fix checking for no more health errors * update the docs for SMART for v1 and remove slightly pointless notes about useSN * update the docs * initial test stuff * add missing tests for the legacy code * save if it it is legacy or not * style cleanup * update the smart legacy test * style cleanup * more test tweaking * some more style cleanup * more test fixes * correct the disk ID for the legacy test da0 -> Z304VCFY * more tests update * more test cleanup * begin cleanup of the v1 tests * more v1 test updates * more tests for v1 * more test cleanup * fix exit_nonzero and add unhealthy metric * add smart alerts * add the metric unhealthy to the stat test * use app data for the smart-common.inc.php
2023-07-24 10:03:45 -05:00
if ($app_data['disks'][$vars['disk']]['is_ssd'] != 1) {
unset($graphs['smart_ssd']);
}
} else {
update SMART monitoring to the use JSON (#15132) * rework into a json app and support the old style * working now * add health checking * add some datapoints to make writing alerts easy * add a few missing item for has checks * rework the app page * use the right var for id9 * print the self test log if we have it * add a graph for the max temp * display the max temp graph * display the health pass in the disk list if we have the data * fix legacy handling and set app as ok * replace id190 and id194 with the more useful maxtemp graph on the apps page * don't print the additional info area for legacy extends * add id232 * add id252 graph support * properly display id232 now * do not display SSD graphs for non-SSD disks * for legacy extends, make sure we don't have a bad line * add missing label for Product value * fix metrics * rework the metrics stuff a bit more * typo fix * more smart metrics cleanup * add exit info to metrics * style cleanup and logic checking for when disks are all now fine * fix checking for no more health errors * update the docs for SMART for v1 and remove slightly pointless notes about useSN * update the docs * initial test stuff * add missing tests for the legacy code * save if it it is legacy or not * style cleanup * update the smart legacy test * style cleanup * more test tweaking * some more style cleanup * more test fixes * correct the disk ID for the legacy test da0 -> Z304VCFY * more tests update * more test cleanup * begin cleanup of the v1 tests * more v1 test updates * more tests for v1 * more test cleanup * fix exit_nonzero and add unhealthy metric * add smart alerts * add the metric unhealthy to the stat test * use app data for the smart-common.inc.php
2023-07-24 10:03:45 -05:00
$graphs = [];
if ($app_data['has']['id5'] == 1) {
$graphs['smart_id5'] = 'ID# 5, Reallocated Sectors Count';
}
if ($app_data['has']['id9'] == 1) {
$graphs['smart_id9'] = 'ID# 9, Power On Hours';
}
if ($app_data['has']['id10'] == 1) {
$graphs['smart_id10'] = 'ID# 10, Spin Retry Count';
}
if ($app_data['has']['id173'] == 1) {
$graphs['smart_id173'] = 'ID# 173, SSD Wear Leveller Worst Case Erase Count';
}
if ($app_data['has']['id177'] == 1) {
$graphs['smart_id177'] = 'ID# 177, SSD Wear Leveling Count';
}
if ($app_data['has']['id183'] == 1) {
$graphs['smart_id183'] = 'ID# 183, Detected Uncorrectable Bad Blocks';
}
if ($app_data['has']['id184'] == 1) {
$graphs['smart_id184'] = 'ID# 184, End-to-End error / IOEDC';
}
if ($app_data['has']['id187'] == 1) {
$graphs['smart_id187'] = 'ID# 187, Reported Uncorrectable Errors';
}
if ($app_data['has']['id188'] == 1) {
$graphs['smart_id188'] = 'ID# 188, Command Timeout';
}
if ($app_data['has']['id190'] == 1 || $app_data['has']['id194'] == 1) {
$graphs['smart_maxtemp'] = 'Max Temp(C), Airflow Temperature or Device';
}
if ($app_data['has']['id190'] == 1) {
$graphs['smart_id190'] = 'ID# 190, Airflow Temperature (C)';
}
if ($app_data['has']['id194'] == 1) {
$graphs['smart_id194'] = 'ID# 194, Temperature (C)';
}
if ($app_data['has']['id196'] == 1) {
$graphs['smart_id196'] = 'ID# 196, Reallocation Event Count';
}
if ($app_data['has']['id197'] == 1) {
$graphs['smart_id197'] = 'ID# 197, Current Pending Sector Count';
}
if ($app_data['has']['id198'] == 1) {
$graphs['smart_id198'] = 'ID# 198, Uncorrectable Sector Count / Offline Uncorrectable / Off-Line Scan Uncorrectable Sector Count';
}
if ($app_data['has']['id199'] == 1) {
$graphs['smart_id199'] = 'ID# 199, UltraDMA CRC Error Count';
}
if ($app_data['has']['id231'] == 1) {
$graphs['smart_id231'] = 'ID# 231, SSD Life Left';
}
if ($app_data['has']['id232'] == 1) {
$graphs['smart_id232'] = 'ID# 232, Available Reservd Space';
}
if ($app_data['has']['id233'] == 1) {
$graphs['smart_id233'] = 'ID# 233, Media Wearout Indicator';
}
}
foreach ($graphs as $key => $text) {
$graph_type = $key;
$graph_array['height'] = '100';
$graph_array['width'] = '215';
$graph_array['to'] = \LibreNMS\Config::get('time.now');
$graph_array['id'] = $app['app_id'];
$graph_array['type'] = 'application_' . $key;
$graph_array['scale_min'] = '0';
if (isset($vars['disk'])) {
$graph_array['disk'] = $vars['disk'];
}
echo '<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">' . $text . '</h3>
</div>
<div class="panel-body">
<div class="row">';
include 'includes/html/print-graphrow.inc.php';
echo '</div>';
echo '</div>';
echo '</div>';
}