diff --git a/etherpad/etherpad.py b/etherpad/etherpad.py index eea7a6d35af09e2f496485976301f375c0747512..0b2fdb05b279117edb8f4e2d5d74a7676bf26cba 100644 --- a/etherpad/etherpad.py +++ b/etherpad/etherpad.py @@ -75,6 +75,7 @@ class EtherpadCollector(object): 'value': data['totalUsers'] } }) + print("Etherpad : data collected for instance {}".format(instance['name'])) return metrics @@ -88,7 +89,11 @@ class EtherpadCollector(object): # Send request stats_plugin = requests.get(instance['url'] + "/stats.json") stats_native = requests.get(instance['url'] + "/stats") - if stats_plugin.status_code != 200 or stats_native.status_code != 200: + if stats_plugin.status_code != 200: + print("Unable to get stats.json : HTTP {}".format(stats_plugin.status_code)) + return None + if stats_native.status_code != 200: + print("Unable to get stats : HTTP {}".format(stats_plugin.status_code)) return None try: plugin = json.loads(stats_plugin.text) diff --git a/main.py b/main.py index 1180a7020ea0330cb78fdea7c9b40f5c855c63b7..fd00e001c1619fb45b37aa761844e4a78c4da190 100644 --- a/main.py +++ b/main.py @@ -47,15 +47,19 @@ def influxb_connect(config): verify = True # Connect to influx db - return InfluxDBClient( - host=o.hostname, - port=port, - username=config['user'], - password=config['password'], - database=config['database'], - ssl=ssl, - verify_ssl=verify - ) + try: + return InfluxDBClient( + host=o.hostname, + port=port, + username=config['user'], + password=config['password'], + database=config['database'], + ssl=ssl, + verify_ssl=verify + ) + except Exception as e: + print("Cannot connect to {} : {}".format(o.hostname, e)) + print("If InfluxDB has just started, this is normal, please wait!") def main(): diff --git a/mattermost/mattermost.py b/mattermost/mattermost.py index faaff8ab6e5523ea35ede20fdef6a960720f4b91..4366c7df5796149fafb1d34fd8feb30e51481eef 100644 --- a/mattermost/mattermost.py +++ b/mattermost/mattermost.py @@ -53,7 +53,7 @@ class MattermostCollector(object): try: mat_api.login() except Exception as err: - print("Cannot login to {} : {}".format(instance, err)) + print("Cannot login to {} : {}".format(instance['name'], err)) continue self.instances.append( { @@ -157,7 +157,7 @@ class MattermostCollector(object): 'value': daily_data['daily_users_with_posts']['value'] } }) - + print("Mattermost : data collected for instance {}".format(instance['config']['name'])) return metrics @classmethod