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

Add total users stat to Etherpad

parent b5f27035
No related branches found
No related tags found
No related merge requests found
......@@ -50,6 +50,7 @@ Pay attention that it is a **list** of objects (wich contains URL and name of yo
Etherpad module exports following metrics :
- `etherpad_pads_count` : Number of pads on the instance
- `etherpad_blank_pads_count` : Number of blank pads on the instance
- `etherpad_total_users` : Number of connected users
Each metric have a `name` tag with the name of the instance.
......
......@@ -65,6 +65,16 @@ class EtherpadCollector(object):
'value': data['blankPads']
}
})
metrics.append({
'measurement': 'etherpad_total_users',
'tags': {
'name': instance['name']
},
'time': data['timestamp']*1000,
'fields': {
'value': data['totalUsers']
}
})
return metrics
......@@ -76,12 +86,15 @@ class EtherpadCollector(object):
:returns: JSON data returned by Etherpad stats module
"""
# Send request
res = requests.get(instance['url'] + "/stats.json")
if res.status_code != 200:
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:
return None
try:
data = json.loads(res.text)
plugin = json.loads(stats_plugin.text)
native = json.loads(stats_native.text)
plugin['totalUsers'] = native['totalUsers']
return plugin
except IOError as err:
print(err)
return None
return data
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