Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #236 incorrect error message 'dur' for MongoDB versions 3.2 and above #249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
37 changes: 23 additions & 14 deletions check_mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
else:
import pymongo.son as son

UNSUPPORTED_SERVICE_CHECK_ERROR = "This service check is not supported for versions of MongoDB 3.2 and above"

#
# thanks to http://stackoverflow.com/a/1229667/72987
Expand Down Expand Up @@ -1223,13 +1224,16 @@ def check_journal_commits_in_wl(con, warning, critical, perf_data):

warning = warning or 10
critical = critical or 40
data = get_server_status(con)
try:
data = get_server_status(con)
j_commits_in_wl = data['dur']['commitsInWriteLock']
message = "Journal commits in DB write lock : %d" % j_commits_in_wl
message += performance_data(perf_data, [(j_commits_in_wl, "j_commits_in_wl", warning, critical)])
except KeyError:
return exit_with_general_critical(UNSUPPORTED_SERVICE_CHECK_ERROR)
message = "Journal commits in DB write lock : %d" % j_commits_in_wl
try:
message += performance_data(perf_data,
[(j_commits_in_wl, "j_commits_in_wl", warning, critical)])
return check_levels(j_commits_in_wl, warning, critical, message)

except Exception as e:
return exit_with_general_critical(e)

Expand All @@ -1239,13 +1243,17 @@ def check_journaled(con, warning, critical, perf_data):

warning = warning or 20
critical = critical or 40

data = get_server_status(con)
try:
data = get_server_status(con)
journaled = data['dur']['journaledMB']
message = "Journaled : %.2f MB" % journaled
message += performance_data(perf_data, [("%.2f" % journaled, "journaled", warning, critical)])
except KeyError:
return exit_with_general_critical(UNSUPPORTED_SERVICE_CHECK_ERROR)
message = "Journaled : %.2f MB" % journaled
try:
message += performance_data(perf_data,
[("%.2f" % journaled, "journaled", warning, critical)])
return check_levels(journaled, warning, critical, message)

except Exception as e:
return exit_with_general_critical(e)

Expand All @@ -1256,17 +1264,18 @@ def check_write_to_datafiles(con, warning, critical, perf_data):
than the amount physically written to disk."""
warning = warning or 20
critical = critical or 40
data = get_server_status(con)
try:
data = get_server_status(con)
writes = data['dur']['writeToDataFilesMB']
message = "Write to data files : %.2f MB" % writes
message += performance_data(perf_data, [("%.2f" % writes, "write_to_data_files", warning, critical)])
except KeyError:
return exit_with_general_critical(UNSUPPORTED_SERVICE_CHECK_ERROR)
message = "Write to data files : %.2f MB" % writes
try:
message += performance_data(perf_data,
[("%.2f" % writes, "write_to_data_files", warning, critical)])
return check_levels(writes, warning, critical, message)

except Exception as e:
return exit_with_general_critical(e)


def get_opcounters(data, opcounters_name, host, port):
try:
insert = data[opcounters_name]['insert']
Expand Down