enhance smart to show power_on_hours also (#10261)

This commit is contained in:
SourceDoctor
2019-06-07 06:39:23 +02:00
committed by Tony Murray
parent e6ad2b5bb8
commit 349e102b73
6 changed files with 73 additions and 1 deletions

View File

@@ -13,10 +13,17 @@ if (isset($vars['disk'])) {
$disks=get_disks_with_smart($device, $app['app_id']);
}
$smart_enhancements = array('id9');
$int=0;
while (isset($disks[$int])) {
$disk=$disks[$int];
if (in_array($rrdVar, $smart_enhancements)) {
$rrd_filename = rrd_name($device['hostname'], array('app', $name.'_'.$rrdVar, $app_id, $disk));
} else {
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id, $disk));
}
if (rrdtool_check_rrd_exists($rrd_filename)) {
$rrd_list[]=array(

View File

@@ -0,0 +1,9 @@
<?php
$unit_text = 'Power On Hours';
$unitlen = 20;
$bigdescrlen = 15;
$smalldescrlen = 15;
$rrdVar='id9';
require 'smart-common.inc.php';

View File

@@ -0,0 +1,24 @@
<?php
$name = 'smart';
$app_id = $app['app_id'];
$unit_text = '';
$unitlen = 20;
$bigdescrlen = 15;
$smalldescrlen = 15;
$colours = 'mega';
$dostack = 0;
$printtotal = 0;
$addarea = 1;
$transparency = 15;
$rrd_filename = rrd_name($device['hostname'], array('app', $name, $app_id, $vars['disk']));
if (rrdtool_check_rrd_exists($rrd_filename)) {
$rrd_list[]=array(
'filename' => $rrd_filename,
'descr' => 'Power On Hours',
'ds' => 'id9',
);
}
require 'includes/html/graphs/generic_multi_line_exact_numbers.inc.php';

View File

@@ -215,6 +215,7 @@ $graphs['bind'] = array(
);
$graphs['smart'] = array(
'id5',
'id9',
'id10',
'id173',
'id183',

View File

@@ -37,10 +37,12 @@ if (isset($vars['disk'])) {
'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',
);
} else {
$graphs = array(
'smart_id5'=>'ID# 5, Reallocated Sectors Count',
'smart_id9'=>'ID# 9, Power On Hours',
'smart_id10'=>'ID# 10, Spin Retry Count',
'smart_id173'=>'ID# 173, SSD Wear Leveller Worst Case Erase Count',
'smart_id177'=>'ID# 177, SSD Wear Leveling Count',

View File

@@ -131,4 +131,33 @@ while (isset($lines[$int])) {
$int++;
}
# smart enhancement id9
$rrd_name = array('app', $name, $app_id);
$rrd_def = RrdDefinition::make()
->addDataset('id9', 'GAUGE', 0);
$int=0;
$metrics = array();
while (isset($lines[$int])) {
list($disk, , , , , , , , , , , , , , , , , , , , , , , , , $id9)=explode(",", $lines[$int]);
if (is_int($id9)) {
$id=null;
}
$rrd_name = array('app', $name.'_id9', $app_id, $disk);
$fields = array(
'id9'=>$id9
);
$metrics[$disk] = $fields;
$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name);
data_update($device, 'app', $tags, $fields);
$int++;
}
update_application($app, $output, $metrics);