Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: mzupan/nagios-plugin-mongodb
base: cdaa3d8158
...
head fork: mzupan/nagios-plugin-mongodb
compare: 3faf1c1ce3
  • 2 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Showing with 17 additions and 5 deletions.
  1. +17 −5 check_mongodb.py
View
22 check_mongodb.py
@@ -134,8 +134,13 @@ def main(argv):
port = options.port
user = options.user
passwd = options.passwd
- warning = float(options.warning) if (options.warning and options.action!='replset_state') else options.warning
- critical = float(options.critical) if (options.critical and options.action!='replset_state') else options.critical
+ if (options.action=='replset_state'):
+ warning = str(options.warning or "")
+ critical = str(options.critical or "")
+ else:
+ warning = float(options.warning or 0)
+ critical = float(options.critical or 0)
+
action = options.action
perf_data = options.perf_data
max_lag = options.max_lag
@@ -439,8 +444,15 @@ def index_miss_ratio(con, warning, critical, perf_data):
def check_replset_state(con,perf_data,warning="",critical=""):
- warning = [int(x) for x in warning.split(",")] if warning else [0,3,5]
- critical= [int(x) for x in critical.split(",") ] if critical else [8,4,-1]
+ try:
+ warning = [int(x) for x in warning.split(",")]
+ except :
+ warning = [0,3,5]
+ try:
+ critical= [int(x) for x in critical.split(",") ]
+ except :
+ critical=[8,4,-1]
+
ok = range(-1,8) #should include the range of all posiible values
try:
try:
@@ -451,7 +463,7 @@ def check_replset_state(con,perf_data,warning="",critical=""):
data = con.admin.command(son.SON([('replSetGetStatus', 1)]))
state = int(data['myState'])
except pymongo.errors.OperationFailure,e :
- if e.code==None and e.message.find('failed: not running with --replSet"'):
+ if e.code==None and str(e).find('failed: not running with --replSet"'):
state=-1
if state == 8:

No commit comments for this range

Something went wrong with that request. Please try again.