mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	git-svn-id: http://www.observium.org/svn/observer/trunk@2 61d68cd4-352d-0410-923a-c4978735b2b8
		
			
				
	
	
		
			31 lines
		
	
	
		
			819 B
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			31 lines
		
	
	
		
			819 B
		
	
	
	
		
			PHP
		
	
	
		
			Executable File
		
	
	
	
	
#!/usr/bin/php
 | 
						|
<?
 | 
						|
include("config.php");
 | 
						|
include("includes/functions.php");
 | 
						|
 | 
						|
`rm ips.txt && touch ips.txt`;
 | 
						|
 | 
						|
$handle = fopen("ips.txt", "w+");
 | 
						|
 | 
						|
$query = mysql_query("SELECT * FROM `networks`");
 | 
						|
while ($data = mysql_fetch_array($query)) {
 | 
						|
  $cidr = $data['cidr'];
 | 
						|
  list ($network, $bits) = split("/", $cidr); 
 | 
						|
  if($bits != '32' && $bits != '32' && $bits > '22') {
 | 
						|
    $broadcast = trim(`$ipcalc $cidr | grep Broadcast | cut -d" " -f 2`);
 | 
						|
    $ip = ip2long($network) + '1';
 | 
						|
    $end = ip2long($broadcast);
 | 
						|
    while($ip < $end) {
 | 
						|
      $ipdotted = long2ip($ip);
 | 
						|
      if(mysql_result(mysql_query("SELECT count(id) FROM ipaddr WHERE addr = '$ipdotted'"),0) == '0' && match_network($nets, $ipdotted)) {
 | 
						|
	fputs($handle, $ipdotted . "\n");
 | 
						|
      }
 | 
						|
      $ip++;
 | 
						|
    }
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
`fping -t 100 -f ips.txt > ips-scanned.txt`;
 | 
						|
 | 
						|
?>
 |