mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
various fixes, add some more netmanplus stats, convert discover_volt and discover_freq to use the by-reference array like discover_temperature
git-svn-id: http://www.observium.org/svn/observer/trunk@1193 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -5,10 +5,11 @@ $community = $device['community'];
|
||||
$snmpver = $device['snmpver'];
|
||||
$port = $device['port'];
|
||||
|
||||
$valid_freq = array();
|
||||
|
||||
echo("Frequencies : ");
|
||||
|
||||
## MGE UPS Frequencies
|
||||
|
||||
if ($device['os'] == "mgeups")
|
||||
{
|
||||
echo("MGE ");
|
||||
@@ -29,25 +30,7 @@ if ($device['os'] == "mgeups")
|
||||
$type = "mge-ups";
|
||||
$precision = 10;
|
||||
$index = $i;
|
||||
if ($current > 55 && $current < 65)
|
||||
{
|
||||
#FIXME Are these sensible values?
|
||||
$lowlimit = 58;
|
||||
$limit = 62;
|
||||
}
|
||||
else if ($current > 45 && $current < 55)
|
||||
{
|
||||
#FIXME Are these sensible values?
|
||||
$lowlimit = 48;
|
||||
$limit = 52;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lowlimit = 0;
|
||||
$limit = 0;
|
||||
}
|
||||
echo discover_freq($device, $freq_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
$freq_exists[$type][$index] = 1;
|
||||
echo discover_freq($valid_freq,$device, $freq_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
}
|
||||
$oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.6.1", "-OsqnU"));
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
@@ -66,32 +49,14 @@ if ($device['os'] == "mgeups")
|
||||
$type = "mge-ups";
|
||||
$precision = 10;
|
||||
$index = 100+$i;
|
||||
if ($current > 55 && $current < 65)
|
||||
{
|
||||
#FIXME Are these sensible values?
|
||||
$lowlimit = 58;
|
||||
$limit = 62;
|
||||
}
|
||||
else if ($current > 45 && $current < 55)
|
||||
{
|
||||
#FIXME Are these sensible values?
|
||||
$lowlimit = 48;
|
||||
$limit = 52;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lowlimit = 0;
|
||||
$limit = 0;
|
||||
}
|
||||
echo discover_freq($device, $freq_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
$freq_exists[$type][$index] = 1;
|
||||
echo discover_freq($valid_freq,$device, $freq_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## Delete removed sensors
|
||||
|
||||
if($debug) { print_r($freq_exists); }
|
||||
if($debug) { print_r($valid_freq); }
|
||||
|
||||
$sql = "SELECT * FROM frequency WHERE device_id = '".$device['device_id']."'";
|
||||
if ($query = mysql_query($sql))
|
||||
@@ -101,7 +66,7 @@ if ($query = mysql_query($sql))
|
||||
$index = $test_freq['freq_index'];
|
||||
$type = $test_freq['freq_type'];
|
||||
if($debug) { echo("$type -> $index\n"); }
|
||||
if(!$freq_exists[$type][$index]) {
|
||||
if(!$valid_freq[$type][$index]) {
|
||||
echo("-");
|
||||
mysql_query("DELETE FROM `frequency` WHERE freq_id = '" . $test_freq['freq_id'] . "'");
|
||||
}
|
||||
|
@@ -204,7 +204,7 @@ function discover_fan($device, $oid, $index, $type, $descr, $precision = 1, $low
|
||||
return $return;
|
||||
}
|
||||
|
||||
function discover_volt($device, $oid, $index, $type, $descr, $precision = 1, $low_limit = NULL, $high_limit = NULL, $current = NULL)
|
||||
function discover_volt(&$valid_volt, $device, $oid, $index, $type, $descr, $precision = 1, $low_limit = NULL, $high_limit = NULL, $current = NULL)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
@@ -250,10 +250,11 @@ function discover_volt($device, $oid, $index, $type, $descr, $precision = 1, $lo
|
||||
}
|
||||
}
|
||||
|
||||
$valid_volt[$type][$index] = 1;
|
||||
return $return;
|
||||
}
|
||||
|
||||
function discover_freq($device, $oid, $index, $type, $descr, $precision = 1, $low_limit = NULL, $high_limit = NULL, $current = NULL)
|
||||
function discover_freq(&$valid_freq, $device, $oid, $index, $type, $descr, $precision = 1, $low_limit = NULL, $high_limit = NULL, $current = NULL)
|
||||
{
|
||||
global $config, $debug;
|
||||
|
||||
@@ -265,6 +266,10 @@ function discover_freq($device, $oid, $index, $type, $descr, $precision = 1, $lo
|
||||
|
||||
if (mysql_result(mysql_query("SELECT count(freq_id) FROM `frequency` WHERE device_id = '".$device['device_id']."' AND freq_type = '$type' AND `freq_index` = '$index'"),0) == '0')
|
||||
{
|
||||
|
||||
if(!$high_limit && isset($current)) { $high_limit = round($current * 1.05, 0); }
|
||||
if(!$low_limit && isset($current)) { $low_limit = round($current * 0.95, 0); }
|
||||
|
||||
$query = "INSERT INTO frequency (`device_id`, `freq_oid`, `freq_index`, `freq_type`, `freq_descr`, `freq_precision`, `freq_limit`, `freq_limit_low`, `freq_current`) ";
|
||||
$query .= " VALUES ('".$device['device_id']."', '$oid', '$index', '$type', '$descr', '$precision', '$high_limit', '$low_limit', '$current')";
|
||||
mysql_query($query);
|
||||
@@ -286,6 +291,7 @@ function discover_freq($device, $oid, $index, $type, $descr, $precision = 1, $lo
|
||||
}
|
||||
}
|
||||
|
||||
$valid_freq[$type][$index] = 1;
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
@@ -214,7 +214,7 @@ switch ($device['os'])
|
||||
$temp_id = $split_oid[count($split_oid)-1];
|
||||
$temp_oid = "1.3.6.1.2.1.33.1.2.7.$temp_id";
|
||||
$temp = trim(shell_exec($config['snmpget'] . " -O qv -$snmpver -c $community $hostname:$port $temp_oid"));
|
||||
$descr = "Battery " . (count(explode("\n",$oids)) == 1 ? '' : ($temp_id+1));
|
||||
$descr = "Battery" . (count(explode("\n",$oids)) == 1 ? '' : ' ' . ($temp_id+1));
|
||||
discover_temperature($valid_temp, $device, $temp_oid, $temp_id, "netmanplus", $descr, 1, NULL, NULL, $temp);
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,8 @@ $community = $device['community'];
|
||||
$snmpver = $device['snmpver'];
|
||||
$port = $device['port'];
|
||||
|
||||
$valid_volt = array();
|
||||
|
||||
echo("Voltages : ");
|
||||
|
||||
## LMSensors Voltages
|
||||
@@ -25,8 +27,7 @@ if ($device['os'] == "linux")
|
||||
$index = $split_oid[count($split_oid)-1];
|
||||
$oid = "1.3.6.1.4.1.2021.13.16.4.1.3." . $index;
|
||||
$current = snmp_get($device, $oid, "-Oqv", "LM-SENSORS-MIB") / $precision;
|
||||
discover_volt($device, $oid, $index, $type, $descr, $precision, NULL, NULL, $current);
|
||||
$volt_exists[$type][$index] = 1;
|
||||
discover_volt($valid_volt,$device, $oid, $index, $type, $descr, $precision, NULL, NULL, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,8 +52,7 @@ if ($device['os'] == "areca")
|
||||
$current = snmp_get($device, $oid, "-Oqv", "") / $precision;
|
||||
if ($descr != '"Battery Status"' || $current != 0.255) # FIXME not sure if this is supposed to be a voltage, but without BBU it's 225, then ignore.
|
||||
{
|
||||
discover_volt($device, $oid, $index, $type, trim($descr,'"'), $precision, NULL, NULL, $current);
|
||||
$volt_exists[$type][$index] = 1;
|
||||
discover_volt($valid_volt,$device, $oid, $index, $type, trim($descr,'"'), $precision, NULL, NULL, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,8 +92,7 @@ if ($device['os'] == "linux")
|
||||
|
||||
if ($monitor == 'true')
|
||||
{
|
||||
echo discover_volt($device, $volt_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
$volt_exists[$type][$index] = 1;
|
||||
echo discover_volt($valid_volt,$device, $volt_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,19 +120,7 @@ if ($device['os'] == "mgeups")
|
||||
$type = "mge-ups";
|
||||
$precision = 10;
|
||||
$index = $i;
|
||||
if ($current > 200 && $current < 250)
|
||||
{
|
||||
#FIXME Are these sensible values?
|
||||
$lowlimit = 210;
|
||||
$limit = 250;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lowlimit = 0;
|
||||
$limit = 0;
|
||||
}
|
||||
echo discover_volt($device, $volt_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
$volt_exists[$type][$index] = 1;
|
||||
echo discover_volt($valid_volt,$device, $volt_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
}
|
||||
$oids = trim(snmp_walk($device, "1.3.6.1.4.1.705.1.6.1", "-OsqnU"));
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
@@ -152,19 +139,7 @@ if ($device['os'] == "mgeups")
|
||||
$type = "mge-ups";
|
||||
$precision = 10;
|
||||
$index = 100+$i;
|
||||
if ($current > 200 && $current < 250)
|
||||
{
|
||||
#FIXME Are these sensible values?
|
||||
$lowlimit = 210;
|
||||
$limit = 250;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lowlimit = 0;
|
||||
$limit = 0;
|
||||
}
|
||||
echo discover_volt($device, $volt_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
$volt_exists[$type][$index] = 1;
|
||||
echo discover_volt($valid_volt,$device, $volt_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,7 +151,6 @@ if ($device['os'] == "netmanplus")
|
||||
$oids = snmp_walk($device, "1.3.6.1.2.1.33.1.2.5", "-Osqn", "UPS-MIB");
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
$oids = trim($oids);
|
||||
if ($oids) echo("NetMan Plus Battery Voltage ");
|
||||
foreach(explode("\n", $oids) as $data)
|
||||
{
|
||||
$data = trim($data);
|
||||
@@ -188,41 +162,59 @@ if ($device['os'] == "netmanplus")
|
||||
$volt_oid = "1.3.6.1.2.1.33.1.2.5.$volt_id";
|
||||
$precision = 10;
|
||||
$volt = trim(shell_exec($config['snmpget'] . " -O qv -$snmpver -c $community $hostname:$port $volt_oid")) / $precision;
|
||||
$descr = "Battery " . (count(explode("\n",$oids)) == 1 ? '' : ($volt_id+1));
|
||||
$descr = "Battery" . (count(explode("\n",$oids)) == 1 ? '' : ' ' . ($volt_id+1));
|
||||
$type = "netmanplus";
|
||||
discover_volt($device, $volt_oid, $volt_id, $type, $descr, $precision, NULL, NULL, $volt);
|
||||
$volt_exists[$type][$volt_id] = 1;
|
||||
discover_volt($valid_volt,$device, $volt_oid, $volt_id, $type, $descr, $precision, NULL, NULL, $volt);
|
||||
}
|
||||
}
|
||||
|
||||
$oids = snmp_walk($device, "1.3.6.1.2.1.33.1.3.3.1.3", "-Osqn", "UPS-MIB");
|
||||
$oids = trim(snmp_walk($device, "1.3.6.1.2.1.33.1.4.3.0", "-OsqnU"));
|
||||
if ($debug) { echo($oids."\n"); }
|
||||
$oids = trim($oids);
|
||||
if ($oids) echo("NetMan Plus Input Voltage ");
|
||||
foreach(explode("\n", $oids) as $data)
|
||||
list($unused,$numPhase) = explode(' ',$oids);
|
||||
for($i = 1; $i <= $numPhase;$i++)
|
||||
{
|
||||
$data = trim($data);
|
||||
if ($data)
|
||||
{
|
||||
list($oid,$descr) = explode(" ", $data,2);
|
||||
$split_oid = explode('.',$oid);
|
||||
$volt_id = $split_oid[count($split_oid)-1];
|
||||
$volt_oid = "1.3.6.1.2.1.33.1.3.3.1.3.$volt_id";
|
||||
$precision = 1;
|
||||
$volt = trim(shell_exec($config['snmpget'] . " -O qv -$snmpver -c $community $hostname:$port $volt_oid")) / $precision;
|
||||
$descr = "Input phase " . ($volt_id);
|
||||
$volt_oid = ".1.3.6.1.2.1.33.1.4.4.1.2.$i";
|
||||
$descr = "Output"; if ($numPhase > 1) $descr .= " Phase $i";
|
||||
$current = snmp_get($device, $volt_oid, "-Oqv");
|
||||
$type = "netmanplus";
|
||||
discover_volt($device, $volt_oid, $volt_id, $type, $descr, $precision, NULL, NULL, $volt);
|
||||
$volt_exists[$type][$volt_id] = 1;
|
||||
}
|
||||
$precision = 1;
|
||||
$index = $i;
|
||||
echo discover_volt($valid_volt,$device, $volt_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $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++)
|
||||
{
|
||||
$volt_oid = "1.3.6.1.2.1.33.1.3.3.1.3.$i";
|
||||
$descr = "Input"; if ($numPhase > 1) $descr .= " Phase $i";
|
||||
$current = snmp_get($device, $volt_oid, "-Oqv");
|
||||
$type = "netmanplus";
|
||||
$precision = 1;
|
||||
$index = 100+$i;
|
||||
echo discover_volt($valid_volt,$device, $volt_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $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++)
|
||||
{
|
||||
$volt_oid = "1.3.6.1.2.1.33.1.5.3.1.2.$i";
|
||||
$descr = "Bypass"; if ($numPhase > 1) $descr .= " Phase $i";
|
||||
$current = snmp_get($device, $volt_oid, "-Oqv");
|
||||
$type = "netmanplus";
|
||||
$precision = 1;
|
||||
$index = 200+$i;
|
||||
echo discover_volt($valid_volt,$device, $volt_oid, $index, $type, $descr, $precision, $lowlimit, $limit, $current);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
## Delete removed sensors
|
||||
|
||||
if($debug) { print_r($volt_exists); }
|
||||
if($debug) { print_r($valid_volt); }
|
||||
|
||||
$sql = "SELECT * FROM voltage WHERE device_id = '".$device['device_id']."'";
|
||||
if ($query = mysql_query($sql))
|
||||
@@ -232,13 +224,13 @@ if ($query = mysql_query($sql))
|
||||
$index = $test_volt['volt_index'];
|
||||
$type = $test_volt['volt_type'];
|
||||
if($debug) { echo("$type -> $index\n"); }
|
||||
if(!$volt_exists[$type][$index]) {
|
||||
if(!$valid_volt[$type][$index]) {
|
||||
echo("-");
|
||||
mysql_query("DELETE FROM `voltage` WHERE volt_id = '" . $test_volt['volt_id'] . "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unset($volt_exists); echo("\n");
|
||||
unset($valid_volt); echo("\n");
|
||||
|
||||
?>
|
||||
|
@@ -7,7 +7,7 @@ while($dbcurrent = mysql_fetch_array($current_data)) {
|
||||
echo("Checking current " . $dbcurrent['current_descr'] . "... ");
|
||||
|
||||
$current_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $dbcurrent['current_oid'] . "|grep -v \"No Such Instance\"";
|
||||
$current = trim(str_replace("\"", "", shell_exec($current_cmd)));
|
||||
$current = trim(shell_exec($current_cmd));
|
||||
|
||||
if ($dbcurrent['current_precision'])
|
||||
{
|
||||
|
@@ -69,7 +69,7 @@ $os_text['dell-laser'] = "Dell Laser Printer";
|
||||
$os_text['adva'] = "Adva";
|
||||
$os_text['allied'] = "AlliedWare";
|
||||
$os_text['mgeups'] = "MGE UPS";
|
||||
$os_text['apc'] = "APC";
|
||||
$os_text['apc'] = "APC Management Module";
|
||||
$os_text['areca'] = "Areca RAID Subsystem";
|
||||
$os_text['netmanplus'] = "NetMan Plus";
|
||||
$os_text['akcp'] = "AKCP SensorProbe";
|
||||
|
Reference in New Issue
Block a user