From e7c8b775833834f187d3107e4fa63b19d9bdb8a8 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Wed, 20 Apr 2011 09:59:48 +0000 Subject: [PATCH] Power discovery/polling enabled for IPMI, CISCO-ENTITY-SENSORS-MIB and ENTIY-SENSORS-MIB git-svn-id: http://www.observium.org/svn/observer/trunk@2104 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/graphs/sensor/power.inc.php | 30 +++++++ html/pages/device/health.inc.php | 5 ++ html/pages/device/health/power.inc.php | 9 ++ html/pages/health.inc.php | 3 +- html/pages/health/power.inc.php | 90 +++++++++++++++++++ .../discovery/cisco-entity-sensor.inc.php | 2 +- includes/discovery/entity-sensor.inc.php | 4 +- includes/discovery/functions.inc.php | 8 +- includes/polling/functions.inc.php | 14 +-- includes/static-config.php | 2 +- 10 files changed, 156 insertions(+), 11 deletions(-) create mode 100644 html/includes/graphs/sensor/power.inc.php create mode 100644 html/pages/device/health/power.inc.php create mode 100644 html/pages/health/power.inc.php diff --git a/html/includes/graphs/sensor/power.inc.php b/html/includes/graphs/sensor/power.inc.php new file mode 100644 index 000000000..e7e356f2b --- /dev/null +++ b/html/includes/graphs/sensor/power.inc.php @@ -0,0 +1,30 @@ + diff --git a/html/pages/device/health.inc.php b/html/pages/device/health.inc.php index 9eede00b8..2307ae162 100644 --- a/html/pages/device/health.inc.php +++ b/html/pages/device/health.inc.php @@ -12,6 +12,9 @@ $volts = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_cla $current = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='current' AND device_id = '" . $device['device_id'] . "'"), 0); $freqs = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='frequency' AND device_id = '" . $device['device_id'] . "'"), 0); +$power = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='power' AND device_id = '" . $device['device_id'] . "'"), 0); + + $datas[] = 'overview'; if ($processor) { $datas[] = 'processor'; } if ($mempools) { $datas[] = 'mempool'; } @@ -23,6 +26,7 @@ if ($fans) { $datas[] = 'fanspeed'; } if ($volts) { $datas[] = 'voltage'; } if ($freqs) { $datas[] = 'frequency'; } if ($current) { $datas[] = 'current'; } +if ($power) { $datas[] = 'power'; } $type_text['overview'] = "Overview"; $type_text['temperature'] = "Temperature"; @@ -35,6 +39,7 @@ $type_text['voltage'] = "Voltage"; $type_text['fanspeed'] = "Fanspeed"; $type_text['frequency'] = "Frequency"; $type_text['current'] = "Current"; +$type_text['power'] = "Power"; print_optionbar_start(); diff --git a/html/pages/device/health/power.inc.php b/html/pages/device/health/power.inc.php new file mode 100644 index 000000000..ab246055e --- /dev/null +++ b/html/pages/device/health/power.inc.php @@ -0,0 +1,9 @@ + diff --git a/html/pages/health.inc.php b/html/pages/health.inc.php index 2495acb73..c146e4703 100644 --- a/html/pages/health.inc.php +++ b/html/pages/health.inc.php @@ -1,6 +1,6 @@ = '5') +{ + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D WHERE S.sensor_class='power' AND S.device_id = D.device_id ORDER BY D.hostname, S.sensor_descr"; +} else { + $sql = "SELECT * FROM `sensors` AS S, `devices` AS D, devices_perms as P WHERE S.sensor_class='power' AND S.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, S.sensor_descr"; +} + +$query = mysql_query($sql); + +echo(''); + +echo(' + + + + + + + + '); + +$row = 1; + +while ($sensor = mysql_fetch_assoc($query)) +{ + if (is_integer($row/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } + + $weekly_sensor = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=500&height=150"; + $sensor_popup = "', LEFT);\" onmouseout=\"return nd();\"> + " . $sensor['sensor_descr'] . ""; + + if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = 'alert'; } else { $alert = ""; } + + $sensor_day = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=300&height=100"; + $sensor_week = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=300&height=100"; + $sensor_month = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=300&height=100"; + $sensor_year = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=300&height=100"; + + $sensor_minigraph = "".$sensor['hostname']." - ".mres($sensor['sensor_descr']); + $sensor_minigraph .= "
', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >"; + + echo(" + + + + + + + + \n"); + + if ($_GET['optb'] == "graphs") + { + echo(""); + } # endif graphs + + $row++; +} + +echo("
DeviceSensorCurrentRange limitNotes
" . generate_device_link($sensor) . "$sensor_popup$sensor_minigraph$alert" . $sensor['sensor_current'] . $unit . "" . $sensor['sensor_limit_low'] . $unit . " - " . $sensor['sensor_limit'] . $unit . "" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "
"); + + $daily_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=211&height=100"; + $daily_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=400&height=150"; + + $weekly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=211&height=100"; + $weekly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$week&to=$now&width=400&height=150"; + + $monthly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=211&height=100"; + $monthly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$month&to=$now&width=400&height=150"; + + $yearly_graph = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=211&height=100"; + $yearly_url = "graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$year&to=$now&width=400&height=150"; + + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("', LEFT);\" onmouseout=\"return nd();\"> + "); + echo("
"); + +?> diff --git a/includes/discovery/cisco-entity-sensor.inc.php b/includes/discovery/cisco-entity-sensor.inc.php index fcecc7a2c..a686c28ab 100644 --- a/includes/discovery/cisco-entity-sensor.inc.php +++ b/includes/discovery/cisco-entity-sensor.inc.php @@ -49,7 +49,7 @@ if ($device['os'] == "ios" || $device['os_group'] == "ios") $entitysensor['percentRH'] = "humidity"; $entitysensor['rpm'] = "fanspeed"; $entitysensor['celsius'] = "temperature"; - $entitysensor['watts'] = "watts"; + $entitysensor['watts'] = "power"; if (is_array($oids)) { diff --git a/includes/discovery/entity-sensor.inc.php b/includes/discovery/entity-sensor.inc.php index b07666ec7..9e5921ba4 100644 --- a/includes/discovery/entity-sensor.inc.php +++ b/includes/discovery/entity-sensor.inc.php @@ -28,7 +28,7 @@ $oids = snmpwalk_cache_multi_oid($device, "entPhySensorValue", $oids, "ENTITY-SE $entitysensor['voltsDC'] = "voltage"; $entitysensor['voltsAC'] = "voltage"; $entitysensor['amperes'] = "current"; -$entitysensor['watt'] = "power"; +$entitysensor['watts'] = "power"; $entitysensor['hertz'] = "freq"; $entitysensor['percentRH'] = "humidity"; $entitysensor['rpm'] = "fanspeed"; @@ -90,4 +90,4 @@ if (is_array($oids)) echo("\n"); -?> \ No newline at end of file +?> diff --git a/includes/discovery/functions.inc.php b/includes/discovery/functions.inc.php index 069929779..45c67edf0 100644 --- a/includes/discovery/functions.inc.php +++ b/includes/discovery/functions.inc.php @@ -101,6 +101,9 @@ function sensor_low_limit($class, $current) case 'fanspeed': $limit = $current * 0.80; break; + case 'power': + $limit = NULL; + break; } return $limit; } @@ -130,6 +133,9 @@ function sensor_limit($class, $current) case 'fanspeed': $limit = $current * 1.30; break; + case 'power': + $limit = $current * 1.50; + break; } return $limit; } @@ -322,4 +328,4 @@ function discover_toner(&$valid, $device, $oid, $index, $type, $descr, $capacity $valid[$type][$index] = 1; } -?> \ No newline at end of file +?> diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index f1f42ddaa..a708b140d 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -20,12 +20,16 @@ function poll_sensor($device, $class, $unit) if (!is_file($rrd_file)) { + rrdtool_create($rrd_file,"--step 300 \ - DS:sensor:GAUGE:600:-273:20000 \ - RRA:AVERAGE:0.5:1:1200 \ - RRA:MIN:0.5:12:2400 \ - RRA:MAX:0.5:12:2400 \ - RRA:AVERAGE:0.5:12:2400"); + DS:sensor:GAUGE:600:-20000:20000 \ + RRA:AVERAGE:0.5:1:1200 \ + RRA:AVERAGE:0.5:12:2400 \ + RRA:AVERAGE:0.5:288:750 \ + RRA:MAX:0.5:12:2400 \ + RRA:MAX:0.5:288:750 \ + RRA:MIN:0.5:12:2400 \ + RRA:MIN:0.5:288:750"); } echo("$sensor_value $unit\n"); diff --git a/includes/static-config.php b/includes/static-config.php index bd6470bd5..7c9effe0a 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -920,7 +920,7 @@ $config['year'] = time() - (365 * 24 * 60 * 60); $ipmi_unit['Volts'] = 'voltage'; $ipmi_unit['degrees C'] = 'temperature'; $ipmi_unit['RPM'] = 'fanspeed'; -$ipmi_unit['Watts'] = ''; +$ipmi_unit['Watts'] = 'power'; $ipmi_unit['discrete'] = ''; ## INCLUDE THE VMWARE DEFINITION FILE.