diff --git a/ennstatus/cli/commands/stats.py b/ennstatus/cli/commands/stats.py --- a/ennstatus/cli/commands/stats.py +++ b/ennstatus/cli/commands/stats.py @@ -18,19 +18,23 @@ def stats(): @click.pass_obj def count(obj, by_type): - - def calculate_host_number(config, type='all'): + def calculate_host_number(config, type='all', servers=None): + hosts = set() if type == 'all': - hosts = set() - for values in config['ENNSTATUS_SERVERS'].values(): ips = frozenset(values['IPS']) hosts.add(ips) return len(hosts) - + else: + for server in servers[servertype]: + ips = frozenset( + config['ENNSTATUS_SERVERS'][server.name.lower()]['IPS'] + ) + hosts.add(ips) + return len(hosts) app = create_app() @@ -57,6 +61,38 @@ def count(obj, by_type): ) ) ) + else: + for servertype, server in servers.items(): + click.echo( + 'We have %s %s servers!' % ( + click.style( + str(len(server)), + fg='blue' + ), + click.style( + servertype, + fg='red' + ) + ) + ) + click.echo( + 'We have %s different %s hosts!' % ( + click.style( + str( + calculate_host_number( + app.config, + type=servertype, + servers=servers + ) + ), + fg='blue' + ), + click.style( + servertype, + fg='red' + ) + ) + ) @stats.command('countries')