Merge pull request #888 from laf/issue-759

Added load and current for apc ups units
This commit is contained in:
Daniel Preussker
2015-05-03 10:39:11 +00:00
7 changed files with 71537 additions and 71437 deletions
+36 -1
View File
@@ -168,10 +168,45 @@ if ($device['os'] == "apc")
$warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", ""); # No / $precision here! Nice, APC!
$descr = "Output Feed";
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, NULL, $warnlimit, $limit, $current);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '1', '1', $lowlimit, NULL, $warnlimit, $limit, $current);
}
unset($oids);
# UPS
$oid_array = array(
array('HighPrecOid' => 'upsHighPrecOutputCurrent', 'AdvOid' => 'upsAdvOutputCurrent', 'type' => 'apc', 'index' => 0, 'descr' => 'Current Drawn', 'divisor' => 10, 'mib' => '+PowerNet-MIB'),
);
foreach ($oid_array as $item) {
$low_limit = NULL;
$low_limit_warn = NULL;
$warn_limit = NULL;
$high_limit = NULL;
$oids = snmp_get($device, $item['HighPrecOid'].'.'.$item['index'], "-OsqnU", $item['mib']);
if (empty($oids)) {
$oids = snmp_get($device, $item['AdvOid'].'.'.$item['index'], "-OsqnU", $item['mib']);
$current_oid = $item['AdvOid'];
} else {
$current_oid = $item['HighPrecOid'];
}
if (!empty($oids)) {
if ($debug) {
print_r($oids);
}
$oids = trim($oids);
if ($oids) {
echo $item['type'] . ' ' . $item['mib'] . ' UPS';
}
if (stristr($current_oid, "HighPrec")) {
$current = $oids / $item['divisor'];
} else {
$current = $oids;
$item['divisor'] = 1;
}
discover_sensor($valid['sensor'], 'current', $device, $current_oid.'.'.$item['index'], $current_oid.'.'.$item['index'], $item['type'], $item['descr'], $item['divisor'], 1, $low_limit, $low_limit_warn, $warn_limit, $high_limit, $current);
}
}
}
?>
+15
View File
@@ -0,0 +1,15 @@
<?php
echo("Load: ");
// Include all discovery modules
$include_dir = "includes/discovery/load";
include("includes/include-dir.inc.php");
if ($debug) { print_r($valid['sensor']['load']); }
check_valid_sensors($device, 'current', $valid['load']);
echo("\n");
?>
+43
View File
@@ -0,0 +1,43 @@
<?php
// APC
if ($device['os'] == "apc") {
echo "APC Load ";
# UPS
$oid_array = array(
array('HighPrecOid' => 'upsHighPrecOutputLoad', 'AdvOid' => 'upsAdvOutputLoad', 'type' => 'apc', 'index' => 0, 'descr' => 'Current Load', 'divisor' => 10, 'mib' => '+PowerNet-MIB'),
);
foreach ($oid_array as $item) {
$low_limit = NULL;
$low_limit_warn = NULL;
$warn_limit = NULL;
$high_limit = NULL;
$oids = snmp_get($device, $item['HighPrecOid'].'.'.$item['index'], "-OsqnU", $item['mib']);
if (empty($oids)) {
$oids = snmp_get($device, $item['AdvOid'].'.'.$item['index'], "-OsqnU", $item['mib']);
$current_oid = $item['AdvOid'];
} else {
$current_oid = $item['HighPrecOid'];
}
if (!empty($oids)) {
if ($debug) {
print_r($oids);
}
$oids = trim($oids);
if ($oids) {
echo $item['type'] . ' ' . $item['mib'] . ' UPS';
}
if (stristr($current_oid, "HighPrec")) {
$current = $oids / $item['divisor'];
} else {
$current = $oids;
$item['divisor'] = 1;
}
discover_sensor($valid['sensor'], 'load', $device, $current_oid.'.'.$item['index'], $current_oid.'.'.$item['index'], $item['type'], $item['descr'], $item['divisor'], 1, $low_limit, $low_limit_warn, $warn_limit, $high_limit, $current);
}
}
}
?>
+1
View File
@@ -18,5 +18,6 @@ include("includes/discovery/current.inc.php");
include("includes/discovery/power.inc.php");
include("includes/discovery/fanspeeds.inc.php");
include("includes/discovery/charge.inc.php");
include("includes/discovery/load.inc.php");
?>
+5 -1
View File
@@ -22,7 +22,11 @@ function poll_sensor($device, $class, $unit)
sleep(1); # Give the TME some time to reset
}
} else {
$sensor_value = trim(str_replace("\"", "", snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB")));
if ($sensor['sensor_type'] == 'apc') {
$sensor_value = trim(str_replace("\"", "", snmp_walk($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB:PowerNet-MIB")));
} else {
$sensor_value = trim(str_replace("\"", "", snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB")));
}
}
} else if ($sensor['poller_type'] == "agent")
{
+3 -1
View File
@@ -21,7 +21,9 @@ $supported_sensors = array('current' => 'A',
'voltage' => 'V',
'temperature' => 'C',
'dbm' => 'dBm',
'charge' => '%');
'charge' => '%',
'load' => '%'
);
foreach ($supported_sensors as $sensor_type => $sensor_unit)
{
+71434 -71434
View File
File diff suppressed because it is too large Load Diff