Added --ping-only to snmp-scan.py (#13810)
* added --ping-only and --ping-fallback; deprecated -P * Updated help text for snmp-scan.py * format fixes * appease lint again
This commit is contained in:
parent
d026e9f0cc
commit
3a379431a5
|
@ -161,24 +161,26 @@ within your LibreNMS installation directory.
|
|||
Here the script's help-page for reference:
|
||||
|
||||
```text
|
||||
usage: snmp-scan.py [-h] [-r NETWORK] [-t THREADS] [-l] [-v]
|
||||
usage: snmp-scan.py [-h] [-t THREADS] [-g GROUP] [-l] [-v] [--ping-fallback] [--ping-only] [-P] [network ...]
|
||||
|
||||
Scan network for snmp hosts and add them to LibreNMS.
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-r NETWORK CIDR noted IP-Range to scan. Can be specified multiple times
|
||||
This argument is only required if $config['nets'] is not set
|
||||
Example: 192.168.0.0/24 Example: 192.168.0.0/31 will be
|
||||
treated as an RFC3021 p-t-p network with two addresses,
|
||||
192.168.0.0 and 192.168.0.1 Example: 192.168.0.1/32 will be
|
||||
treated as a single host address
|
||||
-t THREADS How many IPs to scan at a time. More will increase the scan
|
||||
speed, but could overload your system. Default: 32
|
||||
-l, --legend Print the legend.
|
||||
-v, --verbose Show debug output. Specifying multiple times increases the
|
||||
verbosity.
|
||||
positional arguments:
|
||||
network CIDR noted IP-Range to scan. Can be specified multiple times
|
||||
This argument is only required if 'nets' config is not set
|
||||
Example: 192.168.0.0/24
|
||||
Example: 192.168.0.0/31 will be treated as an RFC3021 p-t-p network with two addresses, 192.168.0.0 and 192.168.0.1
|
||||
Example: 192.168.0.1/32 will be treated as a single host address
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-t THREADS How many IPs to scan at a time. More will increase the scan speed, but could overload your system. Default: 32
|
||||
-g GROUP The poller group all scanned devices will be added to. Default: The first group listed in 'distributed_poller_group', or 0 if not specificed
|
||||
-l, --legend Print the legend.
|
||||
-v, --verbose Show debug output. Specifying multiple times increases the verbosity.
|
||||
--ping-fallback Add the device as an ICMP only device if it replies to ping but not SNMP.
|
||||
--ping-only Always add the device as an ICMP only device.
|
||||
-P, --ping Deprecated. Use --ping-fallback instead.
|
||||
```
|
||||
|
||||
### Discovered devices
|
||||
|
|
39
snmp-scan.py
39
snmp-scan.py
|
@ -172,17 +172,6 @@ Example: 192.168.0.0/24
|
|||
Example: 192.168.0.0/31 will be treated as an RFC3021 p-t-p network with two addresses, 192.168.0.0 and 192.168.0.1
|
||||
Example: 192.168.0.1/32 will be treated as a single host address""",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-P",
|
||||
"--ping",
|
||||
action="store_const",
|
||||
const="-b",
|
||||
default="",
|
||||
help="""Add the device as an ICMP only device if it replies to ping but not SNMP.
|
||||
Example: """
|
||||
+ __file__
|
||||
+ """ -P 192.168.0.0/24""",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-t",
|
||||
dest="threads",
|
||||
|
@ -207,6 +196,24 @@ Example: """
|
|||
help="Show debug output. Specifying multiple times increases the verbosity.",
|
||||
)
|
||||
|
||||
pinggrp = parser.add_mutually_exclusive_group()
|
||||
pinggrp.add_argument(
|
||||
"--ping-fallback",
|
||||
action="store_const",
|
||||
dest="ping",
|
||||
const="-b",
|
||||
default="",
|
||||
help="Add the device as an ICMP only device if it replies to ping but not SNMP.",
|
||||
)
|
||||
pinggrp.add_argument(
|
||||
"--ping-only",
|
||||
action="store_const",
|
||||
dest="ping",
|
||||
const="-P",
|
||||
default="",
|
||||
help="Always add the device as an ICMP only device.",
|
||||
)
|
||||
|
||||
# compatibility arguments
|
||||
parser.add_argument("-r", dest="network", action="append", help=argparse.SUPPRESS)
|
||||
parser.add_argument(
|
||||
|
@ -214,6 +221,16 @@ Example: """
|
|||
)
|
||||
parser.add_argument("-n", action="store_true", help=argparse.SUPPRESS)
|
||||
parser.add_argument("-b", action="store_true", help=argparse.SUPPRESS)
|
||||
pinggrp.add_argument(
|
||||
"-P",
|
||||
"--ping",
|
||||
action="store_const",
|
||||
dest="ping",
|
||||
const="-b",
|
||||
default="",
|
||||
help="Deprecated; Use --ping-fallback instead.",
|
||||
# help=argparse.SUPPRESS, #uncomment after grace period
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
Loading…
Reference in New Issue