Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • picasoft/projets/picasoft-metrics-bot
1 result
Show changes
Commits on Source (1)
...@@ -42,7 +42,6 @@ class EtherpadCollector(object): ...@@ -42,7 +42,6 @@ class EtherpadCollector(object):
for instance in self.instances: for instance in self.instances:
data = self._get_stats(instance) data = self._get_stats(instance)
if data is None: if data is None:
print('Unable to get stats from Etherpad instance : ' + instance['url'])
continue continue
# Create metrics # Create metrics
metrics.append({ metrics.append({
...@@ -90,10 +89,10 @@ class EtherpadCollector(object): ...@@ -90,10 +89,10 @@ class EtherpadCollector(object):
stats_plugin = requests.get(instance['url'] + "/stats.json") stats_plugin = requests.get(instance['url'] + "/stats.json")
stats_native = requests.get(instance['url'] + "/stats") stats_native = requests.get(instance['url'] + "/stats")
if stats_plugin.status_code != 200: if stats_plugin.status_code != 200:
print("Unable to get stats.json : HTTP {}".format(stats_plugin.status_code)) print("Unable to get stats.json from {} : HTTP {}".format(instance['name'], stats_plugin.status_code))
return None return None
if stats_native.status_code != 200: if stats_native.status_code != 200:
print("Unable to get stats : HTTP {}".format(stats_plugin.status_code)) print("Unable to get stats from {} : HTTP {}".format(instance['name'], stats_plugin.status_code))
return None return None
try: try:
plugin = json.loads(stats_plugin.text) plugin = json.loads(stats_plugin.text)
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import json import json
import os import os
import sys import sys
import time
from urllib.parse import urlparse from urllib.parse import urlparse
from influxdb import InfluxDBClient from influxdb import InfluxDBClient
from etherpad import EtherpadCollector from etherpad import EtherpadCollector
...@@ -60,6 +61,7 @@ def influxb_connect(config): ...@@ -60,6 +61,7 @@ def influxb_connect(config):
except Exception as e: except Exception as e:
print("Cannot connect to {} : {}".format(o.hostname, e)) print("Cannot connect to {} : {}".format(o.hostname, e))
print("If InfluxDB has just started, this is normal, please wait!") print("If InfluxDB has just started, this is normal, please wait!")
return None
def main(): def main():
...@@ -78,6 +80,10 @@ def main(): ...@@ -78,6 +80,10 @@ def main():
print('You need to add InfluxDB configuration on your config file.') print('You need to add InfluxDB configuration on your config file.')
sys.exit(1) sys.exit(1)
influx_client = influxb_connect(config['influxdb']) influx_client = influxb_connect(config['influxdb'])
while influx_client is None:
print("InfluxDB not available, retrying in 5 seconds...")
time.sleep(5)
influx_client = influxb_connect(config['influxdb'])
# Get Etherpad metrics and push to InfluxDB # Get Etherpad metrics and push to InfluxDB
if 'etherpad' in config['modules']: if 'etherpad' in config['modules']:
......