From a146d2dd351b057faaae230e9d8232e274071b7b Mon Sep 17 00:00:00 2001 From: Kay Agahd Date: Wed, 31 Jul 2019 11:47:01 +0200 Subject: [PATCH] hotfix replication_lag_percent with authentication --- check_mongodb.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/check_mongodb.py b/check_mongodb.py index 6b9be53..52d5f53 100755 --- a/check_mongodb.py +++ b/check_mongodb.py @@ -215,7 +215,7 @@ def main(argv): elif action == "replication_lag": return check_rep_lag(con, host_to_check, port_to_check, warning, critical, False, perf_data, max_lag, user, passwd) elif action == "replication_lag_percent": - return check_rep_lag(con, host_to_check, port_to_check, warning, critical, True, perf_data, max_lag, user, passwd, ssl, insecure, ssl_ca_cert_file, cert_file) + return check_rep_lag(con, host_to_check, port_to_check, warning, critical, True, perf_data, max_lag, user, passwd, authdb, ssl, insecure, ssl_ca_cert_file, cert_file) elif action == "replset_state": return check_replset_state(con, perf_data, warning, critical) elif action == "memory": @@ -412,7 +412,7 @@ def check_connections(con, warning, critical, perf_data): return exit_with_general_critical(e) -def check_rep_lag(con, host, port, warning, critical, percent, perf_data, max_lag, user, passwd, ssl=None, insecure=None, ssl_ca_cert_file=None, cert_file=None): +def check_rep_lag(con, host, port, warning, critical, percent, perf_data, max_lag, user, passwd, authdb="admin", ssl=None, insecure=None, ssl_ca_cert_file=None, cert_file=None): # Get mongo to tell us replica set member name when connecting locally if "127.0.0.1" == host: if not "me" in list(con.admin.command("ismaster","1").keys()): @@ -521,7 +521,7 @@ def check_rep_lag(con, host, port, warning, critical, percent, perf_data, max_la lag = float(optime_lag.seconds + optime_lag.days * 24 * 3600) if percent: - err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), ssl, user, passwd, None, None, insecure, ssl_ca_cert_file, cert_file) + err, con = mongo_connect(primary_node['name'].split(':')[0], int(primary_node['name'].split(':')[1]), ssl, user, passwd, None, authdb, insecure, ssl_ca_cert_file, cert_file) if err != 0: return err primary_timediff = replication_get_time_diff(con) @@ -1649,3 +1649,4 @@ def replication_get_time_diff(con): # if __name__ == "__main__": sys.exit(main(sys.argv[1:])) +