mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added support for nets-exclude in snmp-scan
This commit is contained in:
@@ -84,7 +84,7 @@ if (!$where) {
|
||||
echo "-r Do not create or update RRDs\n";
|
||||
echo "-f Do not insert data into InfluxDB\n";
|
||||
echo "-d Enable debugging output\n";
|
||||
echo "-d Enable verbose debugging output\n";
|
||||
echo "-v Enable verbose debugging output\n";
|
||||
echo "-m Specify module(s) to be run\n";
|
||||
echo "\n";
|
||||
echo "No polling type specified!\n";
|
||||
|
@@ -42,7 +42,7 @@ require 'includes/functions.php';
|
||||
require 'includes/discovery/functions.inc.php';
|
||||
|
||||
function perform_snmp_scan($net) {
|
||||
global $stats, $config, $debug;
|
||||
global $stats, $config, $debug, $vdebug;
|
||||
echo 'Range: '.$net->network.'/'.$net->bitmask.PHP_EOL;
|
||||
$config['snmp']['timeout'] = 1;
|
||||
$config['snmp']['retries'] = 0;
|
||||
@@ -52,6 +52,10 @@ function perform_snmp_scan($net) {
|
||||
while ($start++ < $end) {
|
||||
$stats['count']++;
|
||||
$host = long2ip($start);
|
||||
if (match_network($config['autodiscovery']['nets-exclude'], $host)) {
|
||||
echo '|';
|
||||
continue;
|
||||
}
|
||||
$test = isPingable($host);
|
||||
if ($test['result'] === false) {
|
||||
echo '.';
|
||||
@@ -93,7 +97,7 @@ function perform_snmp_scan($net) {
|
||||
echo PHP_EOL;
|
||||
}
|
||||
|
||||
$opts = getopt('r:d::l::h::');
|
||||
$opts = getopt('r:d::v::l::h::');
|
||||
$stats = array('count'=> 0, 'known'=>0, 'added'=>0, 'failed'=>0);
|
||||
$start = false;
|
||||
$debug = false;
|
||||
@@ -106,15 +110,19 @@ if (isset($opts['h']) || (empty($opts) && (!isset($config['nets']) || empty($con
|
||||
echo ' This argument is only requied if $config[\'nets\'] is not set'.PHP_EOL;
|
||||
echo ' Example: 192.168.0.0/24'.PHP_EOL;
|
||||
echo ' -d Enable Debug'.PHP_EOL;
|
||||
echo ' -v Enable verbose Debug'.PHP_EOL;
|
||||
echo ' -l Show Legend'.PHP_EOL;
|
||||
echo ' -h Print this text'.PHP_EOL;
|
||||
exit(0);
|
||||
}
|
||||
if (isset($opts['d'])) {
|
||||
if (isset($opts['d']) || isset($opts['v'])) {
|
||||
if (isset($opts['v'])) {
|
||||
$vdebug = true;
|
||||
}
|
||||
$debug = true;
|
||||
}
|
||||
if (isset($opts['l'])) {
|
||||
echo ' * = Known Device; . = Unpingable Device; + = Added Device; - = Failed To Add Device;'.PHP_EOL;
|
||||
echo ' * = Known Device; . = Unpingable Device; + = Added Device; - = Failed To Add Device; | = Excluded by config.php'.PHP_EOL;
|
||||
}
|
||||
if (isset($opts['r'])) {
|
||||
$net = Net_IPv4::parseAddress($opts['r']);
|
||||
|
Reference in New Issue
Block a user