Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Picametrics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Picasoft
Technique
Picametrics
Commits
416a6397
Verified
Commit
416a6397
authored
4 years ago
by
Quentin Duchemin
Browse files
Options
Downloads
Patches
Plain Diff
Add total users stat to Etherpad
parent
b5f27035
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-0
1 addition, 0 deletions
README.md
etherpad/etherpad.py
+17
-4
17 additions, 4 deletions
etherpad/etherpad.py
with
18 additions
and
4 deletions
README.md
+
1
−
0
View file @
416a6397
...
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
etherpad/etherpad.py
+
17
−
4
View file @
416a6397
...
...
@@ -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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment