mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
d616a133e6
git-svn-id: http://www.observium.org/svn/observer/trunk@1169 61d68cd4-352d-0410-923a-c4978735b2b8
122 lines
3.9 KiB
PHP
122 lines
3.9 KiB
PHP
<?php
|
|
$id = $device['device_id'];
|
|
$hostname = $device['hostname'];
|
|
$community = $device['community'];
|
|
$snmpver = $device['snmpver'];
|
|
$port = $device['port'];
|
|
|
|
echo("Current : ");
|
|
|
|
## APC PDU
|
|
if ($device['os'] == "apc")
|
|
{
|
|
$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";
|
|
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;
|
|
$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!
|
|
$descr = "Phase $phase";
|
|
|
|
echo discover_current($device, $current_oid, $index, $type, $descr, $precision, $lowlimit, $warnlimit, $limit, $current);
|
|
$current_exists[$type][$index] = 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
## 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;
|
|
echo discover_current($device, $current_oid, $index, $type, $descr, $precision, $lowlimit, $warnlimit, $limit, $current);
|
|
$current_exists[$type][$index] = 1;
|
|
}
|
|
$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++)
|
|
{
|
|
$current_oid = ".1.3.6.1.4.1.705.1.6.2.1.6.$i";
|
|
$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;
|
|
echo discover_current($device, $current_oid, $index, $type, $descr, $precision, $lowlimit, $warnlimit, $limit, $current);
|
|
$current_exists[$type][$index] = 1;
|
|
}
|
|
}
|
|
|
|
|
|
## Delete removed sensors
|
|
|
|
if($debug) { print_r($current_exists); }
|
|
|
|
$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"); }
|
|
if(!$current_exists[$type][$index]) {
|
|
echo("-");
|
|
mysql_query("DELETE FROM `current` WHERE current_id = '" . $test_current['current_id'] . "'");
|
|
}
|
|
}
|
|
}
|
|
|
|
unset($current_exists); echo("\n");
|
|
|
|
?>
|