mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 10:39:53 +00:00
mongo_lag load env.MONGO_DB_URI
This commit is contained in:
parent
6ee90f2ee4
commit
95e525db5a
1 changed files with 16 additions and 8 deletions
|
@ -20,6 +20,11 @@ Default for host is 127.0.0.1 and port 27017 and will work without being defined
|
|||
env.username user
|
||||
env.password P@55w0rd
|
||||
|
||||
or
|
||||
|
||||
[mongo_lag]
|
||||
env.MONGO_DB_URI mongodb://user:passwd@127.0.0.1:27017
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Stefan Andersen <stefan@stefanandersen.dk>
|
||||
|
@ -44,14 +49,17 @@ import sys
|
|||
import pymongo
|
||||
|
||||
def _get_members():
|
||||
host = os.environ.get('host', '127.0.0.1')
|
||||
port = os.environ.get('port', 27017)
|
||||
username = os.environ.get('username', '')
|
||||
password = os.environ.get('password', '')
|
||||
conn = pymongo.MongoClient(host, int(port))
|
||||
if username:
|
||||
connAuth = conn['admin']
|
||||
connAuth.authenticate(username, password)
|
||||
if 'MONGO_DB_URI' in os.environ:
|
||||
conn = pymongo.MongoClient(os.environ['MONGO_DB_URI'])
|
||||
else:
|
||||
host = os.environ.get('host', '127.0.0.1')
|
||||
port = os.environ.get('port', 27017)
|
||||
username = os.environ.get('username', '')
|
||||
password = os.environ.get('password', '')
|
||||
conn = pymongo.MongoClient(host, int(port))
|
||||
if username:
|
||||
connAuth = conn['admin']
|
||||
connAuth.authenticate(username, password)
|
||||
|
||||
repl_status = conn.admin.command("replSetGetStatus")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue