Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions bin/mongodb_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
"wt_bm_blocks_written"]


mongodb_hostname = socket.gethostname()

f=open("../conf/mongomon.conf")
y = yaml.load(f)
f.close()
Expand All @@ -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.
Expand All @@ -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))
6 changes: 3 additions & 3 deletions bin/mongodb_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion conf/mongomon.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
items:
- {port: 27017, user: "",password: ""}
- {ip: "", port: 27017, user: "",password: ""}
Binary file removed misc/pymongo-3.0.3.tar.gz
Binary file not shown.