From 58658cb67902236a701ec8cb34584bbc13d47781 Mon Sep 17 00:00:00 2001 From: Simon Date: Thu, 25 Aug 2022 16:10:24 +0100 Subject: [PATCH] Add stats option --- config.py | 2 -- report_receiver.py | 14 ++++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/config.py b/config.py index cec13ea..5a9f5c0 100755 --- a/config.py +++ b/config.py @@ -202,8 +202,6 @@ def build_config(_config_file): elif section == 'PROXY': pass - - elif config.getboolean(section, 'ENABLED'): if config.get(section, 'MODE') == 'PEER': diff --git a/report_receiver.py b/report_receiver.py index 37b8b07..971bc1f 100644 --- a/report_receiver.py +++ b/report_receiver.py @@ -69,10 +69,16 @@ class reportClient(NetstringReceiver): def bridgeSend(self,data): self.BRIDGES = pickle.loads(data) - if cli_args.WATCH and cli_args.WATCH in self.BRIDGES: - pprint(self.BRIDGES[cli_args.WATCH], compact=True) + if cli_args.STATS: + print('There are currently {} active bridges in the bridge table:\n\n'.format(len(self.BRIDGES))) + for _bridge in self.BRIDGES: + print('{},'.format({_bridge})) + else: - pprint(self.BRIDGES, compact=True, indent=4) + if cli_args.WATCH and cli_args.WATCH in self.BRIDGES: + pprint(self.BRIDGES[cli_args.WATCH], compact=True) + else: + pprint(self.BRIDGES, compact=True, indent=4) def configSend(self,data): self.CONFIG = pickle.loads(data) @@ -128,7 +134,7 @@ if __name__ == '__main__': parser.add_argument('-w', '--watch', action='store', dest='WATCH', help='watch bridge ') parser.add_argument('-o', '--host', action='store', dest='HOST', help='host to connect to ') parser.add_argument('-p', '--port', action='store', dest='PORT', help='port to connect to ') - + parser.add_argument('-s', '--stats', action='store', dest='STATS', help='print stats only') cli_args = parser.parse_args()