Fix coding style part 2

This commit is contained in:
Job Snijders
2015-07-15 11:04:22 +02:00
parent ad9590df9b
commit d8693f05ae
733 changed files with 37338 additions and 33926 deletions
+226 -183
View File
@@ -1,219 +1,262 @@
<?php
// APC
if ($device['os'] == "apc")
{
# PDU - Phase
$oids = snmp_walk($device, "rPDUStatusPhaseIndex", "-OsqnU", "PowerNet-MIB");
if (empty($oids)) {
$oids = snmp_walk($device, "rPDULoadPhaseConfigIndex", "-OsqnU", "PowerNet-MIB");
}
if ($oids)
{
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
if ($oids) echo("APC PowerNet-MIB Phase ");
$type = "apc";
$precision = "10";
foreach (explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
list($oid,$kind) = explode(" ", $data);
$split_oid = explode('.',$oid);
$index = $split_oid[count($split_oid)-1];
$current_oid = "1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.".$index; #rPDULoadStatusLoad
$phase_oid = "1.3.6.1.4.1.318.1.1.12.2.3.1.1.4.".$index; #rPDULoadStatusPhaseNumber
$limit_oid = "1.3.6.1.4.1.318.1.1.12.2.2.1.1.4.".$index; #rPDULoadPhaseConfigOverloadThreshold
$lowlimit_oid = "1.3.6.1.4.1.318.1.1.12.2.2.1.1.2.".$index; #rPDULoadPhaseConfigLowLoadThreshold
$warnlimit_oid = "1.3.6.1.4.1.318.1.1.12.2.2.1.1.3.".$index; #rPDULoadPhaseConfigNearOverloadThreshold
$phase = snmp_get($device, $phase_oid, "-Oqv", "");
$current = snmp_get($device, $current_oid, "-Oqv", "") / $precision;
$limit = snmp_get($device, $limit_oid, "-Oqv", ""); # No / $precision here! Nice, APC!
$lowlimit = snmp_get($device, $lowlimit_oid, "-Oqv", ""); # No / $precision here! Nice, APC!
$warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", ""); # No / $precision here! Nice, APC!
if (count(explode("\n",$oids)) != 1)
{
$descr = "Phase $phase";
}
else
{
$descr = "Output";
}
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, NULL, $warnlimit, $limit, $current);
}
}
}
unset($oids);
#v2 firmware- first bank is total, v3 firmware, 3rd bank is total
$oids = snmp_walk($device, "rPDULoadBankConfigIndex", "-OsqnU", "PowerNet-MIB"); # should work with firmware v2 and v3
if ($oids)
{
echo("APC PowerNet-MIB Banks ");
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
$type = "apc";
$precision = "10";
# version 2 does some stuff differently- total power is first oid in index instead of the last.
# will look something like "AOS v2.6.4 / App v2.6.5"
$baseversion = "3";
if (stristr($device['version'], 'AOS v2') == TRUE) { $baseversion = "2"; }
foreach (explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
list($oid,$kind) = explode(" ", $data);
$split_oid = explode('.',$oid);
$index = $split_oid[count($split_oid)-1];
$banknum = $index -1;
$descr = "Bank ".$banknum;
if ($baseversion == "3")
{
if ($index == "1") { $descr = "Bank Total"; }
}
if ($baseversion == "2")
{
if ($index == "1") { $descr = "Bank Total"; }
}
$current_oid = "1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.".$index; #rPDULoadStatusLoad
$bank_oid = "1.3.6.1.4.1.318.1.1.12.2.3.1.1.5.".$index; #rPDULoadStatusBankNumber
$limit_oid = "1.3.6.1.4.1.318.1.1.12.2.4.1.1.4.".$index; #rPDULoadBankConfigOverloadThreshold
$lowlimit_oid = "1.3.6.1.4.1.318.1.1.12.2.4.1.1.2.".$index; #rPDULoadBankConfigLowLoadThreshold
$warnlimit_oid = "1.3.6.1.4.1.318.1.1.12.2.4.1.1.3.".$index; #rPDULoadBankConfigNearOverloadThreshold
$bank = snmp_get($device, $bank_oid, "-Oqv", "");
$current = snmp_get($device, $current_oid, "-Oqv", "") / $precision;
$limit = snmp_get($device, $limit_oid, "-Oqv", "");
$lowlimit = snmp_get($device, $lowlimit_oid, "-Oqv", "");
$warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", "");
if ($limit != -1 && $lowlimit != -1 && $warnlimit != -1)
{
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, NULL, $warnlimit, $limit, $current);
}
}
if ($device['os'] == 'apc') {
// PDU - Phase
$oids = snmp_walk($device, 'rPDUStatusPhaseIndex', '-OsqnU', 'PowerNet-MIB');
if (empty($oids)) {
$oids = snmp_walk($device, 'rPDULoadPhaseConfigIndex', '-OsqnU', 'PowerNet-MIB');
}
unset($baseversion);
}
if ($oids) {
if ($debug) {
echo $oids."\n";
}
unset($oids);
$oids = trim($oids);
if ($oids) {
echo 'APC PowerNet-MIB Phase ';
}
#Per Outlet Power Bar
$oids = snmp_walk($device, "1.3.6.1.4.1.318.1.1.26.9.4.3.1.1", "-t 30 -OsqnU", "PowerNet-MIB");
if ($oids)
{
echo("APC PowerNet-MIB Outlets ");
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
$type = "apc";
$precision = "10";
$type = 'apc';
$precision = '10';
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid,$kind) = explode(' ', $data);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
foreach (explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
list($oid,$kind) = explode(" ", $data);
$split_oid = explode('.',$oid);
$current_oid = '1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.'.$index;
// rPDULoadStatusLoad
$phase_oid = '1.3.6.1.4.1.318.1.1.12.2.3.1.1.4.'.$index;
// rPDULoadStatusPhaseNumber
$limit_oid = '1.3.6.1.4.1.318.1.1.12.2.2.1.1.4.'.$index;
// rPDULoadPhaseConfigOverloadThreshold
$lowlimit_oid = '1.3.6.1.4.1.318.1.1.12.2.2.1.1.2.'.$index;
// rPDULoadPhaseConfigLowLoadThreshold
$warnlimit_oid = '1.3.6.1.4.1.318.1.1.12.2.2.1.1.3.'.$index;
// rPDULoadPhaseConfigNearOverloadThreshold
$phase = snmp_get($device, $phase_oid, '-Oqv', '');
$current = (snmp_get($device, $current_oid, '-Oqv', '') / $precision);
$limit = snmp_get($device, $limit_oid, '-Oqv', '');
// No / $precision here! Nice, APC!
$lowlimit = snmp_get($device, $lowlimit_oid, '-Oqv', '');
// No / $precision here! Nice, APC!
$warnlimit = snmp_get($device, $warnlimit_oid, '-Oqv', '');
// No / $precision here! Nice, APC!
if (count(explode("\n", $oids)) != 1) {
$descr = "Phase $phase";
}
else {
$descr = 'Output';
}
$index = $split_oid[count($split_oid)-1];
$voltage_oid = "1.3.6.1.4.1.318.1.1.26.6.3.1.6"; #rPDU2PhaseStatusVoltage
$current_oid = "1.3.6.1.4.1.318.1.1.26.9.4.3.1.6.".$index; #rPDU2OutletMeteredStatusCurrent
$limit_oid = "1.3.6.1.4.1.318.1.1.26.9.4.1.1.7.".$index; #rPDU2OutletMeteredConfigOverloadCurrentThreshold
$lowlimit_oid = "1.3.6.1.4.1.318.1.1.26.9.4.1.1.7.".$index; #rPDU2OutletMeteredConfigLowLoadCurrentThreshold
$warnlimit_oid = "1.3.6.1.4.1.318.1.1.26.9.4.1.1.6.".$index; #rPDU2OutletMeteredConfigNearOverloadCurrentThreshold
$name_oid = "1.3.6.1.4.1.318.1.1.26.9.4.3.1.3.".$index; #rPDU2OutletMeteredStatusName
$voltage = snmp_get($device, $voltage_oid, "-Oqv", "");
$current = snmp_get($device, $current_oid, "-Oqv", "") / $precision;
$limit = snmp_get($device, $limit_oid, "-Oqv", "") / $voltage;
$lowlimit = snmp_get($device, $lowlimit_oid, "-Oqv", "") / $voltage;
$warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", "") / $voltage;
$descr = "Outlet " . $index . " - " . snmp_get($device, $name_oid, "-Oqv", "");
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, '10', '1', $lowlimit, null, $warnlimit, $limit, $current);
}
}
}
}
unset($oids);
unset($oids);
# ATS
$oids = snmp_walk($device, "atsConfigPhaseTableIndex", "-OsqnU", "PowerNet-MIB");
if ($oids)
{
$type = "apc";
if ($debug) { print_r($oids); }
$oids = trim($oids);
if ($oids) echo("APC PowerNet-MIB ATS ");
$current_oid = "1.3.6.1.4.1.318.1.1.8.5.4.3.1.4.1.1.1"; #atsOutputCurrent
$limit_oid = "1.3.6.1.4.1.318.1.1.8.4.16.1.5.1"; #atsConfigPhaseOverLoadThreshold
$lowlimit_oid = "1.3.6.1.4.1.318.1.1.8.4.16.1.3.1"; #atsConfigPhaseLowLoadThreshold
$warnlimit_oid = "1.3.6.1.4.1.318.1.1.8.4.16.1.4.1"; #atsConfigPhaseNearOverLoadThreshold
$index = 1;
// v2 firmware- first bank is total, v3 firmware, 3rd bank is total
$oids = snmp_walk($device, 'rPDULoadBankConfigIndex', '-OsqnU', 'PowerNet-MIB');
// should work with firmware v2 and v3
if ($oids) {
echo 'APC PowerNet-MIB Banks ';
if ($debug) {
echo $oids."\n";
}
$current = snmp_get($device, $current_oid, "-Oqv", "") / $precision;
$limit = snmp_get($device, $limit_oid, "-Oqv", ""); # No / $precision here! Nice, APC!
$lowlimit = snmp_get($device, $lowlimit_oid, "-Oqv", ""); # No / $precision here! Nice, APC!
$warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", ""); # No / $precision here! Nice, APC!
$descr = "Output Feed";
$oids = trim($oids);
$type = 'apc';
$precision = '10';
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, NULL, $warnlimit, $limit, $current);
}
// version 2 does some stuff differently- total power is first oid in index instead of the last.
// will look something like "AOS v2.6.4 / App v2.6.5"
$baseversion = '3';
if (stristr($device['version'], 'AOS v2') == true) {
$baseversion = '2';
}
unset($oids);
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid,$kind) = explode(' ', $data);
$split_oid = explode('.', $oid);
# UPS
$index = $split_oid[(count($split_oid) - 1)];
$banknum = ($index - 1);
$descr = 'Bank '.$banknum;
if ($baseversion == '3') {
if ($index == '1') {
$descr = 'Bank Total';
}
}
if ($baseversion == '2') {
if ($index == '1') {
$descr = 'Bank Total';
}
}
$current_oid = '1.3.6.1.4.1.318.1.1.12.2.3.1.1.2.'.$index;
// rPDULoadStatusLoad
$bank_oid = '1.3.6.1.4.1.318.1.1.12.2.3.1.1.5.'.$index;
// rPDULoadStatusBankNumber
$limit_oid = '1.3.6.1.4.1.318.1.1.12.2.4.1.1.4.'.$index;
// rPDULoadBankConfigOverloadThreshold
$lowlimit_oid = '1.3.6.1.4.1.318.1.1.12.2.4.1.1.2.'.$index;
// rPDULoadBankConfigLowLoadThreshold
$warnlimit_oid = '1.3.6.1.4.1.318.1.1.12.2.4.1.1.3.'.$index;
// rPDULoadBankConfigNearOverloadThreshold
$bank = snmp_get($device, $bank_oid, '-Oqv', '');
$current = (snmp_get($device, $current_oid, '-Oqv', '') / $precision);
$limit = snmp_get($device, $limit_oid, '-Oqv', '');
$lowlimit = snmp_get($device, $lowlimit_oid, '-Oqv', '');
$warnlimit = snmp_get($device, $warnlimit_oid, '-Oqv', '');
if ($limit != -1 && $lowlimit != -1 && $warnlimit != -1) {
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, null, $warnlimit, $limit, $current);
}
}
}
unset($baseversion);
}
unset($oids);
// Per Outlet Power Bar
$oids = snmp_walk($device, '1.3.6.1.4.1.318.1.1.26.9.4.3.1.1', '-t 30 -OsqnU', 'PowerNet-MIB');
if ($oids) {
echo 'APC PowerNet-MIB Outlets ';
if ($debug) {
echo $oids."\n";
}
$oids = trim($oids);
$type = 'apc';
$precision = '10';
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid,$kind) = explode(' ', $data);
$split_oid = explode('.', $oid);
$index = $split_oid[(count($split_oid) - 1)];
$voltage_oid = '1.3.6.1.4.1.318.1.1.26.6.3.1.6';
// rPDU2PhaseStatusVoltage
$current_oid = '1.3.6.1.4.1.318.1.1.26.9.4.3.1.6.'.$index;
// rPDU2OutletMeteredStatusCurrent
$limit_oid = '1.3.6.1.4.1.318.1.1.26.9.4.1.1.7.'.$index;
// rPDU2OutletMeteredConfigOverloadCurrentThreshold
$lowlimit_oid = '1.3.6.1.4.1.318.1.1.26.9.4.1.1.7.'.$index;
// rPDU2OutletMeteredConfigLowLoadCurrentThreshold
$warnlimit_oid = '1.3.6.1.4.1.318.1.1.26.9.4.1.1.6.'.$index;
// rPDU2OutletMeteredConfigNearOverloadCurrentThreshold
$name_oid = '1.3.6.1.4.1.318.1.1.26.9.4.3.1.3.'.$index;
// rPDU2OutletMeteredStatusName
$voltage = snmp_get($device, $voltage_oid, '-Oqv', '');
$current = (snmp_get($device, $current_oid, '-Oqv', '') / $precision);
$limit = (snmp_get($device, $limit_oid, '-Oqv', '') / $voltage);
$lowlimit = (snmp_get($device, $lowlimit_oid, '-Oqv', '') / $voltage);
$warnlimit = (snmp_get($device, $warnlimit_oid, '-Oqv', '') / $voltage);
$descr = 'Outlet '.$index.' - '.snmp_get($device, $name_oid, '-Oqv', '');
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', $lowlimit, null, $warnlimit, $limit, $current);
}
}
}
unset($oids);
// ATS
$oids = snmp_walk($device, 'atsConfigPhaseTableIndex', '-OsqnU', 'PowerNet-MIB');
if ($oids) {
$type = 'apc';
if ($debug) {
print_r($oids);
}
$oids = trim($oids);
if ($oids) {
echo 'APC PowerNet-MIB ATS ';
}
$current_oid = '1.3.6.1.4.1.318.1.1.8.5.4.3.1.4.1.1.1';
// atsOutputCurrent
$limit_oid = '1.3.6.1.4.1.318.1.1.8.4.16.1.5.1';
// atsConfigPhaseOverLoadThreshold
$lowlimit_oid = '1.3.6.1.4.1.318.1.1.8.4.16.1.3.1';
// atsConfigPhaseLowLoadThreshold
$warnlimit_oid = '1.3.6.1.4.1.318.1.1.8.4.16.1.4.1';
// atsConfigPhaseNearOverLoadThreshold
$index = 1;
$current = (snmp_get($device, $current_oid, '-Oqv', '') / $precision);
$limit = snmp_get($device, $limit_oid, '-Oqv', '');
// No / $precision here! Nice, APC!
$lowlimit = snmp_get($device, $lowlimit_oid, '-Oqv', '');
// No / $precision here! Nice, 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);
}
unset($oids);
// UPS
$oid_array = array(
array('HighPrecOid' => 'upsHighPrecOutputCurrent', 'AdvOid' => 'upsAdvOutputCurrent', 'type' => 'apc', 'index' => 0, 'descr' => 'Current Drawn', 'divisor' => 10, 'mib' => '+PowerNet-MIB'),
);
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']);
$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']);
$oids = snmp_get($device, $item['AdvOid'].'.'.$item['index'], '-OsqnU', $item['mib']);
$current_oid = $item['AdvOid'];
} else {
}
else {
$current_oid = $item['HighPrecOid'];
}
if (!empty($oids)) {
if ($debug) {
print_r($oids);
}
$oids = trim($oids);
if ($oids) {
echo $item['type'] . ' ' . $item['mib'] . ' UPS';
echo $item['type'].' '.$item['mib'].' UPS';
}
if (stristr($current_oid, "HighPrec")) {
$current = $oids / $item['divisor'];
} else {
$current = $oids;
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);
}
}
}
@@ -1,8 +1,7 @@
<?php
if ($device['os'] == 'gamatronicups') {
for ($i = 1; $i <= 3; $i++)
{
for ($i = 1; $i <= 3; $i++) {
$current_oid = "GAMATRONIC-MIB::gamatronicLTD.5.4.1.1.3.$i";
$descr = "Input Phase $i";
$current = snmp_get($device, $current_oid, '-Oqv');
@@ -18,8 +17,7 @@ if ($device['os'] == 'gamatronicups') {
$descr, '1', '1', $lowlimit, null, null, null, $current);
}
for ($i = 1; $i <= 3; $i++)
{
for ($i = 1; $i <= 3; $i++) {
$current_oid = "GAMATRONIC-MIB::gamatronicLTD.5.5.1.1.3.$i";
$descr = "Output Phase $i";
$current = snmp_get($device, $current_oid, '-Oqv');
+2 -4
View File
@@ -26,8 +26,7 @@ if ($device['os'] == 'ipoman') {
$oids_out = snmpwalk_cache_multi_oid($device, 'outletStatusCurrent', $oids_out, 'IPOMANII-MIB');
if (is_array($oids_in)) {
foreach ($oids_in as $index => $entry)
{
foreach ($oids_in as $index => $entry) {
$cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.1.3.1.3.'.$index;
$divisor = 1000;
$descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'], '"') : "Inlet $index");
@@ -40,8 +39,7 @@ if ($device['os'] == 'ipoman') {
}
if (is_array($oids_out)) {
foreach ($oids_out as $index => $entry)
{
foreach ($oids_out as $index => $entry) {
$cur_oid = '.1.3.6.1.4.1.2468.1.4.2.1.3.2.3.1.3.'.$index;
$divisor = 1000;
$descr = (trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') != '' ? trim($cache['ipoman']['out'][$index]['outletConfigDesc'], '"') : "Output $index");
+2 -4
View File
@@ -1,8 +1,7 @@
<?php
if ($device['os'] == 'netvision') {
for ($i = 1; $i <= 3; $i++)
{
for ($i = 1; $i <= 3; $i++) {
$current_oid = "1.3.6.1.4.1.4555.1.1.1.1.3.3.1.3.$i";
$descr = "Input Phase $i";
$current = snmp_get($device, $current_oid, '-Oqv');
@@ -18,8 +17,7 @@ if ($device['os'] == 'netvision') {
$descr, '10', '1', $lowlimit, null, null, null, $current);
}
for ($i = 1; $i <= 3; $i++)
{
for ($i = 1; $i <= 3; $i++) {
$current_oid = "1.3.6.1.4.1.4555.1.1.1.1.4.4.1.3.$i";
$descr = "Output Phase $i";
$current = snmp_get($device, $current_oid, '-Oqv');
+58 -59
View File
@@ -1,79 +1,78 @@
<?php
// blindly copied from sentry3
if ($device['os'] == 'raritan') {
$divisor = '1000';
$outlet_divisor = $divisor;
$multiplier = '1';
if ($device['os'] == 'raritan')
{
$divisor = "1000";
$outlet_divisor = $divisor;
$multiplier = "1";
// Check Inlets
$inlet_oids = snmp_walk($device, 'inletLabel', '-Osqn', 'PDU2-MIB');
$inlet_oids = trim($inlet_oids);
if ($inlet_oids) {
echo 'PDU Inlet ';
}
// Check Inlets
$inlet_oids = snmp_walk($device,"inletLabel","-Osqn","PDU2-MIB");
$inlet_oids = trim($inlet_oids);
if ($inlet_oids) echo("PDU Inlet ");
foreach (explode("\n", $inlet_oids) as $inlet_data)
{
$inlet_data = trim($inlet_data);
if ($inlet_data)
{
list($inlet_oid,$inlet_descr) = explode(" ", $inlet_data,2);
$inlet_split_oid = explode('.', $inlet_oid);
$inlet_index = $inlet_split_oid[count($inlet_split_oid)-2].".".$inlet_split_oid[count($inlet_split_oid)-1];
foreach (explode("\n", $inlet_oids) as $inlet_data) {
$inlet_data = trim($inlet_data);
if ($inlet_data) {
list($inlet_oid,$inlet_descr) = explode(' ', $inlet_data, 2);
$inlet_split_oid = explode('.', $inlet_oid);
$inlet_index = $inlet_split_oid[(count($inlet_split_oid) - 2)].'.'.$inlet_split_oid[(count($inlet_split_oid) - 1)];
$inlet_oid = ".1.3.6.1.4.1.13742.6.5.2.3.1.4.$inlet_index.1";
$inlet_divisor = pow(10,snmp_get($device, "inletSensorDecimalDigits.$inlet_index.rmsCurrent", "-Ovq","PDU2-MIB"));
$inlet_current = snmp_get($device, "measurementsInletSensorValue.$inlet_index.1", "-Ovq","PDU2-MIB") / $inlet_divisor;
$inlet_oid = ".1.3.6.1.4.1.13742.6.5.2.3.1.4.$inlet_index.1";
$inlet_divisor = pow(10, snmp_get($device, "inletSensorDecimalDigits.$inlet_index.rmsCurrent", '-Ovq', 'PDU2-MIB'));
$inlet_current = (snmp_get($device, "measurementsInletSensorValue.$inlet_index.1", '-Ovq', 'PDU2-MIB') / $inlet_divisor);
if ($inlet_current >= 0) {
discover_sensor($valid['sensor'], 'current', $device, $inlet_oid, $inlet_index, 'raritan', $inlet_descr, $inlet_divisor, $multiplier, NULL, NULL, NULL, NULL, $inlet_current);
}
if ($inlet_current >= 0) {
discover_sensor($valid['sensor'], 'current', $device, $inlet_oid, $inlet_index, 'raritan', $inlet_descr, $inlet_divisor, $multiplier, null, null, null, null, $inlet_current);
}
}
}
}
/////////////////////////////////
# Check for per-outlet polling
$outlet_oids = snmp_walk($device, "outletIndex", "-Osqn", "PDU-MIB");
$outlet_oids = trim($outlet_oids);
//
// Check for per-outlet polling
$outlet_oids = snmp_walk($device, 'outletIndex', '-Osqn', 'PDU-MIB');
$outlet_oids = trim($outlet_oids);
if ($outlet_oids) echo("PDU Outlet ");
foreach (explode("\n", $outlet_oids) as $outlet_data)
{
$outlet_data = trim($outlet_data);
if ($outlet_data)
{
list($outlet_oid,$outlet_descr) = explode(" ", $outlet_data,2);
$outlet_split_oid = explode('.',$outlet_oid);
$outlet_index = $outlet_split_oid[count($outlet_split_oid)-1];
if ($outlet_oids) {
echo 'PDU Outlet ';
}
$outletsuffix = "$outlet_index";
$outlet_insert_index=$outlet_index;
foreach (explode("\n", $outlet_oids) as $outlet_data) {
$outlet_data = trim($outlet_data);
if ($outlet_data) {
list($outlet_oid,$outlet_descr) = explode(' ', $outlet_data, 2);
$outlet_split_oid = explode('.', $outlet_oid);
$outlet_index = $outlet_split_oid[(count($outlet_split_oid) - 1)];
#outletLoadValue: "A non-negative value indicates the measured load in milli Amps"
$outletsuffix = "$outlet_index";
$outlet_insert_index = $outlet_index;
// outletLoadValue: "A non-negative value indicates the measured load in milli Amps"
$outlet_oid = ".1.3.6.1.4.1.13742.4.1.2.2.1.4.$outletsuffix";
$outlet_descr = snmp_get($device,"outletLabel.$outletsuffix", "-Ovq", "PDU-MIB");
$outlet_low_warn_limit = NULL;
$outlet_low_limit = NULL;
$outlet_high_warn_limit = snmp_get($device,"outletCurrentUpperWarning.$outletsuffix", "-Ovq", "PDU-MIB") / $outlet_divisor;
$outlet_high_limit = snmp_get($device,"outletCurrentUpperCritical.$outletsuffix", "-Ovq", "PDU-MIB") / $outlet_divisor;
$outlet_current = snmp_get($device,"outletCurrent.$outletsuffix", "-Ovq", "PDU-MIB") / $outlet_divisor;
$outlet_descr = snmp_get($device, "outletLabel.$outletsuffix", '-Ovq', 'PDU-MIB');
$outlet_low_warn_limit = null;
$outlet_low_limit = null;
$outlet_high_warn_limit = (snmp_get($device, "outletCurrentUpperWarning.$outletsuffix", '-Ovq', 'PDU-MIB') / $outlet_divisor);
$outlet_high_limit = (snmp_get($device, "outletCurrentUpperCritical.$outletsuffix", '-Ovq', 'PDU-MIB') / $outlet_divisor);
$outlet_current = (snmp_get($device, "outletCurrent.$outletsuffix", '-Ovq', 'PDU-MIB') / $outlet_divisor);
if ($outlet_current >= 0) {
discover_sensor($valid['sensor'], 'current', $device, $outlet_oid, $outlet_insert_index, 'raritan', $outlet_descr, $outlet_divisor, $multiplier, $outlet_low_limit, $outlet_low_warn_limit, $outlet_high_warn_limit, $outlet_high_limit, $outlet_current);
discover_sensor($valid['sensor'], 'current', $device, $outlet_oid, $outlet_insert_index, 'raritan', $outlet_descr, $outlet_divisor, $multiplier, $outlet_low_limit, $outlet_low_warn_limit, $outlet_high_warn_limit, $outlet_high_limit, $outlet_current);
}
} // if ($outlet_data)
}
// unset($outlet_data);
// unset($outlet_oids);
// unset($outlet_oid);
// unset($outlet_descr);
// unset($outlet_low_warn_limit);
// unset($outlet_low_limit);
// unset($outlet_high_warn_limit);
// unset($outlet_high_limit);
// unset($outlet_current);
} // foreach (explode("\n", $outlet_oids) as $outlet_data)
// unset($outlet_data);
// unset($outlet_oids);
// unset($outlet_oid);
// unset($outlet_descr);
// unset($outlet_low_warn_limit);
// unset($outlet_low_limit);
// unset($outlet_high_warn_limit);
// unset($outlet_high_limit);
// unset($outlet_current);
}
}
+80 -64
View File
@@ -1,76 +1,92 @@
<?php
// RFC1628 UPS
if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modules_compat']['rfc1628'][$device['os']])
{
echo("RFC1628 ");
if (isset($config['modules_compat']['rfc1628'][$device['os']]) && $config['modules_compat']['rfc1628'][$device['os']]) {
echo 'RFC1628 ';
$oids = snmp_walk($device, "1.3.6.1.2.1.33.1.2.6", "-Osqn", "UPS-MIB");
if ($debug) { echo($oids."\n"); }
$oids = trim($oids);
foreach (explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
{
list($oid,$descr) = explode(" ", $data,2);
$split_oid = explode('.',$oid);
$current_id = $split_oid[count($split_oid)-1];
$current_oid = "1.3.6.1.2.1.33.1.2.6.$current_id";
$precision = 10;
$current = snmp_get($device, $current_oid, "-O vq") / $precision;
$descr = "Battery" . (count(explode("\n",$oids)) == 1 ? '' : ' ' . ($current_id+1));
$type = "rfc1628";
$index = 500+$current_id;
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', NULL, NULL, NULL, NULL, $current);
$oids = snmp_walk($device, '1.3.6.1.2.1.33.1.2.6', '-Osqn', 'UPS-MIB');
if ($debug) {
echo $oids."\n";
}
}
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.4.3.0", "-OsqnU"));
if ($debug) { echo($oids."\n"); }
list($unused,$numPhase) = explode(' ',$oids);
for($i = 1; $i <= $numPhase;$i++)
{
$current_oid = ".1.3.6.1.2.1.33.1.4.4.1.3.$i";
$descr = "Output"; if ($numPhase > 1) $descr .= " Phase $i";
$precision = 10;
$current = snmp_get($device, $current_oid, "-Oqv") / $precision;
$type = "rfc1628";
$index = $i;
$oids = trim($oids);
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid,$descr) = explode(' ', $data, 2);
$split_oid = explode('.', $oid);
$current_id = $split_oid[(count($split_oid) - 1)];
$current_oid = "1.3.6.1.2.1.33.1.2.6.$current_id";
$precision = 10;
$current = (snmp_get($device, $current_oid, '-O vq') / $precision);
$descr = 'Battery'.(count(explode("\n", $oids)) == 1 ? '' : ' '.($current_id + 1));
$type = 'rfc1628';
$index = (500 + $current_id);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', NULL, NULL, NULL, NULL, $current);
}
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', null, null, null, null, $current);
}
}
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.3.2.0", "-OsqnU"));
if ($debug) { echo($oids."\n"); }
list($unused,$numPhase) = explode(' ',$oids);
for($i = 1; $i <= $numPhase;$i++)
{
$current_oid = "1.3.6.1.2.1.33.1.3.3.1.4.$i";
$descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i";
$precision = 10;
$current = snmp_get($device, $current_oid, "-Oqv") / $precision;
$type = "rfc1628";
$index = 100+$i;
$oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.4.3.0', '-OsqnU'));
if ($debug) {
echo $oids."\n";
}
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', NULL, NULL, NULL, NULL, $current);
}
list($unused,$numPhase) = explode(' ', $oids);
for ($i = 1; $i <= $numPhase; $i++) {
$current_oid = ".1.3.6.1.2.1.33.1.4.4.1.3.$i";
$descr = 'Output';
if ($numPhase > 1) {
$descr .= " Phase $i";
}
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.5.2.0", "-OsqnU"));
if ($debug) { echo($oids."\n"); }
list($unused,$numPhase) = explode(' ',$oids);
for($i = 1; $i <= $numPhase;$i++)
{
$current_oid = "1.3.6.1.2.1.33.1.5.3.1.3.$i";
$descr = "Bypass"; if ($numPhase > 1) $descr .= " Phase $i";
$precision = 10;
$current = snmp_get($device, $current_oid, "-Oqv") / $precision;
$type = "rfc1628";
$index = 200+$i;
$precision = 10;
$current = (snmp_get($device, $current_oid, '-Oqv') / $precision);
$type = 'rfc1628';
$index = $i;
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', NULL, NULL, NULL, NULL, $current);
}
}
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', null, null, null, null, $current);
}
?>
$oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.3.2.0', '-OsqnU'));
if ($debug) {
echo $oids."\n";
}
list($unused,$numPhase) = explode(' ', $oids);
for ($i = 1; $i <= $numPhase; $i++) {
$current_oid = "1.3.6.1.2.1.33.1.3.3.1.4.$i";
$descr = 'Input';
if ($numPhase > 1) {
$descr .= " Phase $i";
}
$precision = 10;
$current = (snmp_get($device, $current_oid, '-Oqv') / $precision);
$type = 'rfc1628';
$index = (100 + $i);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', null, null, null, null, $current);
}
$oids = trim(snmp_walk($device, '1.3.6.1.2.1.33.1.5.2.0', '-OsqnU'));
if ($debug) {
echo $oids."\n";
}
list($unused,$numPhase) = explode(' ', $oids);
for ($i = 1; $i <= $numPhase; $i++) {
$current_oid = "1.3.6.1.2.1.33.1.5.3.1.3.$i";
$descr = 'Bypass';
if ($numPhase > 1) {
$descr .= " Phase $i";
}
$precision = 10;
$current = (snmp_get($device, $current_oid, '-Oqv') / $precision);
$type = 'rfc1628';
$index = (200 + $i);
discover_sensor($valid['sensor'], 'current', $device, $current_oid, $index, $type, $descr, '10', '1', null, null, null, null, $current);
}
}//end if
+1 -2
View File
@@ -54,8 +54,7 @@ if ($device['os'] == 'sentry3') {
echo 'ServerTech Sentry Outlet ';
}
foreach (explode("\n", $outlet_oids) as $outlet_data)
{
foreach (explode("\n", $outlet_oids) as $outlet_data) {
$outlet_data = trim($outlet_data);
if ($outlet_data) {
list($outlet_oid,$outlet_descr) = explode(' ', $outlet_data, 2);
+1 -2
View File
@@ -10,8 +10,7 @@ if ($device['os'] == 'powerware') {
}
$oids = trim($oids);
foreach (explode("\n", $oids) as $data)
{
foreach (explode("\n", $oids) as $data) {
$data = trim($data);
if ($data) {
list($oid,$descr) = explode(' ', $data, 2);