From de53ae27c660c3caa79f75908dd3fa70c3677cbd Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Sat, 16 Jan 2010 23:56:33 +0000 Subject: [PATCH] more warning cleanups git-svn-id: http://www.observium.org/svn/observer/trunk@705 61d68cd4-352d-0410-923a-c4978735b2b8 --- discovery.php | 13 ++++++++++--- includes/discovery/cdp-lldp.inc.php | 8 ++++---- includes/discovery/entity-physical.inc.php | 4 ++-- includes/discovery/interfaces.php | 6 +++--- includes/discovery/storage.php | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/discovery.php b/discovery.php index 703cdb4881..f89a488b92 100755 --- a/discovery.php +++ b/discovery.php @@ -56,11 +56,18 @@ if (file_exists('.svn')) { echo("Applying database updates to from r$db_rev to r" . trim($dbu_rev) . "...\n"); shell_exec("scripts/update-sql.php database-update.sql"); - mysql_query("INSERT INTO dbSchema VALUES ($dbu_rev) ON DUPLICATE KEY UPDATE revision=$dbu_rev"); + if ($dbrev == 0) + { + mysql_query("INSERT INTO dbSchema VALUES ($dbu_rev)"); + } + else + { + mysql_query("UPDATE dbSchema set revision=$dbu_rev"); + } } } -if(isset($options['d'])) { echo("DEBUG!\n"); $debug = 1; } +if(isset($options['d'])) { echo("DEBUG!\n"); $debug = 1; } else { $debug = 0; } $devices_discovered = 0; @@ -69,7 +76,7 @@ $device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where O while ($device = mysql_fetch_array($device_query)) { echo($device['hostname'] . " ".$device['device_id']." ".$device['os']." "); - if($os_groups[$device[os]]) {$device['os_group'] = $os_groups[$device[os]]; echo "(".$device['os_group'].")";} + if($os_groups[$device['os']]) {$device['os_group'] = $os_groups[$device['os']]; echo "(".$device['os_group'].")";} echo("\n"); ## Discover OS Changes diff --git a/includes/discovery/cdp-lldp.inc.php b/includes/discovery/cdp-lldp.inc.php index 92177654e8..2ebc5e5dfa 100755 --- a/includes/discovery/cdp-lldp.inc.php +++ b/includes/discovery/cdp-lldp.inc.php @@ -5,8 +5,8 @@ $community = $device['community']; echo("CISCO-CDP-MIB: "); unset($cdp_array); -$cdp_array = snmpwalk_cache_twopart_oid("cdpCache", $device, $cdp_array, "CISCO-CDP-MIB"); -$cdp_array = $cdp_array[$device[device_id]]; +$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) { @@ -29,7 +29,7 @@ if($debug) {echo("$cdp_links");} echo("\nLLDP-MIB: "); unset($lldp_array); -$lldp_array = snmpwalk_cache_threepart_oid("lldpRemoteSystemsData", $device, $lldp_array, "LLDP-MIB"); +$lldp_array = snmpwalk_cache_threepart_oid("lldpRemoteSystemsData", $device, array(), "LLDP-MIB"); $lldp_array = $lldp_array[$device['device_id']]; if($lldp_array) { unset($lldp_links); @@ -53,7 +53,7 @@ if($lldp_array) { } if($debug) {echo("$lldp_links");} -$discovered_links = $cdp_links . $lldp_links; +$discovered_links = (isset($cdp_links) ? $cdp_links : '') . (isset($lldp_links) ? $lldp_links : ''); echo "\n"; diff --git a/includes/discovery/entity-physical.inc.php b/includes/discovery/entity-physical.inc.php index 630cfd33f0..f2fb0c4589 100755 --- a/includes/discovery/entity-physical.inc.php +++ b/includes/discovery/entity-physical.inc.php @@ -10,9 +10,9 @@ $entity_array = snmpwalk_cache_oid("entPhysicalEntry", $device, $empty, "ENTITY-MIB"); $entity_array = snmpwalk_cache_oid("entSensorValues", $device, $entity_array, "CISCO-ENTITY-SENSOR-MIB"); - if(!$entity_array[$device[device_id]]) { $entity_array[$device[device_id]] = array(); } + if(!$entity_array[$device['device_id']]) { $entity_array[$device['device_id']] = array(); } - foreach($entity_array[$device[device_id]] as $entPhysicalIndex => $entry) { + foreach($entity_array[$device['device_id']] as $entPhysicalIndex => $entry) { $entPhysicalDescr = $entry['entPhysicalDescr']; $entPhysicalContainedIn = $entry['entPhysicalContainedIn']; diff --git a/includes/discovery/interfaces.php b/includes/discovery/interfaces.php index 140536e4b7..756f8b0c8a 100755 --- a/includes/discovery/interfaces.php +++ b/includes/discovery/interfaces.php @@ -35,7 +35,7 @@ if($device['os'] == "catos" && strstr($if, "vlan") ) { $nullintf = 1; } $ifDescr = fixifName($ifDescr); if (preg_match('/serial[0-9]:/', $if)) { $nullintf = 1; } - if(!$config['allow_ng']) { + if(isset($config['allow_ng']) && !$config['allow_ng']) { if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = 1; } } if ($debug) echo("\n $if "); @@ -45,7 +45,7 @@ # Add Interface echo("+"); } else { - if($interface['deleted']) { + if(isset($interface['deleted']) && $interface['deleted']) { mysql_query("UPDATE `interfaces` SET `deleted` = '0' WHERE `device_id` = '".$device['device_id']."' AND `ifIndex` = '$ifIndex'"); echo("*"); } else { @@ -73,7 +73,7 @@ while ($test_if = mysql_fetch_array($query)) { unset($exists); $i = 0; - while ($i < count($int_exists) && !$exists) { + while ($i < count($int_exists) && !isset($exists)) { $this_if = $test_if['ifIndex']; if ($int_exists[$i] == $this_if) { $exists = 1; } $i++; diff --git a/includes/discovery/storage.php b/includes/discovery/storage.php index 8432310f64..8c27ac5c3e 100755 --- a/includes/discovery/storage.php +++ b/includes/discovery/storage.php @@ -37,7 +37,7 @@ mysql_query($query); } else { echo("."); } } - $storage_exists[] = $device[device_id]." $hrStorageIndex"; + $storage_exists[] = $device['device_id']." $hrStorageIndex"; } else { echo("X"); }; } } @@ -48,7 +48,7 @@ $query = mysql_query($sql); while ($store = mysql_fetch_array($query)) { unset($exists); $i = 0; - while ($i < count($storage_exists) && !$exists) { + while ($i < count($storage_exists) && !isset($exists)) { $thisstore = $store['host_id'] . " " . $store['hrStorageIndex']; if ($storage_exists[$i] == $thisstore) { $exists = 1; } $i++;