Skip to content
Snippets Groups Projects
Verified Commit 4ccadd2f authored by Quentin Duchemin's avatar Quentin Duchemin
Browse files

Better exception handling and informations on stdout

parent 508a84c7
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......
......@@ -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():
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment