Nuria has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/143868

Change subject: Correcting text output of check_graphite script
......................................................................

Correcting text output of check_graphite script

Script was reporting "Less than x data above the threshold [x]"
when it was actually checking whether values are "below" threshold
i.e. --under was passed on on the comand line

Change-Id: Ibb164e0b5c6d205c723291d5d3c60203854fb964
---
M files/icinga/check_graphite
1 file changed, 15 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/68/143868/1

diff --git a/files/icinga/check_graphite b/files/icinga/check_graphite
index cb5cfe2..188a19e 100755
--- a/files/icinga/check_graphite
+++ b/files/icinga/check_graphite
@@ -8,6 +8,10 @@
 
 :copyright: (c) 2014 Wikimedia Foundation
 :license: Apache License 2.0, see LICENSE for more details.
+
+ Can be tested like:
+ ./files/icinga/check_graphite --url http://graphite.wikimedia.org 
check_threshold
+   <metric-name> --from 15min -C 1 -W 2 --under
 """
 
 import os
@@ -184,7 +188,7 @@
             dest="percentage",
             default=1,
             type=int,
-            help='Number of datapoints above threshold that will raise the 
alarm')
+            help='Number of datapoints above or below threshold that will 
raise the alarm')
         return p
 
     def get_all(self, args):
@@ -212,8 +216,10 @@
         for target in self.targets:
             self.params.append(('target', target))
         if args.under:
+            self.under = True
             self.check_func = lambda x, y: x < y
         else:
+            self.under = False
             self.check_func = lambda x, y: x > y
         self.limits = {}
         self.limits['WARNING'] = args.warn
@@ -255,6 +261,10 @@
         if not datapoints['_total']:
             raise NagiosException('UNKNOWN', 'No valid datapoints found')
 
+        report = "above"
+        if self.under:
+            report = "under"
+
         lengths = {}
         t = datapoints['_total']
         for key in NagiosException.NAGIOS_STATUSES.keys():
@@ -267,10 +277,10 @@
             if lengths[key] >= t * self.perc / 100.0:
                 perc = lengths[key] * 100.0 / t
                 raise NagiosException(
-                    key, '%3.2f%% of data exceeded the %s threshold [%s]' %
-                    (perc, key.lower(), self.limits[key]))
-        return 'Less than %3.2f%% data above the threshold [%s]' % \
-            (self.perc, self.limits['WARNING'])
+                    key, '%3.2f%% of data %s the %s threshold [%s]' %
+                    (perc, report, key.lower(), self.limits[key]))
+        return 'Less than %3.2f%% %s the threshold [%s]' % \
+            (self.perc, report, self.limits['WARNING'])
 
 
 class Anomaly(GraphiteCheck):

-- 
To view, visit https://gerrit.wikimedia.org/r/143868
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibb164e0b5c6d205c723291d5d3c60203854fb964
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Nuria <nu...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to