mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fixes
git-svn-id: http://www.observium.org/svn/observer/trunk@449 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
12
cleanup.php
12
cleanup.php
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user