more trailing spaces hunted down and shot, then shot again

git-svn-id: http://www.observium.org/svn/observer/trunk@1880 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-16 17:53:20 +00:00
parent 318a3ebf93
commit 31b2092041
21 changed files with 54 additions and 52 deletions

View File

@@ -12,35 +12,35 @@ foreach (explode("\n", $ipNetToMedia_data) as $data)
{
list($oid, $mac) = explode(" ", $data);
list($if, $first, $second, $third, $fourth) = explode(".", $oid);
list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(":", $mac);
list($m_a, $m_b, $m_c, $m_d, $m_e, $m_f) = explode(":", $mac);
$interface = mysql_fetch_array(mysql_query("SELECT * FROM ports WHERE device_id = '".$device['device_id']."' AND ifIndex = '".$if."'"));
$ip = $first .".". $second .".". $third .".". $fourth;
$m_a = zeropad($m_a);$m_b = zeropad($m_b);$m_c = zeropad($m_c);$m_d = zeropad($m_d);$m_e = zeropad($m_e);$m_f = zeropad($m_f);
$md_a = hexdec($m_a);$md_b = hexdec($m_b);$md_c = hexdec($m_c);$md_d = hexdec($m_d);$md_e = hexdec($m_e);$md_f = hexdec($m_f);
$mac = "$m_a:$m_b:$m_c:$m_d:$m_e:$m_f";
$mac = "$m_a:$m_b:$m_c:$m_d:$m_e:$m_f";
$mac_table[$if][$mac]['ip'] = $ip;
$mac_table[$if][$mac]['ciscomac'] = "$m_a$m_b.$m_c$m_d.$m_e$m_f";
$clean_mac = $m_a . $m_b . $m_c . $m_d . $m_e . $m_f;
$clean_mac = $m_a . $m_b . $m_c . $m_d . $m_e . $m_f;
$mac_table[$if][$mac]['cleanmac'] = $clean_mac;
$interface_id = $interface['interface_id'];
$mac_table[$interface_id][$clean_mac] = 1;
if (mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"),0))
if (mysql_result(mysql_query("SELECT COUNT(*) from ipv4_mac WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'"),0))
{
$sql = "UPDATE `ipv4_mac` SET `mac_address` = '$clean_mac' WHERE interface_id = '".$interface['interface_id']."' AND ipv4_address = '$ip'";
$old_mac = mysql_fetch_row(mysql_query("SELECT mac_address from ipv4_mac WHERE ipv4_address='$ip' AND interface_id = '".$interface['interface_id']."'"));
if ($clean_mac != $old_mac[0] && $clean_mac != '' && $old_mac[0] != '')
if ($clean_mac != $old_mac[0] && $clean_mac != '' && $old_mac[0] != '')
{
if ($debug) { echo("Changed mac address for $ip from $old_mac[0] to $clean_mac\n"); }
log_event("MAC change: $ip : " . mac_clean_to_readable($old_mac[0]) . " -> " . mac_clean_to_readable($clean_mac), $device, "interface", $interface['interface_id']);
}
mysql_query($sql);
echo(".");
}
else
}
else
{
echo("+");
#echo("Add MAC $mac\n");
@@ -51,16 +51,16 @@ foreach (explode("\n", $ipNetToMedia_data) as $data)
$sql = "SELECT * from ipv4_mac AS M, ports as I WHERE M.interface_id = I.interface_id and I.device_id = '".$device['device_id']."'";
$query = mysql_query($sql);
while ($entry = mysql_fetch_array($query))
while ($entry = mysql_fetch_array($query))
{
$entry_mac = $entry['mac_address'];
$entry_if = $entry['interface_id'];
if (!$mac_table[$entry_if][$entry_mac])
if (!$mac_table[$entry_if][$entry_mac])
{
mysql_query("DELETE FROM ipv4_mac WHERE interface_id = '".$entry_if."' AND mac_address = '".$entry_mac."'");
if ($debug) { echo("Removing MAC $entry_mac from interface ".$interface['ifName']); }
echo("-");
}
}
}
echo("\n");

View File

@@ -206,4 +206,4 @@ if ($config['enable_bgp'])
echo("\n");
}
?>
?>

View File

@@ -38,7 +38,7 @@ if ($device['os_group'] == "ios")
#echo(" Not Exists!");
mysql_query("INSERT INTO `mac_accounting` (interface_id, mac) VALUES ('".$interface['interface_id']."','$clean_mac')");
echo("+");
}
}
#echo("\n");
}
}

View File

@@ -49,7 +49,7 @@ if ($device['os_group'] == "ios")
{
if ($test_vlan == $dev_vlan['vlan_vlan']) { $vlan_exists = 1; }
}
if (!$vlan_exists)
{
mysql_query("DELETE FROM `vlans` WHERE `vlan_id` = '" . $dev_vlan['vlan_id'] . "'");

View File

@@ -40,6 +40,7 @@ if ($device['os'] == "ipoman")
$descr = (trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') != '' ? trim($cache['ipoman']['in'][$index]['inletConfigDesc'],'"') : "Inlet $index");
$current = $entry['inletStatusCurrent'] / $divisor;
$high_limit = $entry['inletConfigCurrentHigh'] / 10;
discover_sensor($valid_sensor, 'current', $device, $cur_oid, '1.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', NULL, NULL, NULL, $high_limit, $current);
# FIXME: iPoMan 1201 also says it has 2 inlets, at least until firmware 1.06 - wtf?
}
@@ -54,6 +55,7 @@ if ($device['os'] == "ipoman")
$descr = (trim($cache['ipoman']['out'][$index]['outletConfigDesc'],'"') != '' ? trim($cache['ipoman']['out'][$index]['outletConfigDesc'],'"') : "Output $index");
$current = $entry['outletStatusCurrent'] / $divisor;
$high_limit = $entry['outletConfigCurrentHigh'] / 10;
discover_sensor($valid_sensor, 'current', $device, $cur_oid, '2.3.1.3.'.$index, 'ipoman', $descr, $divisor, '1', NULL, NULL, NULL, $high_limit, $current);
}
}

View File

@@ -11,7 +11,7 @@
$entity_array = array();
echo(" entPhysicalEntry");
$entity_array = snmpwalk_cache_oid($device, "entPhysicalEntry", $entity_array, "ENTITY-MIB");
$entity_array = snmpwalk_cache_oid($device, "entPhysicalEntry", $entity_array, "ENTITY-MIB");
echo(" entAliasMappingIdentifier");
$entity_array = snmpwalk_cache_twopart_oid($device, "entAliasMappingIdentifier", $entity_array, "ENTITY-MIB:IF-MIB");
@@ -26,7 +26,7 @@
$entPhysicalMfgName = $entry['entPhysicalMfgName'];
$entPhysicalVendorType = $entry['entPhysicalVendorType'];
$entPhysicalParentRelPos = $entry['entPhysicalParentRelPos'];
$entPhysicalHardwareRev = $entry['entPhysicalHardwareRev'];
$entPhysicalHardwareRev = $entry['entPhysicalHardwareRev'];
$entPhysicalFirmwareRev = $entry['entPhysicalFirmwareRev'];
$entPhysicalSoftwareRev = $entry['entPhysicalSoftwareRev'];
$entPhysicalIsFRU = $entry['entPhysicalIsFRU'];
@@ -46,7 +46,7 @@
if ($entPhysicalVendorTypes[$entPhysicalVendorType] && !$entPhysicalModelName)
{
$entPhysicalModelName = $entPhysicalVendorTypes[$entPhysicalVendorType];
}
}
if ($entPhysicalDescr || $entPhysicalName)
{
@@ -60,12 +60,12 @@
$sql .= ", entPhysicalHardwareRev = '$entPhysicalHardwareRev', entPhysicalFirmwareRev = '$entPhysicalFirmwareRev', entPhysicalSoftwareRev = '$entPhysicalSoftwareRev'";
$sql .= ", entPhysicalIsFRU = '$entPhysicalIsFRU', entPhysicalAlias = '$entPhysicalAlias', entPhysicalAssetID = '$entPhysicalAssetID'";
$sql .= " WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'";
mysql_query($sql);
echo(".");
} else {
$sql = "INSERT INTO `entPhysical` ( `device_id` , `entPhysicalIndex` , `entPhysicalDescr` , `entPhysicalClass` , `entPhysicalName` , `entPhysicalModelName` , `entPhysicalSerialNum` , `entPhysicalContainedIn`, `entPhysicalMfgName`, `entPhysicalParentRelPos`, `entPhysicalVendorType`, `entPhysicalHardwareRev`,`entPhysicalFirmwareRev`,`entPhysicalSoftwareRev`,`entPhysicalIsFRU`,`entPhysicalAlias`,`entPhysicalAssetID`, `ifIndex` ) ";
$sql .= "VALUES ( '" . $device['device_id'] . "', '$entPhysicalIndex', '$entPhysicalDescr', '$entPhysicalClass', '$entPhysicalName', '$entPhysicalModelName', '$entPhysicalSerialNum', '$entPhysicalContainedIn', '$entPhysicalMfgName','$entPhysicalParentRelPos' , '$entPhysicalVendorType', '$entPhysicalHardwareRev', '$entPhysicalFirmwareRev', '$entPhysicalSoftwareRev', '$entPhysicalIsFRU', '$entPhysicalAlias', '$entPhysicalAssetID', '$ifIndex')";
$sql .= "VALUES ( '" . $device['device_id'] . "', '$entPhysicalIndex', '$entPhysicalDescr', '$entPhysicalClass', '$entPhysicalName', '$entPhysicalModelName', '$entPhysicalSerialNum', '$entPhysicalContainedIn', '$entPhysicalMfgName','$entPhysicalParentRelPos' , '$entPhysicalVendorType', '$entPhysicalHardwareRev', '$entPhysicalFirmwareRev', '$entPhysicalSoftwareRev', '$entPhysicalIsFRU', '$entPhysicalAlias', '$entPhysicalAssetID', '$ifIndex')";
mysql_query($sql);
echo("+");
}

View File

@@ -6,7 +6,7 @@ global $valid_sensor;
if ($device['os'] == "netmanplus" || $device['os'] == "deltaups")
{
echo("RFC1628 ");
$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);

View File

@@ -6,9 +6,9 @@ global $valid_sensor;
if ($device['os'] == "powerware")
{
echo("XUPS-MIB ");
# I'm not sure if there is provision for frequency of multiple phases in this MIB -TL
# XUPS-MIB::xupsInputFrequency.0 = INTEGER: 500
$freq_oid = ".1.3.6.1.4.1.534.1.3.1.0";
$descr = "Input";

View File

@@ -24,14 +24,14 @@ if ($device['os'] == 'akcp' || $device['os'] == 'minkelsrms')
$limit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.8.$index";
$warnlowlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.9.$index";
$lowlimit_oid = ".1.3.6.1.4.1.3854.1.2.2.1.17.1.10.$index";
$descr = trim(snmp_get($device, $descr_oid, "-Oqv", ""),'"');
$humidity = snmp_get($device, $oid, "-Oqv", "");
$warnlimit = snmp_get($device, $warnlimit_oid, "-Oqv", "");
$limit = snmp_get($device, $limit_oid, "-Oqv", "");
$lowlimit = snmp_get($device, $lowlimit_oid, "-Oqv", "");
$warnlowlimit = snmp_get($device, $warnlowlimit_oid, "-Oqv", "");
discover_sensor($valid_sensor, 'humidity', $device, $oid, $index, 'akcp', $descr, '1', '1', $lowlimit, $warnlowlimit, $limit, $warnlimit, $humidity);
}
}

View File

@@ -9,14 +9,14 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname'))
$ipmi['user'] = get_dev_attrib($device,'ipmi_username');
$ipmi['password'] = get_dev_attrib($device,'ipmi_password');
$results = shell_exec($config['ipmitool'] . " -H " . $ipmi['host'] . " -U " . $ipmi['user'] . " -P " . $ipmi['password'] . " sensor|sort");
$index = 0;
foreach (explode("\n",$results) as $sensor)
{
# BB +1.1V IOH | 1.089 | Volts | ok | na | 1.027 | 1.054 | 1.146 | 1.177 | na
# BB +1.1V IOH | 1.089 | Volts | ok | na | 1.027 | 1.054 | 1.146 | 1.177 | na
list($desc,$current,$unit,$state,$low_nonrecoverable,$low_limit,$low_warn,$high_warn,$high_limit,$high_nonrecoverable) = explode('|',$sensor);
$index++;
if (trim($current) != "na" && $ipmi_unit[trim($unit)])
@@ -27,7 +27,7 @@ if ($ipmi['host'] = get_dev_attrib($device,'ipmi_hostname'))
$current, 'ipmi');
}
}
echo("\n");
}

View File

@@ -12,7 +12,7 @@ foreach (explode("\n", $oids) as $data)
$addr = Net_IPv4::parseAddress("$oid/$mask");
$network = $addr->network . "/" . $addr->bitmask;
$cidr = $addr->bitmask;
if (mysql_result(mysql_query("SELECT count(*) FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0' && $oid != "0.0.0.0")
{
$i_query = "SELECT interface_id FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'";

View File

@@ -45,7 +45,7 @@ if ($device['os'] == "junose" && $config['enable_ports_junoseatmvp'])
echo("-");
mysql_query("DELETE FROM `juniAtmvp` WHERE `juniAtmVp` = '" . $test['juniAtmvp'] . "'");
}
unset($interface_id); unset($vp_id);
}

View File

@@ -22,7 +22,7 @@ while ($test_mempool = mysql_fetch_array($query))
echo("-");
mysql_query("DELETE FROM `mempools` WHERE mempool_id = '" . $test_mempool['mempool_id'] . "'");
}
unset($mempool_oid); unset($mempool_type);
}

View File

@@ -30,7 +30,7 @@ foreach (explode("\n", $ports) as $entry){
}
if (empty($ifDescr)) { $nullintf = 1; }
if ($device['os'] == "catos" && strstr($if, "vlan") ) { $nullintf = 1; }
if ($device['os'] == "catos" && strstr($if, "vlan") ) { $nullintf = 1; }
$ifDescr = fixifName($ifDescr);
if (preg_match('/serial[0-9]:/', $if)) { $nullintf = 1; }
if (isset($config['allow_ng']) && !$config['allow_ng']) {
@@ -43,11 +43,11 @@ foreach (explode("\n", $ports) as $entry){
# Add Interface
echo("+");
} else {
mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
echo(".");
}
$int_exists[] = "$ifIndex";
} else {
} else {
# Ignored Interface
if (mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) != '0') {
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
@@ -57,7 +57,7 @@ foreach (explode("\n", $ports) as $entry){
echo("X"); ## Ignored Interface
}
}
}
}
}

View File

@@ -22,7 +22,7 @@ while ($test_storage = mysql_fetch_array($query))
echo("-");
mysql_query("DELETE FROM `storage` WHERE storage_id = '" . $test_storage['storage_id'] . "'");
}
unset($storage_index); unset($storage_mib);
}

View File

@@ -23,7 +23,7 @@ Disabled needing rewrite
echo("Adva Chassis ");
if ($temperature_chassis != "0")
{
if (mysql_result(mysql_query("SELECT count(temperature_id) FROM `temperature` WHERE temperature_oid = '$oid_chassis' AND temperature_host = '$id'"),0) == '0')
if (mysql_result(mysql_query("SELECT count(temperature_id) FROM `temperature` WHERE temperature_oid = '$oid_chassis' AND temperature_host = '$id'"),0) == '0')
{
$query = "INSERT INTO temperature (`temperature_host`, `temperature_oid`, `temperature_descr`, `temperature_precision`, `temperature_limit`, `temperature_current`) values ('$id', '$oid_chassis', '$descr_chassis',1," . ($config['defaults']['temperature_limit'] ? $config['defaults']['temperature_limit'] : '60') . ", '$temperature_chassis')";
mysql_query($query);

View File

@@ -1,5 +1,5 @@
<?php
global $valid_sensor;
if (strstr($device['hardware'], "dell"))

View File

@@ -21,7 +21,7 @@ if ($device['os'] == "ipoman")
{
$current_oid = ".1.3.6.1.4.1.2468.1.4.2.1.5.1.1.2.0";
$descr = trim(str_replace("\"", "", $descr));
discover_sensor($valid_sensor, 'temperature', $device, $current_oid, "1", 'ipoman', $descr, '10', '1', $low_limit, NULL, NULL, $high_limit, $current);
}
}

View File

@@ -29,7 +29,7 @@ if ($device['os'] == "ironware")
$descr = str_replace("Active management module", "Mgmt Module", $descr);
$descr = str_replace(" ", " ", $descr);
$descr = trim($descr);
$current = $temperature / 2;
discover_sensor($valid_sensor, 'temperature', $device, $temperature_oid, $oid, 'ironware', $descr, '2', '1', NULL, NULL, NULL, NULL, $current);

View File

@@ -5,12 +5,12 @@ global $valid_sensor;
if ($device['os'] == 'ies')
{
echo("ZyXEL IES ");
$oids = array();
$oids = array();
$oids = snmpwalk_cache_multi_oid($device, "accessSwitchSysTempCurValue", $oids, "ZYXEL-AS-MIB");
$oids = snmpwalk_cache_multi_oid($device, "accessSwitchSysTempHighThresh", $oids, "ZYXEL-AS-MIB");
if (is_array($oids))
{
foreach ($oids as $index => $entry)

View File

@@ -3,18 +3,18 @@
if ($config['enable_printers'])
{
$valid_toner = array();
echo("Toner : ");
if ($device['os_group'] == 'printer')
if ($device['os_group'] == 'printer')
{
$oids = trim(snmp_walk($device, "SNMPv2-SMI::mib-2.43.12.1.1.2.1 ", "-OsqnU"));
if ($debug) { echo($oids."\n"); }
if ($oids) echo("Jetdirect ");
foreach (explode("\n", $oids) as $data)
foreach (explode("\n", $oids) as $data)
{
$data = trim($data);
if ($data)
if ($data)
{
list($oid,$kind) = explode(" ", $data);
$split_oid = explode('.',$oid);
@@ -38,10 +38,10 @@ if ($config['enable_printers'])
}
}
}
## Delete removed toners
## Delete removed toners
if ($debug) { echo("\n Checking ... \n"); print_r($valid_toner); }
$sql = "SELECT * FROM toner WHERE device_id = '".$device['device_id']."'";
if ($query = mysql_query($sql))
{
@@ -55,8 +55,8 @@ if ($config['enable_printers'])
}
}
}
unset($valid_toner); echo("\n");
} # if ($config['enable_printers'])
?>