git-svn-id: http://www.observium.org/svn/observer/trunk@449 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-08-11 16:24:50 +00:00
parent c396d9c230
commit 3cb050d63c
2 changed files with 7 additions and 7 deletions

View File

@@ -6,19 +6,19 @@
include("config.php");
include("includes/functions.php");
$query = "SELECT *,A.id as id FROM ipaddr AS A, interfaces as I, devices as D
$query = "SELECT *,A.id as id FROM ipv4_addresses AS A, interfaces as I, devices as D
WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.status = '1'";
$data = mysql_query($query);
while($row = mysql_fetch_array($data)) {
$mask = trim(shell_exec($config['ipcalc'] . " ".$row['addr']."/".$row['cidr']." | grep Netmask: | cut -d \" \" -f 4"));
$response = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname]:$row[port] ipAdEntIfIndex.$row[addr] | cut -d " " -f 2`);
$maskcheck = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname]:$row[port] ipAdEntNetMask.$row[addr] | cut -d " " -f 2`);
$mask = trim(shell_exec($config['ipcalc'] . " ".$row['ipv4_address']."/".$row['ipv4_prefixlen']." | grep Netmask: | cut -d \" \" -f 4"));
$response = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname]:$row[port] ipAdEntIfIndex.".$row['ipv4_address']." | cut -d " " -f 2`);
$maskcheck = trim(`snmpget -v2c -Osq -c $row[community] $row[hostname]:$row[port] ipAdEntNetMask.".$row['ipv4_address']." | cut -d " " -f 2`);
if($response == $row['ifIndex'] && $mask == $maskcheck) {
} else {
mysql_query("delete from ipaddr where id = '$row[id]'");
echo("Deleted $row[addr] from $row[hostname]\n");
mysql_query("delete from ipv4_address where id = '".$row['ipv4_address_id']."'");
echo("Deleted ".$row['ipv4_address']." from $row[hostname]\n");
}
}