some code formatting improvements from sovern

git-svn-id: http://www.observium.org/svn/observer/trunk@1300 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-07-05 19:21:36 +00:00
parent 96c74a23bb
commit c5f851a00f
4 changed files with 194 additions and 194 deletions
+9 -9
View File
@@ -3,7 +3,7 @@
if($config['enable_pseudowires'] && $device['os_group'] == "ios") {
unset( $cpw_count );
unset($cpw_exists);
unset( $cpw_exists );
echo("Cisco Pseudowires : ");
@@ -22,7 +22,7 @@ if($config['enable_pseudowires'] && $device['os_group'] == "ios") {
$if_id = @mysql_result(mysql_query("SELECT `interface_id` FROM `ports` WHERE `ifDescr` = '$interface_descr' AND `device_id` = '".$device['device_id']."'"),0);
if($cpw_remote_device && $if_id) {
$hostname = gethostbyid($cpw_remote_device);
#echo("\nOid: " . $cpwOid . " cpwVcID: " . $cpwVcID . " Remote Id: " . $cpw_remote_id . "($hostname(".$cpw_remote_device.") -> $interface_descr($if_id))");
#echo("\nOid: " . $cpwOid . " cpwVcID: " . $cpwVcID . " Remote Id: " . $cpw_remote_id . "($hostname(".$cpw_remote_device.") -> $interface_descr($if_id))");
if(mysql_result(mysql_query("SELECT count(*) FROM pseudowires WHERE `interface_id` = '$if_id'
AND `cpwVcID`='".$cpwVcID."'"),0)) {
echo(".");
@@ -31,18 +31,18 @@ if($config['enable_pseudowires'] && $device['os_group'] == "ios") {
$insert_query .= "VALUES ('$if_id','$cpw_remote_device','$cpw_remote_id','$cpwVcID', '$cpwOid')";
mysql_query($insert_query);
echo("+");
#echo($device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID\n");
#echo($device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID\n");
}
$cpw_exists[] = $device['device_id'] . " $cpwOid $cpw_remote_device $if_id $cpwVcID";
}
}
}
}
}
$sql = "SELECT * FROM pseudowires AS P, ports AS I, devices as D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id AND D.device_id = '".$device['device_id']."'";
$query = mysql_query($sql);
$sql = "SELECT * FROM pseudowires AS P, ports AS I, devices as D WHERE P.interface_id = I.interface_id AND I.device_id = D.device_id AND D.device_id = '".$device['device_id']."'";
$query = mysql_query($sql);
while ($cpw = mysql_fetch_array($query)) {
while ($cpw = mysql_fetch_array($query)) {
unset($exists);
$i = 0;
while ($i < count($cpw_exists) && !$exists) {
@@ -57,9 +57,9 @@ while ($cpw = mysql_fetch_array($query)) {
# echo($this_cpw . "\n");
mysql_query("DELETE FROM pseudowires WHERE pseudowire_id = '" . $cpw['pseudowire_id'] . "'");
}
}
}
echo("\n");
echo("\n");
}
+15 -15
View File
@@ -1,16 +1,16 @@
<?php
echo "Discovery protocols:";
$community = $device['community'];
if($device['os'] == "ironware") {
echo(" Brocade FDP: ");
$fdp_array = snmpwalk_cache_twopart_oid("snFdpCacheEntry", $device, array(), "FOUNDRY-SN-SWITCH-GROUP-MIB");
$fdp_array = $fdp_array[$device['device_id']];
if($fdp_array) {
echo(" Brocade FDP: ");
$fdp_array = snmpwalk_cache_twopart_oid("snFdpCacheEntry", $device, array(), "FOUNDRY-SN-SWITCH-GROUP-MIB");
$fdp_array = $fdp_array[$device['device_id']];
if($fdp_array) {
unset($fdp_links);
foreach( array_keys($fdp_array) as $key)
{
foreach( array_keys($fdp_array) as $key) {
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$key."'"));
$fdp_if_array = $fdp_array[$key];
foreach( array_keys($fdp_if_array) as $entry_key)
@@ -24,18 +24,17 @@ if($fdp_array) {
discover_link($interface['interface_id'], $fdp['snFdpCacheVendorId'], $remote_interface_id, $fdp['snFdpCacheDeviceId'], $fdp['snFdpCacheDevicePort'], $fdp['snFdpCachePlatform'], $fdp['snFdpCacheVersion']);
}
}
}
}
}
if($device['os_group'] == "ios") {
echo(" CISCO-CDP-MIB: ");
unset($cdp_array);
$cdp_array = snmpwalk_cache_twopart_oid("cdpCache", $device, array(), "CISCO-CDP-MIB");
$cdp_array = $cdp_array[$device['device_id']];
if($cdp_array) {
echo(" CISCO-CDP-MIB: ");
unset($cdp_array);
$cdp_array = snmpwalk_cache_twopart_oid("cdpCache", $device, array(), "CISCO-CDP-MIB");
$cdp_array = $cdp_array[$device['device_id']];
if($cdp_array) {
unset($cdp_links);
foreach( array_keys($cdp_array) as $key) {
$interface = mysql_fetch_array(mysql_query("SELECT * FROM `ports` WHERE device_id = '".$device['device_id']."' AND `ifIndex` = '".$key."'"));
@@ -52,7 +51,7 @@ if($cdp_array) {
}
}
}
}
}
}
@@ -104,6 +103,7 @@ if ($query = mysql_query($sql))
}
}
unset($link_exists); echo("\n");
unset($link_exists);
echo("\n");
?>
+18 -18
View File
@@ -2,18 +2,18 @@
# Discover ports
echo("Ports : ");
echo("Ports : ");
$ports = snmp_walk($device, "ifDescr", "-Onsq", "IF-MIB");
$ports = snmp_walk($device, "ifDescr", "-Onsq", "IF-MIB");
$ports = str_replace("\"", "", $ports);
$ports = str_replace("ifDescr.", "", $ports);
$ports = str_replace(" ", "||", $ports);
$ports = str_replace("\"", "", $ports);
$ports = str_replace("ifDescr.", "", $ports);
$ports = str_replace(" ", "||", $ports);
$interface_ignored = 0;
$interface_added = 0;
$interface_ignored = 0;
$interface_added = 0;
foreach(explode("\n", $ports) as $entry){
foreach(explode("\n", $ports) as $entry){
$entry = trim($entry);
list($ifIndex, $ifDescr) = explode("||", $entry);
@@ -40,7 +40,7 @@
if ($nullintf == 0) {
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"), 0) == '0') {
mysql_query("INSERT INTO `ports` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('".$device['device_id']."','$ifIndex','$ifDescr')");
# Add Interface
# Add Interface
echo("+");
} else {
mysql_query("UPDATE `ports` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'");
@@ -48,23 +48,23 @@
}
$int_exists[] = "$ifIndex";
} else {
# Ignored Interface
# 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'");
# Delete Interface
# Delete Interface
echo("-"); ## Deleted Interface
} else {
echo("X"); ## Ignored Interface
}
}
}
}
}
$sql = "SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = '0'";
$query = mysql_query($sql);
$sql = "SELECT * FROM `ports` WHERE `device_id` = '".$device['device_id']."' AND `deleted` = '0'";
$query = mysql_query($sql);
while ($test_if = mysql_fetch_array($query)) {
while ($test_if = mysql_fetch_array($query)) {
unset($exists);
$i = 0;
while ($i < count($int_exists) && !isset($exists)) {
@@ -76,9 +76,9 @@
echo("-");
mysql_query("UPDATE `ports` SET `deleted` = '1' WHERE interface_id = '" . $test_if['interface_id'] . "'");
}
}
}
unset($temp_exists);
echo("\n");
unset($temp_exists);
echo("\n");
?>
+5 -5
View File
@@ -1,7 +1,7 @@
<?php
if($device['os'] == "ios" || $device['os_group'] == "ios")
{
if($device['os'] == "ios" || $device['os_group'] == "ios")
{
echo("CISCO-PROCESS-MIB : ");
$processors_array = snmpwalk_cache_oid("cpmCPU", $device, $processors_array, "CISCO-PROCESS-MIB");
if($debug) { print_r($processors_array); }
@@ -44,9 +44,9 @@
discover_processor($valid_processor, $device, ".1.3.6.1.4.1.9.2.1.58.0", "0", "ios", "Processor", "1", $avgBusy5, NULL, NULL);
}
}
}
## End Cisco Processors
}
## End Cisco Processors
unset ($processors_array);
unset ($processors_array);
?>