remove battery status from areca; code cleanup; insert into eventlog when device is XDP-discovered

git-svn-id: http://www.observium.org/svn/observer/trunk@2601 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-09-28 14:30:24 +00:00
parent f4def07b2d
commit 649e8586e1
3 changed files with 24 additions and 11 deletions

View File

@@ -25,6 +25,11 @@ if ($device['os'] == "ironware")
if (!$remote_device_id)
{
$remote_device_id = discover_new_device($fdp['snFdpCacheDeviceId']);
if ($remote_device_id)
{
$int = ifNameDescr($interface);
log_event("Device autodiscovered through FDP on " . $device['hostname'] . " (port " . $int['label'] . ")", $remote_device_id, 'interface', $int['interface_id']);
}
}
if ($remote_device_id)
@@ -54,11 +59,15 @@ if ($cdp_array)
$cdp = $cdp_if_array[$entry_key];
$remote_device_id = @mysql_result(mysql_query("SELECT `device_id` FROM `devices` WHERE `sysName` = '".$cdp['cdpCacheDeviceId']."' OR `hostname`='".$cdp['cdpCacheDeviceId']."'"), 0);
if (!$remote_device_id)
if (!$remote_device_id)
{
$remote_device_id = discover_new_device($cdp['cdpCacheDeviceId']);
if ($remote_device_id)
{
$remote_device_id = discover_new_device($cdp['cdpCacheDeviceId']);
$int = ifNameDescr($interface);
log_event("Device autodiscovered through CDP on " . $device['hostname'] . " (port " . $int['label'] . ")", $remote_device_id, 'interface', $int['interface_id']);
}
}
if ($remote_device_id)
{
@@ -104,6 +113,11 @@ if ($lldp_array)
if (!$remote_device_id)
{
$remote_device_id = discover_new_device($lldp['lldpRemSysName']);
if ($remote_device_id)
{
$int = ifNameDescr($interface);
log_event("Device autodiscovered through LLDP on " . $device['hostname'] . " (port " . $int['label'] . ")", $remote_device_id, 'interface', $int['interface_id']);
}
}
if ($remote_device_id)
@@ -114,8 +128,8 @@ if ($lldp_array)
$remote_interface_id = "0";
}
if (is_numeric($interface['interface_id']) && isset($lldp['lldpRemSysName']) && isset($lldp['lldpRemPortId']))
{
if (is_numeric($interface['interface_id']) && isset($lldp['lldpRemSysName']) && isset($lldp['lldpRemPortId']))
{
discover_link($interface['interface_id'], 'lldp', $remote_interface_id, $lldp['lldpRemSysName'], $lldp['lldpRemPortId'], NULL, $lldp['lldpRemSysDesc']);
}
}

View File

@@ -137,11 +137,11 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
{
$sensor_entry = dbFetchRow("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ? AND `sensor_type` = ? AND `sensor_index` = ?", array($class, $device['device_id'], $type, $index));
if (!$high_limit)
if (!isset($high_limit))
{
if (!$sensor_entry['sensor_limit'])
{
$high_limit = sensor_limit($class, $current);
$high_limit = sensor_limit($class, $current);
} else {
$high_limit = $sensor_entry['sensor_limit'];
}
@@ -149,7 +149,6 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
if ($high_limit != $sensor_entry['sensor_limit'])
{
$update = array('sensor_limit' => ($high_limit == NULL ? NULL : $high_limit));
$updated = dbUpdate($update, 'sensors', '`sensor_id` = ?', array($sensor_entry['sensor_id']));
if ($debug) { echo("( $updated updated )\n"); }
@@ -157,11 +156,11 @@ function discover_sensor(&$valid, $class, $device, $oid, $index, $type, $descr,
log_event("Sensor High Limit Updated: ".mres($class)." ".mres($type)." ". mres($index)." ".mres($descr)." (".$high_limit.")", $device, 'sensor', $sensor_id);
}
if (!$low_limit)
if (!isset($low_limit))
{
if (!$sensor_entry['sensor_limit_low'])
{
$low_limit = sensor_low_limit($class, $current);
$low_limit = sensor_low_limit($class, $current);
} else {
$low_limit = $sensor_entry['sensor_limit_low'];
}

View File

@@ -20,7 +20,7 @@ if ($device['os'] == "areca")
$index = $split_oid[count($split_oid)-1];
$oid = "1.3.6.1.4.1.18928.1.2.2.1.8.1.3." . $index;
$current = snmp_get($device, $oid, "-Oqv", "") / $divisor;
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.
if ($descr != '"Battery Status"') # Battery Status is charge percentage, or 255 when no BBU
{
discover_sensor($valid['sensor'], 'voltage', $device, $oid, $index, $type, trim($descr,'"'), $divisor, '1', NULL, NULL, NULL, NULL, $current);
}