2010-06-09 20:03:16 +00:00
|
|
|
<?php
|
|
|
|
$id = $device['device_id'];
|
|
|
|
$hostname = $device['hostname'];
|
|
|
|
$community = $device['community'];
|
|
|
|
$snmpver = $device['snmpver'];
|
|
|
|
$port = $device['port'];
|
|
|
|
|
2010-06-17 10:46:04 +00:00
|
|
|
$valid_current = array();
|
|
|
|
|
2010-06-09 20:03:16 +00:00
|
|
|
echo("Current : ");
|
|
|
|
|
2010-07-06 10:27:20 +00:00
|
|
|
## APC
|
2010-06-10 15:53:51 +00:00
|
|
|
if ($device['os'] == "apc")
|
2010-06-09 20:03:16 +00:00
|
|
|
{
|
2010-07-06 10:27:20 +00:00
|
|
|
# PDU
|
2010-06-09 20:03:16 +00:00
|
|
|
$oids = snmp_walk($device, ".1.3.6.1.4.1.318.1.1.12.2.3.1.1.2", "-OsqnU", "");
|
|
|
|
if ($debug) { echo($oids."\n"); }
|
|
|
|
$oids = trim($oids);
|
|
|
|
if ($oids) echo("APC ");
|
|
|
|
$type = "apc";
|
|
|
|
$precision = "10";
|
2010-06-10 15:53:51 +00:00
|
|
|
foreach(explode("\n", $oids) as $data)
|
2010-06-09 20:03:16 +00:00
|
|
|
{
|
|
|
|
$data = trim($data);
|
2010-06-10 15:53:51 +00:00
|
|
|
if ($data)
|
2010-06-09 20:03:16 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
$phase_oid = "1.3.6.1.4.1.318.1.1.12.2.3.1.1.4.".$index;
|
|
|
|
$limit_oid = "1.3.6.1.4.1.318.1.1.12.2.2.1.1.4.".$index;
|
|
|
|
$lowlimit_oid = "1.3.6.1.4.1.318.1.1.12.2.2.1.1.2.".$index;
|
|
|
|
$warnlimit_oid = "1.3.6.1.4.1.318.1.1.12.2.2.1.1.3.".$index;
|
|
|
|
|
|
|
|
$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!
|
2010-07-13 10:33:07 +00:00
|
|
|
if (count(explode("\n",$oids)) != 1)
|
|
|
|
{
|
|
|
|
$descr = "Phase $phase";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$descr = "Output";
|
|
|
|
}
|
2010-06-09 20:03:16 +00:00
|
|
|
|
2010-06-17 10:46:04 +00:00
|
|
|
echo discover_current($valid_current,$device, $current_oid, $index, $type, $descr, $precision, $lowlimit, $warnlimit, $limit, $current);
|
2010-06-09 20:03:16 +00:00
|
|
|
}
|
|
|
|
}
|
2010-07-06 10:27:20 +00:00
|
|
|
|
|
|
|
# ATS
|
|
|
|
$atsCurrent = snmp_get($device, "1.3.6.1.4.1.318.1.1.8.5.4.3.1.4.1.1.1", "-OsqnU", "");
|
|
|
|
if ($atsCurrent)
|
|
|
|
{
|
|
|
|
$current_oid = "1.3.6.1.4.1.318.1.1.8.5.4.3.1.4.1.1.1";
|
|
|
|
$limit_oid = "1.3.6.1.4.1.318.1.1.8.4.16.1.5.1";
|
|
|
|
$lowlimit_oid = "1.3.6.1.4.1.318.1.1.8.4.16.1.3.1";
|
|
|
|
$warnlimit_oid = "1.3.6.1.4.1.318.1.1.8.4.16.1.4.1";
|
|
|
|
$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";
|
|
|
|
|
|
|
|
echo discover_current($valid_current,$device, $current_oid, $index, $type, $descr, $precision, $lowlimit, $warnlimit, $limit, $current);
|
|
|
|
}
|
2010-06-09 20:03:16 +00:00
|
|
|
}
|
|
|
|
|
2010-06-10 15:53:51 +00:00
|
|
|
## MGE UPS
|
|
|
|
if ($device['os'] == "mgeups")
|
|
|
|
{
|
|
|
|
echo("MGE ");
|
|
|
|
$oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.7.1", "-OsqnU"));
|
|
|
|
if ($debug) { echo($oids."\n"); }
|
|
|
|
list($unused,$numPhase) = explode(' ',$oids);
|
|
|
|
for($i = 1; $i <= $numPhase;$i++)
|
|
|
|
{
|
|
|
|
$current_oid = ".1.3.6.1.4.1.705.1.7.2.1.5.$i";
|
|
|
|
$descr = "Output"; if ($numPhase > 1) $descr .= " Phase $i";
|
|
|
|
$current = snmp_get($device, $current_oid, "-Oqv");
|
|
|
|
if (!$current)
|
|
|
|
{
|
|
|
|
$current_oid .= ".0";
|
|
|
|
$current = snmp_get($device, $current_oid, "-Oqv");
|
|
|
|
}
|
|
|
|
$current /= 10;
|
|
|
|
$type = "mge-ups";
|
|
|
|
$precision = 10;
|
|
|
|
$index = $i;
|
|
|
|
$warnlimit = NULL;
|
|
|
|
$lowlimit = 0;
|
|
|
|
$limit = NULL;
|
2010-06-17 10:46:04 +00:00
|
|
|
echo discover_current($valid_current,$device, $current_oid, $index, $type, $descr, $precision, $lowlimit, $warnlimit, $limit, $current);
|
2010-06-10 15:53:51 +00:00
|
|
|
}
|
|
|
|
$oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.6.1", "-OsqnU"));
|
|
|
|
if ($debug) { echo($oids."\n"); }
|
|
|
|
list($unused,$numPhase) = explode(' ',$oids);
|
|
|
|
for($i = 1; $i <= $numPhase;$i++)
|
|
|
|
{
|
2010-06-14 10:07:35 +00:00
|
|
|
$current_oid = ".1.3.6.1.4.1.705.1.6.2.1.6.$i";
|
2010-06-10 15:53:51 +00:00
|
|
|
$descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i";
|
|
|
|
$current = snmp_get($device, $current_oid, "-Oqv");
|
|
|
|
if (!$current)
|
|
|
|
{
|
|
|
|
$current_oid .= ".0";
|
|
|
|
$current = snmp_get($device, $current_oid, "-Oqv");
|
|
|
|
}
|
|
|
|
$current /= 10;
|
|
|
|
$type = "mge-ups";
|
|
|
|
$precision = 10;
|
|
|
|
$index = 100+$i;
|
|
|
|
$warnlimit = NULL;
|
|
|
|
$lowlimit = 0;
|
|
|
|
$limit = NULL;
|
2010-06-17 10:46:04 +00:00
|
|
|
echo discover_current($valid_current,$device, $current_oid, $index, $type, $descr, $precision, $lowlimit, $warnlimit, $limit, $current);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
## Riello UPS
|
|
|
|
if ($device['os'] == "netmanplus")
|
|
|
|
{
|
|
|
|
echo("NetMan Plus ");
|
|
|
|
|
|
|
|
$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;
|
2010-07-02 19:58:13 +00:00
|
|
|
$current = snmp_get($device, $current_oid, "-O vq") / $precision;
|
|
|
|
#$current = trim(shell_exec($config['snmpget'] . " -O qv -$snmpver -c $community $hostname:$port $current_oid")) / $precision;
|
2010-06-17 10:46:04 +00:00
|
|
|
$descr = "Battery" . (count(explode("\n",$oids)) == 1 ? '' : ' ' . ($current_id+1));
|
|
|
|
$type = "netmanplus";
|
|
|
|
$index = 500+$current_id;
|
2010-06-17 10:49:42 +00:00
|
|
|
discover_current($valid_current,$device, $current_oid, $index, $type, $descr, $precision, NULL, NULL, NULL, $current);
|
2010-06-17 10:46:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$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";
|
|
|
|
$current = snmp_get($device, $current_oid, "-Oqv");
|
|
|
|
$type = "netmanplus";
|
|
|
|
$precision = 1;
|
|
|
|
$index = $i;
|
2010-06-17 10:49:42 +00:00
|
|
|
echo discover_current($valid_current,$device, $current_oid, $index, $type, $descr, $precision, NULL, NULL, NULL, $current);
|
2010-06-17 10:46:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$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";
|
|
|
|
$current = snmp_get($device, $current_oid, "-Oqv");
|
|
|
|
$type = "netmanplus";
|
|
|
|
$precision = 1;
|
|
|
|
$index = 100+$i;
|
2010-06-17 10:49:42 +00:00
|
|
|
echo discover_current($valid_current,$device, $current_oid, $index, $type, $descr, $precision, NULL, NULL, NULL, $current);
|
2010-06-17 10:46:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$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";
|
|
|
|
$current = snmp_get($device, $current_oid, "-Oqv");
|
|
|
|
$type = "netmanplus";
|
|
|
|
$precision = 1;
|
|
|
|
$index = 200+$i;
|
2010-06-17 10:49:42 +00:00
|
|
|
echo discover_current($valid_current,$device, $current_oid, $index, $type, $descr, $precision, NULL, NULL, NULL, $current);
|
2010-06-10 15:53:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-24 16:17:22 +00:00
|
|
|
|
|
|
|
if ($device['os'] == "gamatronicups") {
|
|
|
|
|
|
|
|
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");
|
|
|
|
$type = "gamatronicups";
|
|
|
|
$precision = 1;
|
|
|
|
$index = $i;
|
|
|
|
$lowlimit = 0;
|
|
|
|
$warnlimit = NULL;
|
|
|
|
$limit = NULL;
|
|
|
|
|
|
|
|
echo discover_current($valid_current,$device, $current_oid, $index, $type, $descr, $precision, $lowlimit, $warnlimit, $limit, $current);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
$type = "gamatronicups";
|
|
|
|
$precision = 1;
|
|
|
|
$index = 100+$i;
|
|
|
|
$lowlimit = 0;
|
|
|
|
$warnlimit = NULL;
|
|
|
|
$limit = NULL;
|
|
|
|
|
|
|
|
echo discover_current($valid_current,$device, $current_oid, $index, $type, $descr, $precision, $lowlimit, $warnlimit, $limit, $current);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 20:03:16 +00:00
|
|
|
## Delete removed sensors
|
|
|
|
|
2010-06-17 10:46:04 +00:00
|
|
|
if($debug) { print_r($valid_current); }
|
2010-06-09 20:03:16 +00:00
|
|
|
|
|
|
|
$sql = "SELECT * FROM current WHERE device_id = '".$device['device_id']."'";
|
|
|
|
if ($query = mysql_query($sql))
|
|
|
|
{
|
|
|
|
while ($test_current = mysql_fetch_array($query))
|
|
|
|
{
|
|
|
|
$index = $test_current['current_index'];
|
|
|
|
$type = $test_current['current_type'];
|
|
|
|
if($debug) { echo("$type -> $index\n"); }
|
2010-06-17 10:46:04 +00:00
|
|
|
if(!$valid_current[$type][$index]) {
|
2010-06-09 20:03:16 +00:00
|
|
|
echo("-");
|
|
|
|
mysql_query("DELETE FROM `current` WHERE current_id = '" . $test_current['current_id'] . "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-17 10:46:04 +00:00
|
|
|
unset($valid_current); echo("\n");
|
2010-06-09 20:03:16 +00:00
|
|
|
|
|
|
|
?>
|