Skip to content

Commit

Permalink
add logging of serverStatus errors
Browse files Browse the repository at this point in the history
The current code does not check if db.serverStatus() returns an error (e.g. insufficient privileges). If that is the case, no message is logged anywhere, so user has no clue why metrics are not being posted. I propose to log a warning with the error message.
  • Loading branch information
igroenewold committed Aug 1, 2014
1 parent 3711211 commit 088d280
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions checks.d/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ def check(self, instance):
self.log.error("Mongo: cannot connect with config %s" % server)

status = db["$cmd"].find_one({"serverStatus": 1})
if status['ok'] == 0:
self.log.warn(status['errmsg'].__str__())

status['stats'] = db.command('dbstats')

# Handle replica data, if any
Expand Down

0 comments on commit 088d280

Please sign in to comment.