1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Update mongodb plugins

* Update mongodb plugins
* fix category
* chmod +x
* flake8-CI
* flake8 adjustments for mongo_collection_ and env python3
This commit is contained in:
Alban 2020-02-13 16:11:16 +01:00 committed by GitHub
parent 52144bc277
commit 276169a6c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 360 additions and 146 deletions

View file

@ -1,24 +1,38 @@
#!/usr/bin/env python
#!/usr/bin/env python3
"""
=head1 NAME
MongoDB Replication Lag
~~~~~~~~~~~~~~~~~~~~~~~
Connects to a single mongo instance and retrieve
replication lag for all connected members.
munin-node.conf:
=head1 APPLICABLE SYSTEMS
MongoDB 3.X and 4.X with pymongo installed.
=head1 CONFIGURATION
munin-node.conf
defauts for host is 127.0.0.1 and port 27017
and will work without being defined :
[mongo_lag]
env.host 127.0.0.1
env.port 27017
env.username user
env.password P@55w0rd
:author: Stefan Andersen <stefan@stefanandersen.dk>
:license: The Beer Ware License (Revision 42)
<stefan@stefanandersen.dk> wrote this file. As long
as you retain this notice you can do whatever you want
with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer in return.
=head1 AUTHOR
Stefan Andersen <stefan@stefanandersen.dk>
Updated by Alban Espie-Guillon <alban.espie@alterway.fr>
=head1 LICENSE
The Beer Ware License (Revision 42)
<alban.espie@alterway.fr> wrote this file. As long
as you retain this notice you can do whatever you want
with this stuff. If we meet some day, and you think
this stuff is worth it, you can buy me a beer in return.
"""
import os
import sys
@ -33,7 +47,7 @@ def _get_members():
if username:
connAuth = conn['admin']
connAuth.authenticate(username, password)
repl_status = conn.admin.command("replSetGetStatus")
members = {}
@ -51,17 +65,17 @@ def run():
for member in members:
lag = (primary_optime - members[member]['optimeDate']).seconds
print "{0}.value {1}".format(member, lag)
print("{0}.value {1}".format(member, lag))
def config():
print """graph_title MongoDB replication lag
print("""graph_title MongoDB replication lag
graph_args --base 1000
graph_vlabel Replication lag (seconds)
graph_category db
"""
""")
for member in _get_members():
print "{0}.label {0}".format(member)
print("{0}.label {0}".format(member))
if __name__ == "__main__":
if len(sys.argv) > 1 and sys.argv[1] == "config":