snmp-scan filter for dns resolved devices (#14934)
* snmp-scan filter for dns resolved devices * . * add console arguments
This commit is contained in:
parent
74c627270a
commit
93f270155f
|
@ -177,6 +177,7 @@ Artisan::command('poller:billing-calculate
|
|||
Artisan::command('scan
|
||||
{network?* : ' . __('CIDR notation network(s) to scan, can be ommited if \'nets\' config is set') . '}
|
||||
{--P|ping-only : ' . __('Add the device as a ping only device if it replies to ping but not SNMP') . '}
|
||||
{--o|dns-only : ' . __('Only DNS resolved Devices') . '}
|
||||
{--t|threads=32 : ' . __('How many IPs to scan at a time, more will increase the scan speed, but could overload your system') . '}
|
||||
{--l|legend : ' . __('Print the legend') . '}
|
||||
', function () {
|
||||
|
@ -189,6 +190,10 @@ Artisan::command('scan
|
|||
return 1;
|
||||
}
|
||||
|
||||
if ($this->option('dns-only')) {
|
||||
$command[] = '-o';
|
||||
}
|
||||
|
||||
if ($this->option('ping-only')) {
|
||||
$command[] = '-P';
|
||||
}
|
||||
|
|
17
snmp-scan.py
17
snmp-scan.py
|
@ -43,6 +43,7 @@ class Outcome:
|
|||
FAILED = 4
|
||||
EXCLUDED = 5
|
||||
TERMINATED = 6
|
||||
NODNS = 7
|
||||
|
||||
|
||||
POLLER_GROUP = "0"
|
||||
|
@ -59,6 +60,7 @@ stats = {
|
|||
Outcome.FAILED: 0,
|
||||
Outcome.EXCLUDED: 0,
|
||||
Outcome.TERMINATED: 0,
|
||||
Outcome.NODNS: 0,
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,6 +77,7 @@ def get_outcome_symbol(outcome):
|
|||
Outcome.KNOWN: "*",
|
||||
Outcome.FAILED: "-",
|
||||
Outcome.TERMINATED: "",
|
||||
Outcome.NODNS: "",
|
||||
}[outcome]
|
||||
|
||||
|
||||
|
@ -126,6 +129,9 @@ def scan_host(scan_ip):
|
|||
|
||||
try:
|
||||
|
||||
if args.dns and not hostname:
|
||||
return Result(scan_ip, hostname, Outcome.NODNS, "DNS not Resolved")
|
||||
|
||||
arguments = [
|
||||
"/usr/bin/env",
|
||||
"lnms",
|
||||
|
@ -134,9 +140,11 @@ def scan_host(scan_ip):
|
|||
POLLER_GROUP,
|
||||
hostname or scan_ip,
|
||||
]
|
||||
|
||||
if args.ping:
|
||||
arguments.insert(5, args.ping)
|
||||
add_output = check_output(arguments)
|
||||
|
||||
return Result(scan_ip, hostname, Outcome.ADDED, add_output)
|
||||
except CalledProcessError as err:
|
||||
output = err.output.decode().rstrip()
|
||||
|
@ -188,6 +196,15 @@ Example: 192.168.0.1/32 will be treated as a single host address""",
|
|||
POLLER_GROUP
|
||||
),
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-o",
|
||||
"--dns-only",
|
||||
dest="dns",
|
||||
action="store_true",
|
||||
help="Only DNS resolved Devices",
|
||||
)
|
||||
|
||||
parser.add_argument("-l", "--legend", action="store_true", help="Print the legend.")
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
|
|
Loading…
Reference in New Issue