mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-22 02:51:03 +00:00
mongodb_conn load env.MONGO_DB_URI
This commit is contained in:
parent
842acaef1a
commit
6ee90f2ee4
1 changed files with 16 additions and 8 deletions
|
@ -18,6 +18,11 @@ Default for host is 127.0.0.1 and port 27017 and will work without being defined
|
||||||
env.username user
|
env.username user
|
||||||
env.password P@55w0rd
|
env.password P@55w0rd
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
[mongodb_conn]
|
||||||
|
env.MONGO_DB_URI mongodb://user:passwd@127.0.0.1:27017
|
||||||
|
|
||||||
=head1 AUTHOR
|
=head1 AUTHOR
|
||||||
|
|
||||||
Alban Espie-Guillon <alban.espie@alterway.fr>
|
Alban Espie-Guillon <alban.espie@alterway.fr>
|
||||||
|
@ -42,14 +47,17 @@ import pymongo
|
||||||
|
|
||||||
|
|
||||||
def _get_connections():
|
def _get_connections():
|
||||||
host = os.environ.get('host', '127.0.0.1')
|
if 'MONGO_DB_URI' in os.environ:
|
||||||
port = os.environ.get('port', 27017)
|
conn = pymongo.MongoClient(os.environ['MONGO_DB_URI'])
|
||||||
username = os.environ.get('username', '')
|
else:
|
||||||
password = os.environ.get('password', '')
|
host = os.environ.get('host', '127.0.0.1')
|
||||||
conn = pymongo.MongoClient(host, int(port))
|
port = os.environ.get('port', 27017)
|
||||||
if username:
|
username = os.environ.get('username', '')
|
||||||
connAuth = conn['admin']
|
password = os.environ.get('password', '')
|
||||||
connAuth.authenticate(username, password)
|
conn = pymongo.MongoClient(host, int(port))
|
||||||
|
if username:
|
||||||
|
connAuth = conn['admin']
|
||||||
|
connAuth.authenticate(username, password)
|
||||||
|
|
||||||
""" cli : db.serverStatus().connections """
|
""" cli : db.serverStatus().connections """
|
||||||
conn_status = conn.admin.command("serverStatus")['connections']
|
conn_status = conn.admin.command("serverStatus")['connections']
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue