From 071249df9a9e94b060558b27f61384b02e723a79 Mon Sep 17 00:00:00 2001 From: Maksim Podlesnyi Date: Fri, 29 Jul 2016 13:00:58 +0300 Subject: [PATCH] add an exception for serverStatus execution --- checks.d/mongo.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/checks.d/mongo.py b/checks.d/mongo.py index 459a962777..0f89581668 100644 --- a/checks.d/mongo.py +++ b/checks.d/mongo.py @@ -639,12 +639,20 @@ def total_seconds(td): message=message) raise Exception(message) - self.service_check( - self.SERVICE_CHECK_NAME, - AgentCheck.OK, - tags=service_check_tags) + try: + status = db.command('serverStatus', tcmalloc=collect_tcmalloc_metrics) + except Exception: + self.service_check( + self.SERVICE_CHECK_NAME, + AgentCheck.CRITICAL, + tags=service_check_tags) + raise + else: + self.service_check( + self.SERVICE_CHECK_NAME, + AgentCheck.OK, + tags=service_check_tags) - status = db.command('serverStatus', tcmalloc=collect_tcmalloc_metrics) if status['ok'] == 0: raise Exception(status['errmsg'].__str__())