Merge pull request #4016 from crcro/ipmi_rewrites

ipmi sensors rewrite based on known hardware id
This commit is contained in:
Neil Lathwood
2016-08-11 23:37:40 +01:00
committed by GitHub
6 changed files with 71 additions and 12 deletions

View File

@@ -1346,3 +1346,16 @@ function get_ports_from_type($given_types) {
$ports = dbFetchRows("SELECT * FROM `ports` as I, `devices` AS D WHERE $type_where AND I.device_id = D.device_id ORDER BY I.ifAlias", $type_param); $ports = dbFetchRows("SELECT * FROM `ports` as I, `devices` AS D WHERE $type_where AND I.device_id = D.device_id ORDER BY I.ifAlias", $type_param);
return $ports; return $ports;
} }
function ipmiSensorName($hardwareId, $sensorIpmi, $rewriteArray)
{
if(count($rewriteArray[$hardwareId]) > 0) {
if($rewriteArray[$hardwareId][$sensorIpmi] != "") {
return $rewriteArray[$hardwareId][$sensorIpmi];
} else {
return $sensorIpmi;
}
} else {
return $sensorIpmi;
}
}

View File

@@ -14,8 +14,13 @@ $rrd_options .= " DEF:sensor_min=$rrd_filename:sensor:MIN";
$rrd_options .= ' AREA:sensor_max#c5c5c5'; $rrd_options .= ' AREA:sensor_max#c5c5c5';
$rrd_options .= ' AREA:sensor_min#ffffffff'; $rrd_options .= ' AREA:sensor_min#ffffffff';
// $rrd_options .= " AREA:sensor#FFFF99"; if($sensor['poller_type'] == "ipmi")
$rrd_options .= " LINE1.5:sensor#cc0000:'".rrdtool_escape($sensor['sensor_descr'], 22)."'"; {
$rrd_options .= " LINE1.5:sensor#cc0000:'".rrdtool_escape(ipmiSensorName($device['hardware'], $sensor['sensor_descr'], $ipmiSensorsNames), 21)."'";
} else {
$rrd_options .= " LINE1.5:sensor#cc0000:'".rrdtool_escape($sensor['sensor_descr'], 21)."'";
}
$rrd_options .= ' GPRINT:sensor:LAST:%6.2lfW'; $rrd_options .= ' GPRINT:sensor:LAST:%6.2lfW';
$rrd_options .= ' GPRINT:sensor:MAX:%6.2lfW\\\\l'; $rrd_options .= ' GPRINT:sensor:MAX:%6.2lfW\\\\l';

View File

@@ -1,5 +1,4 @@
<?php <?php
$scale_min = '0'; $scale_min = '0';
$scale_max = '60'; $scale_max = '60';
@@ -16,7 +15,13 @@ $rrd_options .= ' CDEF:sensor_diff=sensor_max,sensor_min,-';
$rrd_options .= ' AREA:sensor_min'; $rrd_options .= ' AREA:sensor_min';
$rrd_options .= ' AREA:sensor_diff#c5c5c5::STACK'; $rrd_options .= ' AREA:sensor_diff#c5c5c5::STACK';
$rrd_options .= " LINE1.5:sensor#cc0000:'".rrdtool_escape($sensor['sensor_descr'], 21)."'"; if($sensor['poller_type'] == "ipmi")
{
$rrd_options .= " LINE1.5:sensor#cc0000:'".rrdtool_escape(ipmiSensorName($device['hardware'], $sensor['sensor_descr'], $ipmiSensorsNames), 21)."'";
} else {
$rrd_options .= " LINE1.5:sensor#cc0000:'".rrdtool_escape($sensor['sensor_descr'], 21)."'";
}
$rrd_options .= ' GPRINT:sensor_min:MIN:%4.1lfC'; $rrd_options .= ' GPRINT:sensor_min:MIN:%4.1lfC';
$rrd_options .= ' GPRINT:sensor:LAST:%4.1lfC'; $rrd_options .= ' GPRINT:sensor:LAST:%4.1lfC';
$rrd_options .= ' GPRINT:sensor_max:MAX:%4.1lfC\\l'; $rrd_options .= ' GPRINT:sensor_max:MAX:%4.1lfC\\l';
@@ -28,3 +33,4 @@ if (is_numeric($sensor['sensor_limit'])) {
if (is_numeric($sensor['sensor_limit_low'])) { if (is_numeric($sensor['sensor_limit_low'])) {
$rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes'; $rrd_options .= ' HRULE:'.$sensor['sensor_limit_low'].'#999999::dashes';
} }

View File

@@ -1,7 +1,5 @@
<?php <?php
//echo '<table cellspacing=0 cellpadding=5 width=100%>';
$row = 1; $row = 1;
foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_descr`', array($class, $device['device_id'])) as $sensor) { foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? ORDER BY `sensor_descr`', array($class, $device['device_id'])) as $sensor) {
@@ -11,7 +9,14 @@ foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `devi
else { else {
$row_colour = $list_colour_b; $row_colour = $list_colour_b;
} }
$sensor_descr = $sensor['sensor_descr'];
if($sensor['poller_type'] == "ipmi")
{
$sensor_descr = ipmiSensorName($device['hardware'], $sensor['sensor_descr'], $ipmiSensorsNames);
} else {
$sensor_descr = $sensor['sensor_descr'];
}
$sensor_current = format_si($sensor['sensor_current']).$unit; $sensor_current = format_si($sensor['sensor_current']).$unit;
$sensor_limit = format_si($sensor['sensor_limit']).$unit; $sensor_limit = format_si($sensor['sensor_limit']).$unit;
$sensor_limit_low = format_si($sensor['sensor_limit_low']).$unit; $sensor_limit_low = format_si($sensor['sensor_limit_low']).$unit;
@@ -30,5 +35,3 @@ foreach (dbFetchRows('SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `devi
$row++; $row++;
} }
//echo '</table>';

View File

@@ -1,6 +1,4 @@
<?php <?php
if ($sensor_class == 'state') { if ($sensor_class == 'state') {
$sensors = dbFetchRows('SELECT * FROM `sensors` LEFT JOIN `sensors_to_state_indexes` ON sensors_to_state_indexes.sensor_id = sensors.sensor_id LEFT JOIN state_indexes ON state_indexes.state_index_id = sensors_to_state_indexes.state_index_id WHERE `sensor_class` = ? AND device_id = ? ORDER BY `sensor_type`, `sensor_index`+0, `sensor_oid`', array($sensor_class, $device['device_id'])); $sensors = dbFetchRows('SELECT * FROM `sensors` LEFT JOIN `sensors_to_state_indexes` ON sensors_to_state_indexes.sensor_id = sensors.sensor_id LEFT JOIN state_indexes ON state_indexes.state_index_id = sensors_to_state_indexes.state_index_id WHERE `sensor_class` = ? AND device_id = ? ORDER BY `sensor_type`, `sensor_index`+0, `sensor_oid`', array($sensor_class, $device['device_id']));
} }
@@ -46,6 +44,13 @@ if (count($sensors)) {
unset($link_array['height'], $link_array['width'], $link_array['legend']); unset($link_array['height'], $link_array['width'], $link_array['legend']);
$link = generate_url($link_array); $link = generate_url($link_array);
if($sensor['poller_type'] == "ipmi")
{
$sensor['sensor_descr'] = truncate(ipmiSensorName($device['hardware'], $sensor['sensor_descr'], $ipmiSensorsNames), 48, '');
} else {
$sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, '');
}
$overlib_content = '<div style="width: 580px;"><h2>'.$device['hostname'].' - '.$sensor['sensor_descr'].'</h1>'; $overlib_content = '<div style="width: 580px;"><h2>'.$device['hostname'].' - '.$sensor['sensor_descr'].'</h1>';
foreach (array('day', 'week', 'month', 'year') as $period) { foreach (array('day', 'week', 'month', 'year') as $period) {
$graph_array['from'] = $config['time'][$period]; $graph_array['from'] = $config['time'][$period];
@@ -61,7 +66,6 @@ if (count($sensors)) {
$graph_array['from'] = $config['time']['day']; $graph_array['from'] = $config['time']['day'];
$sensor_minigraph = generate_lazy_graph_tag($graph_array); $sensor_minigraph = generate_lazy_graph_tag($graph_array);
$sensor['sensor_descr'] = truncate($sensor['sensor_descr'], 48, '');
if (!empty($state_translation['0']['state_descr'])) { if (!empty($state_translation['0']['state_descr'])) {
$state_style=""; $state_style="";
switch ($state_translation['0']['state_generic_value']) { switch ($state_translation['0']['state_generic_value']) {

View File

@@ -1331,3 +1331,31 @@ function rewrite_brocade_fc_switches($descr) {
} }
return $hardware; return $hardware;
} }
$ipmiSensorsNames = array(
"HP ProLiant BL460c G6" => array(
"Temp 1" => "Ambient zone",
"Temp 2" => "CPU 1",
"Temp 3" => "CPU 2",
"Temp 4" => "Memory zone",
"Temp 5" => "Memory zone",
"Temp 6" => "Memory zone",
"Temp 7" => "System zone",
"Temp 8" => "System zone",
"Temp 9" => "System zone",
"Temp 10" => "Storage zone",
"Power Meter" => "Power usage",
),
"HP ProLiant BL460c G1" => array(
"Temp 1" => "System zone",
"Temp 2" => "CPU 1 zone",
"Temp 3" => "CPU 1",
"Temp 4" => "CPU 1",
"Temp 5" => "CPU 2 zone",
"Temp 6" => "CPU 2",
"Temp 7" => "CPU 2",
"Temp 8" => "Memory zone",
"Temp 9" => "Ambient zone",
"Power Meter" => "Power usage",
),
);