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,6 +18,20 @@ def stats(): @click.pass_obj def count(obj, by_type): + + def calculate_host_number(config, type='all'): + + if type == 'all': + + hosts = set() + + for values in config['ENNSTATUS_SERVERS'].values(): + ips = frozenset(values['IPS']) + hosts.add(ips) + + return len(hosts) + + app = create_app() with app.app_context(): @@ -35,6 +49,15 @@ def count(obj, by_type): ) ) + click.echo( + 'We have %s different hosts!' % ( + click.style( + str(calculate_host_number(app.config)), + fg='blue' + ) + ) + ) + @stats.command('countries') @click.option('--by-type', 'by_type', is_flag=True, default=False)