diff --git a/bin/mongodb_monitor.py b/bin/mongodb_monitor.py index d71727a..016f780 100644 --- a/bin/mongodb_monitor.py +++ b/bin/mongodb_monitor.py @@ -66,8 +66,6 @@ "wt_bm_blocks_written"] -mongodb_hostname = socket.gethostname() - f=open("../conf/mongomon.conf") y = yaml.load(f) f.close() @@ -79,11 +77,11 @@ mongodb_tag = "mongo=" + str(mongodb_ins["port"]) - err,conn = mongodb_monitor.mongodb_connect(host=mongodb_hostname,port=mongodb_ins["port"], user=mongodb_ins["user"], password=mongodb_ins["password"]) + err,conn = mongodb_monitor.mongodb_connect(host=mongodb_ins["ip"],port=mongodb_ins["port"], user=mongodb_ins["user"], password=mongodb_ins["password"]) mongodb_upate_list = [] if err != 0: - key_item_dict = {"endpoint": mongodb_hostname, "metric": "mongo_local_alive", "tags":mongodb_tag , "timestamp":ts, "value": 0, "step": 60, "counterType": "GAUGE"} + key_item_dict = {"endpoint": mongodb_ins["ip"], "metric": "mongo_local_alive", "tags":mongodb_tag , "timestamp":ts, "value": 0, "step": 60, "counterType": "GAUGE"} mongodb_upate_list.append(key_item_dict) r = requests.post(falcon_client,data=json.dumps(mongodb_upate_list)) continue #The instance is dead. upload the "mongo_alive_local=0" key, then continue. @@ -94,9 +92,9 @@ for mongodb_metric in mongodb_dict_keys: if mongodb_metric in mongodb_counter_metric : - key_item_dict = {"endpoint": mongodb_hostname, "metric": mongodb_metric, "tags":mongodb_tag , "timestamp":ts, "value": mongodb_dict[mongodb_metric], "step": 60, "counterType": "COUNTER"} + key_item_dict = {"endpoint": mongodb_ins["ip"], "metric": mongodb_metric, "tags":mongodb_tag , "timestamp":ts, "value": mongodb_dict[mongodb_metric], "step": 60, "counterType": "COUNTER"} else: - key_item_dict = {"endpoint": mongodb_hostname, "metric": mongodb_metric, "tags":mongodb_tag , "timestamp":ts, "value": mongodb_dict[mongodb_metric], "step": 60, "counterType": "GAUGE"} + key_item_dict = {"endpoint": mongodb_ins["ip"], "metric": mongodb_metric, "tags":mongodb_tag , "timestamp":ts, "value": mongodb_dict[mongodb_metric], "step": 60, "counterType": "GAUGE"} mongodb_upate_list.append(key_item_dict) r = requests.post(falcon_client,data=json.dumps(mongodb_upate_list)) diff --git a/bin/mongodb_server.py b/bin/mongodb_server.py index c87965e..c84c751 100644 --- a/bin/mongodb_server.py +++ b/bin/mongodb_server.py @@ -277,14 +277,14 @@ def repl_status(self,connection): for repl_member in repl_status_members: if repl_member.has_key("self") and repl_member["self"]: repl_status_dict["repl_health"] = repl_member["health"] - repl_status_dict["repl_optime"] = repl_member["optime"].time + repl_status_dict["repl_optime"] = repl_member["optime"]["ts"].time if repl_member.has_key("repl_electionTime"): repl_status_dict["repl_electionTime"] = repl_member["electionTime"].time if repl_member.has_key("repl_configVersion"): repl_status_dict["repl_configVersion"] = repl_member["configVersion"] - myself_optime = repl_member["optime"].time + myself_optime = repl_member["optime"]["ts"].time if (replStatus["myState"] == 2 and repl_member["state"] == 1 ): # CONDARY ,get repl lag - master_optime = repl_member["optime"].time + master_optime = repl_member["optime"]["ts"].time if replStatus["myState"] == 2 : repl_status_dict["repl_lag"] = master_optime - myself_optime diff --git a/conf/mongomon.conf b/conf/mongomon.conf index 191928e..51b93db 100644 --- a/conf/mongomon.conf +++ b/conf/mongomon.conf @@ -1,2 +1,2 @@ items: -- {port: 27017, user: "",password: ""} +- {ip: "", port: 27017, user: "",password: ""} diff --git a/misc/pymongo-3.0.3.tar.gz b/misc/pymongo-3.0.3.tar.gz deleted file mode 100644 index 881013d..0000000 Binary files a/misc/pymongo-3.0.3.tar.gz and /dev/null differ