2010-06-04 09:05:42 +00:00
|
|
|
<?php
|
|
|
|
$id = $device['device_id'];
|
|
|
|
$hostname = $device['hostname'];
|
|
|
|
$community = $device['community'];
|
|
|
|
$snmpver = $device['snmpver'];
|
|
|
|
$port = $device['port'];
|
|
|
|
|
2010-06-17 10:03:50 +00:00
|
|
|
$valid_freq = array();
|
|
|
|
|
2010-06-04 09:05:42 +00:00
|
|
|
echo("Frequencies : ");
|
|
|
|
|
|
|
|
## MGE UPS Frequencies
|
|
|
|
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++)
|
|
|
|
{
|
2010-06-04 14:35:03 +00:00
|
|
|
$freq_oid = ".1.3.6.1.4.1.705.1.7.2.1.3.$i";
|
2010-06-04 09:05:42 +00:00
|
|
|
$descr = "Output"; if ($numPhase > 1) $descr .= " Phase $i";
|
2010-06-10 15:44:47 +00:00
|
|
|
$current = snmp_get($device, $freq_oid, "-Oqv");
|
2010-06-04 14:35:03 +00:00
|
|
|
if (!$current)
|
|
|
|
{
|
2010-06-04 18:41:25 +00:00
|
|
|
$freq_oid .= ".0";
|
|
|
|
$current = snmp_get($device, $freq_oid, "-Oqv");
|
2010-06-04 14:35:03 +00:00
|
|
|
}
|
|
|
|
$current /= 10;
|
2010-06-04 09:05:42 +00:00
|
|
|
$type = "mge-ups";
|
|
|
|
$precision = 10;
|
|
|
|
$index = $i;
|
2010-06-18 09:32:00 +00:00
|
|
|
echo discover_freq($valid_freq, $device, $freq_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
2010-06-04 09:05:42 +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-04 14:35:03 +00:00
|
|
|
$freq_oid = ".1.3.6.1.4.1.705.1.6.2.1.3.$i";
|
2010-06-04 09:05:42 +00:00
|
|
|
$descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i";
|
2010-06-10 15:44:47 +00:00
|
|
|
$current = snmp_get($device, $freq_oid, "-Oqv");
|
2010-06-04 14:35:03 +00:00
|
|
|
if (!$current)
|
|
|
|
{
|
2010-06-04 18:41:25 +00:00
|
|
|
$freq_oid .= ".0";
|
|
|
|
$current = snmp_get($device, $freq_oid, "-Oqv");
|
2010-06-04 14:35:03 +00:00
|
|
|
}
|
|
|
|
$current /= 10;
|
2010-06-04 09:05:42 +00:00
|
|
|
$type = "mge-ups";
|
|
|
|
$precision = 10;
|
|
|
|
$index = 100+$i;
|
2010-06-18 09:32:00 +00:00
|
|
|
echo discover_freq($valid_freq, $device, $freq_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
2010-06-04 09:05:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-18 09:32:00 +00:00
|
|
|
## Riello UPS
|
|
|
|
if ($device['os'] == "netmanplus")
|
|
|
|
{
|
|
|
|
echo("NetMan Plus ");
|
|
|
|
|
|
|
|
$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++)
|
|
|
|
{
|
|
|
|
$freq_oid = "1.3.6.1.2.1.33.1.3.3.1.2.$i";
|
|
|
|
$descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i";
|
|
|
|
$current = snmp_get($device, $freq_oid, "-Oqv") / 10;
|
|
|
|
$type = "netmanplus";
|
|
|
|
$precision = 10;
|
|
|
|
$index = '3.2.0.'.$i;
|
|
|
|
echo discover_freq($valid_freq, $device, $freq_oid, $index, $type, $descr, $precision, NULL, NULL, $current);
|
|
|
|
}
|
|
|
|
|
|
|
|
$freq_oid = "1.3.6.1.2.1.33.1.4.2.0";
|
|
|
|
$descr = "Output";
|
|
|
|
$current = snmp_get($device, $freq_oid, "-Oqv") / 10;
|
|
|
|
$type = "netmanplus";
|
|
|
|
$precision = 10;
|
|
|
|
$index = '4.2.0';
|
|
|
|
echo discover_freq($valid_freq, $device, $freq_oid, $index, $type, $descr, $precision, NULL, NULL, $current);
|
|
|
|
|
|
|
|
$freq_oid = "1.3.6.1.2.1.33.1.5.1.0";
|
|
|
|
$descr = "Bypass";
|
|
|
|
$current = snmp_get($device, $freq_oid, "-Oqv") / 10;
|
|
|
|
$type = "netmanplus";
|
|
|
|
$precision = 10;
|
|
|
|
$index = '5.1.0';
|
|
|
|
echo discover_freq($valid_freq, $device, $freq_oid, $index, $type, $descr, $precision, NULL, NULL, $current);
|
|
|
|
}
|
|
|
|
|
2010-07-06 10:27:20 +00:00
|
|
|
## APC
|
|
|
|
if ($device['os'] == "apc")
|
|
|
|
{
|
|
|
|
$oids = snmp_walk($device, "1.3.6.1.4.1.318.1.1.8.5.3.2.1.4", "-OsqnU", "");
|
|
|
|
if ($debug) { echo($oids."\n"); }
|
|
|
|
if ($oids) echo("APC In ");
|
|
|
|
$precision = 1;
|
|
|
|
$type = "apc";
|
|
|
|
foreach(explode("\n", $oids) as $data)
|
|
|
|
{
|
|
|
|
$data = trim($data);
|
|
|
|
if ($data)
|
|
|
|
{
|
|
|
|
list($oid,$current) = explode(" ", $data,2);
|
|
|
|
$split_oid = explode('.',$oid);
|
|
|
|
$index = $split_oid[count($split_oid)-1];
|
|
|
|
$oid = "1.3.6.1.4.1.318.1.1.8.5.3.2.1.4." . $index;
|
|
|
|
$descr = "Input Feed " . chr(64+$index);
|
|
|
|
discover_freq($valid_freq,$device, $oid, "3.2.1.4.$index", $type, $descr, $precision, NULL, NULL, $current);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$oids = snmp_walk($device, "1.3.6.1.4.1.318.1.1.8.5.4.2.1.4", "-OsqnU", "");
|
|
|
|
if ($debug) { echo($oids."\n"); }
|
|
|
|
if ($oids) echo(" APC Out ");
|
|
|
|
$precision = 1;
|
|
|
|
$type = "apc";
|
|
|
|
foreach(explode("\n", $oids) as $data)
|
|
|
|
{
|
|
|
|
$data = trim($data);
|
|
|
|
if ($data)
|
|
|
|
{
|
|
|
|
list($oid,$current) = explode(" ", $data,2);
|
|
|
|
$split_oid = explode('.',$oid);
|
|
|
|
$index = $split_oid[count($split_oid)-3];
|
|
|
|
$oid = "1.3.6.1.4.1.318.1.1.8.5.4.2.1.4." . $index;
|
|
|
|
$descr = "Output Feed"; if (count(explode("\n", $oids)) > 1) { $descr .= " $index"; }
|
|
|
|
discover_freq($valid_freq,$device, $oid, "4.2.1.4.$index", $type, $descr, $precision, NULL, NULL, $current);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-18 09:32:00 +00:00
|
|
|
|
2010-06-04 09:05:42 +00:00
|
|
|
|
|
|
|
## Delete removed sensors
|
|
|
|
|
2010-06-17 10:03:50 +00:00
|
|
|
if($debug) { print_r($valid_freq); }
|
2010-06-04 09:05:42 +00:00
|
|
|
|
|
|
|
$sql = "SELECT * FROM frequency WHERE device_id = '".$device['device_id']."'";
|
|
|
|
if ($query = mysql_query($sql))
|
|
|
|
{
|
|
|
|
while ($test_freq = mysql_fetch_array($query))
|
|
|
|
{
|
|
|
|
$index = $test_freq['freq_index'];
|
|
|
|
$type = $test_freq['freq_type'];
|
|
|
|
if($debug) { echo("$type -> $index\n"); }
|
2010-06-17 10:03:50 +00:00
|
|
|
if(!$valid_freq[$type][$index]) {
|
2010-06-04 09:05:42 +00:00
|
|
|
echo("-");
|
|
|
|
mysql_query("DELETE FROM `frequency` WHERE freq_id = '" . $test_freq['freq_id'] . "'");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unset($fan_exists); echo("\n");
|
|
|
|
|
|
|
|
?>
|