diff --git a/discover-ifs.php b/discover-ifs.php deleted file mode 100755 index 49301d2d41..0000000000 --- a/discover-ifs.php +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/php - '$if'\n"); - - if (strstr($if, $bi)) { - echo("'$bi' -> '$if' MATCH!\n"); - $nullintf = 1; - } - } - if (preg_match('/serial[0-9]:/', $if)) { $nullintf = '1'; } - if (preg_match('/ng[0-9]+$/', $if)) { $nullintf = '1'; } - if ($nullintf == 0) { - if(mysql_result(mysql_query("SELECT COUNT(*) FROM `interfaces` WHERE `device_id` = '$id' AND `ifIndex` = '$ifIndex'"), 0) == '0') { - echo "Adding port $ifName \n"; - mysql_query("INSERT INTO `interfaces` (`device_id`,`ifIndex`,`ifDescr`) VALUES ('$id','$ifIndex','$ifName')"); - } else { - # echo("Already have $ifName \n"); - } - } else { - # echo("Invalid $ifName\n"); - } - } - } -} -?> diff --git a/discover-ifs.sh b/discover-ifs.sh deleted file mode 100755 index 89c9fe9ff9..0000000000 --- a/discover-ifs.sh +++ /dev/null @@ -1,11 +0,0 @@ -./discover-ifs.php 1 & -./discover-ifs.php 2 & -./discover-ifs.php 3 & -./discover-ifs.php 4 & -./discover-ifs.php 5 & -./discover-ifs.php 6 & -./discover-ifs.php 7 & -./discover-ifs.php 8 & -./discover-ifs.php 9 & -./discover-ifs.php 0 & - diff --git a/discovery.php b/discovery.php new file mode 100755 index 0000000000..4199a823ec --- /dev/null +++ b/discovery.php @@ -0,0 +1,49 @@ +#!/usr/bin/php + diff --git a/discover-bgp_peers.php b/includes/discovery/bgp-peers.php similarity index 66% rename from discover-bgp_peers.php rename to includes/discovery/bgp-peers.php index aafe630d00..eb1ed3c290 100755 --- a/discover-bgp_peers.php +++ b/includes/discovery/bgp-peers.php @@ -1,15 +1,8 @@ -#!/usr/bin/php diff --git a/discover-vlans.php b/includes/discovery/cisco-vlans.php old mode 100644 new mode 100755 similarity index 70% rename from discover-vlans.php rename to includes/discovery/cisco-vlans.php index 3e045b25eb..fee5b8185f --- a/discover-vlans.php +++ b/includes/discovery/cisco-vlans.php @@ -1,15 +1,8 @@ -#!/usr/bin/php /dev/null`); if($vtpversion == '1' || $vtpversion == '2') { @@ -17,7 +10,7 @@ while ($device = mysql_fetch_array($device_query)) { $vtp_domain_cmd = "snmpget -Oqv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " .1.3.6.1.4.1.9.9.46.1.2.1.1.2.1"; $vtp_domain = trim(str_replace("\"", "", `$vtp_domain_cmd 2>/dev/null`)); - echo("VLAN Trunking Protocol Version $vtpversion Domain : $vtp_domain\n"); + echo("VTP v$vtpversion $vtp_domain "); $vlans_cmd = "snmpwalk -O qn -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " "; $vlans_cmd .= "1.3.6.1.4.1.9.9.46.1.3.1.1.2.1 | sed s/.1.3.6.1.4.1.9.9.46.1.3.1.1.2.1.//g | cut -f 1 -d\" \""; @@ -33,11 +26,10 @@ while ($device = mysql_fetch_array($device_query)) { $vlan_descr = trim(str_replace("\"", "", $vlan_descr)); if(mysql_result(mysql_query("SELECT COUNT(vlan_id) FROM `vlans` WHERE `device_id` = '" . $device['device_id'] . "' AND `vlan_domain` = '" . $vtp_domain . "' AND `vlan_vlan` = '" . $vlan . "'"), 0) == '0') { - echo "Adding VLAN $vlan - $vlan_descr \n"; mysql_query("INSERT INTO `vlans` (`device_id`,`vlan_domain`,`vlan_vlan`, `vlan_descr`) VALUES (" . $device['device_id'] . ",'" . $vtp_domain . "','$vlan', '$vlan_descr')"); - } + echo("+"); + } else { echo("."); } - echo("VLAN $vlan ($vlan_descr)\n"); $this_vlans[] = $vlan; @@ -49,7 +41,14 @@ while ($device = mysql_fetch_array($device_query)) { foreach($this_vlans as $test_vlan) { 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'] . "'"); echo("Deleted VLAN ". $dev_vlan['vlan_vlan'] ."\n"); } + if(!$vlan_exists) { + mysql_query("DELETE FROM `vlans` WHERE `vlan_id` = '" . $dev_vlan['vlan_id'] . "'"); + echo("-"); + #echo("Deleted VLAN ". $dev_vlan['vlan_vlan'] ."\n"); + } } } -} + + unset($this_vlans); + + echo("\n"); diff --git a/includes/discovery/interfaces.php b/includes/discovery/interfaces.php new file mode 100755 index 0000000000..5708b888a6 --- /dev/null +++ b/includes/discovery/interfaces.php @@ -0,0 +1,49 @@ + diff --git a/includes/discovery/ipaddresses.php b/includes/discovery/ipaddresses.php new file mode 100755 index 0000000000..9f4613a8c0 --- /dev/null +++ b/includes/discovery/ipaddresses.php @@ -0,0 +1,47 @@ + diff --git a/discover-storage.php b/includes/discovery/storage.php similarity index 57% rename from discover-storage.php rename to includes/discovery/storage.php index 135463ab47..7c97ab4663 100755 --- a/discover-storage.php +++ b/includes/discovery/storage.php @@ -1,44 +1,40 @@ -#!/usr/bin/php '0') { - if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '$id'"),0) == '0') { + if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '".$device['device_id']."'"),0) == '0') { $query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) "; - $query .= "values ('$id', '$hrStorageIndex', '$descr', '$size', '$units')"; + $query .= "values ('".$device['device_id']."', '$hrStorageIndex', '$descr', '$size', '$units')"; mysql_query($query); - echo("Adding $descr\n"); + echo("+"); } else { - $data = mysql_fetch_array(mysql_query("SELECT * FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '$id'")); + $data = mysql_fetch_array(mysql_query("SELECT * FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '".$device['device_id']."'")); if($data['hrStorageDescr'] != $descr || $data['hrStorageSize'] != $size || $data['hrStorageAllocationUnits'] != $units ) { $query = "UPDATE storage SET `hrStorageDescr` = '$descr', `hrStorageSize` = '$size', `hrStorageAllocationUnits` = '$units' "; - $query .= "WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '$id'"; - echo("Updating $descr\n"); + $query .= "WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '".$device['device_id']."'"; + echo("U"); mysql_query($query); - } + } else { echo("."); } } - $storage_exists[] = "$id $hrStorageIndex"; + $storage_exists[] = $device[device_id]." $hrStorageIndex"; } } -} -$sql = "SELECT * FROM storage AS S, devices AS D where S.host_id = D.device_id AND D.status = '1'"; + +$sql = "SELECT * FROM storage AS S, devices AS D where S.host_id = D.device_id AND D.device_id = '".$device['device_id']."'"; $query = mysql_query($sql); while ($store = mysql_fetch_array($query)) { @@ -53,13 +49,14 @@ while ($store = mysql_fetch_array($query)) { } if(!$exists) { - echo("Deleting " . $store['hrStorageDescr'] . " from " . $store['hostname'] . "\n"); + echo("-"); mysql_query("DELETE FROM storage WHERE storage_id = '" . $store['storage_id'] . "'"); } } +echo("\n"); ?> diff --git a/discover-temperatures.php b/includes/discovery/temperatures.php similarity index 62% rename from discover-temperatures.php rename to includes/discovery/temperatures.php index 54a1132d96..27887ca2ee 100755 --- a/discover-temperatures.php +++ b/includes/discovery/temperatures.php @@ -1,39 +1,29 @@ -#!/usr/bin/php $descr : $temp\n"); mysql_query($query); - $temp_exists[] = "$id $fulloid"; - } + echo("+"); + } else { echo("."); } $temp_exists[] = "$id $temp_oid"; } + } } } -} + ## Delete removed sensors -$sql = "SELECT * FROM temperature AS T, devices AS D WHERE T.temp_host = D.device_id AND D.status = '1'"; +$sql = "SELECT * FROM temperature AS T, devices AS D WHERE T.temp_host = D.device_id AND D.device_id = '".$device['device_id']."'"; $query = mysql_query($sql); while ($sensor = mysql_fetch_array($query)) { @@ -114,11 +101,12 @@ while ($sensor = mysql_fetch_array($query)) { $i++; } if(!$exists) { - echo("Deleting...\n"); + echo("-"); mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'"); } } +unset($temp_exists); echo("\n"); + ?> - diff --git a/ips.php b/ips.php deleted file mode 100755 index e7a4210ba3..0000000000 --- a/ips.php +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/php - diff --git a/ips.sh b/ips.sh deleted file mode 100755 index 6fbbe834ee..0000000000 --- a/ips.sh +++ /dev/null @@ -1,11 +0,0 @@ -./ips.php 1 & -./ips.php 2 & -./ips.php 3 & -./ips.php 4 & -./ips.php 5 & -./ips.php 6 & -./ips.php 7 & -./ips.php 8 & -./ips.php 9 & -./ips.php 0 & -