mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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
This commit is contained in:
30
html/includes/graphs/sensor/power.inc.php
Normal file
30
html/includes/graphs/sensor/power.inc.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
$scale_min = "0";
|
||||
|
||||
include("includes/graphs/common.inc.php");
|
||||
|
||||
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/power-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
|
||||
|
||||
$rrd_options .= " -A ";
|
||||
$rrd_options .= " COMMENT:' Last Max\\n'";
|
||||
|
||||
$sensor['sensor_descr_fixed'] = substr(str_pad($sensor['sensor_descr'], 22),0,22);
|
||||
$sensor['sensor_descr_fixed'] = str_replace(':','\:',str_replace('\*','*',$sensor['sensor_descr_fixed']));
|
||||
|
||||
$rrd_options .= " DEF:sensor=$rrd_filename:sensor:AVERAGE";
|
||||
$rrd_options .= " DEF:sensor_max=$rrd_filename:sensor:MAX";
|
||||
$rrd_options .= " DEF:sensor_min=$rrd_filename:sensor:MIN";
|
||||
|
||||
$rrd_options .= " AREA:sensor_max#c5c5c5";
|
||||
$rrd_options .= " AREA:sensor_min#ffffffff";
|
||||
|
||||
#$rrd_options .= " AREA:sensor#FFFF99";
|
||||
$rrd_options .= " LINE1.5:sensor#cc0000:'" . $sensor['sensor_descr_fixed']."'";
|
||||
$rrd_options .= " GPRINT:sensor:LAST:%6.2lfW";
|
||||
$rrd_options .= " GPRINT:sensor:MAX:%6.2lfW\\\\l";
|
||||
|
||||
if (is_numeric($sensor['sensor_limit'])) $rrd_options .= " HRULE:".$sensor['sensor_limit']."#999999::dashes";
|
||||
if (is_numeric($sensor['sensor_limit_low'])) $rrd_options .= " HRULE:".$sensor['sensor_limit_low']."#999999::dashes";
|
||||
|
||||
?>
|
@@ -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();
|
||||
|
||||
|
9
html/pages/device/health/power.inc.php
Normal file
9
html/pages/device/health/power.inc.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
$class = "power";
|
||||
$unit = "W";
|
||||
$graph_type = "sensor_power";
|
||||
|
||||
include("sensors.inc.php");
|
||||
|
||||
?>
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$datas = array('processor','mempool','storage','temperature', 'humidity', 'fanspeed', 'voltage', 'frequency', 'current');
|
||||
$datas = array('processor','mempool','storage','temperature', 'humidity', 'fanspeed', 'voltage', 'frequency', 'current', 'power');
|
||||
|
||||
$type_text['overview'] = "Overview";
|
||||
$type_text['temperature'] = "Temperature";
|
||||
@@ -13,6 +13,7 @@ $type_text['voltage'] = "Voltage";
|
||||
$type_text['fanspeed'] = "Fanspeed";
|
||||
$type_text['frequency'] = "Frequency";
|
||||
$type_text['current'] = "Current";
|
||||
$type_text['power'] = "Power";
|
||||
|
||||
if (!$_GET['opta']) { $_GET['opta'] = "processor"; }
|
||||
if (!$_GET['optb']) { $_GET['optb'] = "nographs"; }
|
||||
|
90
html/pages/health/power.inc.php
Normal file
90
html/pages/health/power.inc.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
$graph_type = "sensor_power";
|
||||
$unit = "V";
|
||||
|
||||
if ($_SESSION['userlevel'] >= '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('<table cellspacing="0" cellpadding="6" width="100%">');
|
||||
|
||||
echo('<tr class=tablehead>
|
||||
<th width="280">Device</th>
|
||||
<th width="180">Sensor</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th width="100">Current</th>
|
||||
<th width="250">Range limit</th>
|
||||
<th>Notes</th>
|
||||
</tr>');
|
||||
|
||||
$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 = "<a href=\"graphs/" . $sensor['sensor_id'] . "/".$graph_type."/\" onmouseover=\"return overlib('<img src=\'$weekly_sensor\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
" . $sensor['sensor_descr'] . "</a>";
|
||||
|
||||
if ($sensor['sensor_current'] >= $sensor['sensor_limit']) { $alert = '<img src="images/16/flag_red.png" alt="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 = "<img src='graph.php?id=" . $sensor['sensor_id'] . "&type=".$graph_type."&from=$day&to=$now&width=100&height=20'";
|
||||
$sensor_minigraph .= " onmouseover=\"return overlib('<div class=list-large>".$sensor['hostname']." - ".mres($sensor['sensor_descr']);
|
||||
$sensor_minigraph .= "</div><div style=\'width: 750px\'><img src=\'$sensor_day\'><img src=\'$sensor_week\'><img src=\'$sensor_month\'><img src=\'$sensor_year\'></div>', RIGHT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\" >";
|
||||
|
||||
echo("<tr bgcolor=$row_colour>
|
||||
<td class=list-bold>" . generate_device_link($sensor) . "</td>
|
||||
<td>$sensor_popup</td>
|
||||
<td>$sensor_minigraph</td>
|
||||
<td width=100>$alert</td>
|
||||
<td style='text-align: center; font-weight: bold;'>" . $sensor['sensor_current'] . $unit . "</td>
|
||||
<td style='text-align: center'>" . $sensor['sensor_limit_low'] . $unit . " - " . $sensor['sensor_limit'] . $unit . "</td>
|
||||
<td>" . (isset($sensor['sensor_notes']) ? $sensor['sensor_notes'] : '') . "</td>
|
||||
</tr>\n");
|
||||
|
||||
if ($_GET['optb'] == "graphs")
|
||||
{
|
||||
echo("<tr bgcolor='$row_colour'><td colspan=7>");
|
||||
|
||||
$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("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$daily_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$weekly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$weekly_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$monthly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$monthly_graph' border=0></a> ");
|
||||
echo("<a onmouseover=\"return overlib('<img src=\'$yearly_url\'>', LEFT);\" onmouseout=\"return nd();\">
|
||||
<img src='$yearly_graph' border=0></a>");
|
||||
echo("</td></tr>");
|
||||
} # endif graphs
|
||||
|
||||
$row++;
|
||||
}
|
||||
|
||||
echo("</table>");
|
||||
|
||||
?>
|
@@ -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))
|
||||
{
|
||||
|
@@ -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";
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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");
|
||||
|
@@ -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.
|
||||
|
Reference in New Issue
Block a user