From 088d2802ed10ded2cf8a7cf2cc2fff9ba75155e9 Mon Sep 17 00:00:00 2001 From: igroenewold Date: Fri, 1 Aug 2014 10:22:39 -0300 Subject: [PATCH] add logging of serverStatus errors 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. --- checks.d/mongo.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/checks.d/mongo.py b/checks.d/mongo.py index 5787e173ae..18e343703b 100644 --- a/checks.d/mongo.py +++ b/checks.d/mongo.py @@ -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