Skip to content
Snippets Groups Projects
Commit 66cd3e87 authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Configurable retries in check_ping_multiaddr.

Add command line option -r/--retries for specifying the number of
retries to make.  It will be passed on to fping/fping6.  Note that
fping(1) requires this to be in the range 1 <= RETRIES <= 20.
parent 20621ebd
Branches
Tags
No related merge requests found
...@@ -56,6 +56,10 @@ class Options(optparse.OptionParser): ...@@ -56,6 +56,10 @@ class Options(optparse.OptionParser):
help=("Check all addresses each hostname resolves to." help=("Check all addresses each hostname resolves to."
" By default, only the first address for each host is" " By default, only the first address for each host is"
" checked.")) " checked."))
self.add_option(
'-r', '--retries', action='store', type='int', default=9,
help=("Number of ICMP ECHO retries to send [default: %default]."
" Must be in the range 1 <= RETRIES <= 20."))
self.add_option( self.add_option(
'-d', '--debug', action='count', default=0, '-d', '--debug', action='count', default=0,
help=("Increase debug level [default: %default].")) help=("Increase debug level [default: %default]."))
...@@ -72,6 +76,9 @@ class Options(optparse.OptionParser): ...@@ -72,6 +76,9 @@ class Options(optparse.OptionParser):
self.error("At least one IP address is required") self.error("At least one IP address is required")
if not values.ipv4 and not values.ipv6: if not values.ipv4 and not values.ipv6:
self.error("At least one IP version must be specified (-4, -6)") self.error("At least one IP version must be specified (-4, -6)")
if values.retries < 1 or values.retries > 20:
self.error(
"Retries (-r) must be in range 1 <= RETRIES <= 20")
return values,args return values,args
def exit(self, status=0, msg=None): def exit(self, status=0, msg=None):
...@@ -175,11 +182,12 @@ def ping_addresses(addresses): ...@@ -175,11 +182,12 @@ def ping_addresses(addresses):
6: ['fping6'], 6: ['fping6'],
} }
fpingflags = [ fpingflags = [
# These settings gives ca 5 seconds timeout for unreachable addresses # These settings, with default 9 retries, gives ca 5 seconds timeout
# for unreachable addresses
'-i10', # -i10 is the fastest fping allows without being root '-i10', # -i10 is the fastest fping allows without being root
'-t250', '-t250',
'-B1.125', '-B1.125',
'-r9', '-r%d' % (OPTIONS.retries,),
] ]
all_output = [] all_output = []
for ipver,addrs in addresses.items(): for ipver,addrs in addresses.items():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment