mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 16:04:35 +02:00
bye bye ipcalc, + cleanup of cleanup.php
git-svn-id: http://www.observium.org/svn/observer/trunk@1809 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+15
-10
@@ -5,21 +5,24 @@ include("includes/defaults.inc.php");
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
|
||||
shell_exec("rm ips.txt && touch ips.txt");
|
||||
|
||||
$handle = fopen("ips.txt", "w+");
|
||||
$handle = fopen("ips.txt", "w");
|
||||
|
||||
$query = mysql_query("SELECT * FROM `ipv4_networks`");
|
||||
while ($data = mysql_fetch_array($query)) {
|
||||
while ($data = mysql_fetch_array($query))
|
||||
{
|
||||
$cidr = $data['ipv4_network'];
|
||||
list ($network, $bits) = preg_split("@\/@", $cidr);
|
||||
if($bits != '32' && $bits != '32' && $bits > '22') {
|
||||
$broadcast = trim(shell_exec($config['ipcalc']." $cidr | grep Broadcast | cut -d\" \" -f 2"));
|
||||
list ($network, $bits) = explode("/", $cidr);
|
||||
if($bits != '32' && $bits != '32' && $bits > '22')
|
||||
{
|
||||
$addr = Net_IPv4::parseAddress($cidr);
|
||||
$broadcast = $addr->broadcast;
|
||||
$ip = ip2long($network) + '1';
|
||||
$end = ip2long($broadcast);
|
||||
while($ip < $end) {
|
||||
while($ip < $end)
|
||||
{
|
||||
$ipdotted = long2ip($ip);
|
||||
if(mysql_result(mysql_query("SELECT count(ipv4_address_id) FROM ipv4_addresses WHERE ipv4_address = '$ipdotted'"),0) == '0' && match_network($config['nets'], $ipdotted)) {
|
||||
if(mysql_result(mysql_query("SELECT count(ipv4_address_id) FROM ipv4_addresses WHERE ipv4_address = '$ipdotted'"),0) == '0' && match_network($config['nets'], $ipdotted))
|
||||
{
|
||||
fputs($handle, $ipdotted . "\n");
|
||||
}
|
||||
$ip++;
|
||||
@@ -27,6 +30,8 @@ while ($data = mysql_fetch_array($query)) {
|
||||
}
|
||||
}
|
||||
|
||||
`fping -t 100 -f ips.txt > ips-scanned.txt`;
|
||||
fclose($handle);
|
||||
|
||||
shell_exec("fping -t 100 -f ips.txt > ips-scanned.txt");
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user