From 427f7d668ae0fa2e9083cc27537371f088ea15a1 Mon Sep 17 00:00:00 2001 From: Stefan Safar Date: Thu, 3 Sep 2020 12:12:20 +0200 Subject: [PATCH] Update usage in README, remove unnecessary parenthesis and make sure -L is used only with -p --- README.md | 12 +++++++++--- ethtool-exporter.py | 10 +++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c32f1e5..aeef799 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,9 @@ Warning: since 0.3.0, the code relies on Python3 specific code. If you need to u the 0.2.6 version. # Usage ``` -usage: ethtool-exporter.py [-h] (-f TEXTFILE_NAME | -l LISTEN) [-i INTERVAL] - [-I INTERFACE_REGEX] [-1] +usage: ethtool-exporter.py [-h] (-f TEXTFILE_NAME | -l LISTEN | -p PORT) + [-L LISTEN_ADDRESS] [-i INTERVAL] + [-I INTERFACE_REGEX] [-1] [-q] [-w WHITELIST_REGEX | -b BLACKLIST_REGEX] optional arguments: @@ -24,7 +25,11 @@ optional arguments: Full file path where to store data for node collector to pick up -l LISTEN, --listen LISTEN - Listen host:port, i.e. 0.0.0.0:9417 + OBSOLETE. Use -L/-p instead. Listen host:port, i.e. + 0.0.0.0:9417 + -p PORT, --port PORT Port to listen on, i.e. 9417 + -L LISTEN_ADDRESS, --listen-address LISTEN_ADDRESS + IP address to listen on -i INTERVAL, --interval INTERVAL Number of seconds between updates of the textfile. Default is 5 seconds @@ -32,6 +37,7 @@ optional arguments: Only scrape interfaces whose name matches this regex -1, --oneshot Run only once and exit. Useful for running in a cronjob + -q, --quiet Silence any error messages and warnings -w WHITELIST_REGEX, --whitelist-regex WHITELIST_REGEX Only include values whose name matches this regex. -w and -b are mutually exclusive diff --git a/ethtool-exporter.py b/ethtool-exporter.py index 561ef02..828599b 100755 --- a/ethtool-exporter.py +++ b/ethtool-exporter.py @@ -117,6 +117,10 @@ def _parse_args(self, args): logging.error('Interval has to be used with textfile mode') parser.print_help() sys.exit(1) + if arguments.listen_address and not arguments.port: + logging.error('Listen address has to be used with a listen port') + parser.print_help() + sys.exit(1) if not arguments.interval: arguments.interval = 5 self.args = vars(arguments) @@ -222,9 +226,9 @@ class IPv6HTTPServer(HTTPServer): args = collector.args if args['listen'] or args['port']: if args['listen']: - logging.warning(('You are using obsolete argument -l.' - 'Please switch to -L and -p')) - (ip, port) = args['listen'].rsplit(':', 1) + logging.warning('You are using obsolete argument -l.' + 'Please switch to -L and -p') + ip, port = args['listen'].rsplit(':', 1) else: ip = args['listen_address'] port = args['port']