summaryrefslogtreecommitdiffstats
path: root/extensions/Push
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-03-27 09:35:44 +0100
committerByron Jones <bjones@mozilla.com>2013-03-27 09:35:44 +0100
commit930b6f4b3aaf1dcbfb1d24f56f1282a98f13f50b (patch)
tree91337fd616ca3e0930e14148cf5f812eda2b893b /extensions/Push
parent6c4fcb2bee2e1783d692011b58b42e5779385b15 (diff)
downloadbugzilla-930b6f4b3aaf1dcbfb1d24f56f1282a98f13f50b.tar.gz
bugzilla-930b6f4b3aaf1dcbfb1d24f56f1282a98f13f50b.tar.xz
Bug 854891: Add a nagios checker for the push_backlog table
Diffstat (limited to 'extensions/Push')
-rwxr-xr-xextensions/Push/bin/nagios_push_checker.pl54
1 files changed, 54 insertions, 0 deletions
diff --git a/extensions/Push/bin/nagios_push_checker.pl b/extensions/Push/bin/nagios_push_checker.pl
new file mode 100755
index 000000000..f022f584d
--- /dev/null
+++ b/extensions/Push/bin/nagios_push_checker.pl
@@ -0,0 +1,54 @@
+#!/usr/bin/perl
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
+use strict;
+use warnings;
+
+use FindBin '$RealBin';
+use lib "$RealBin/../../..";
+use lib "$RealBin/../../../lib";
+use lib "$RealBin/../lib";
+
+use Bugzilla;
+use Bugzilla::Constants;
+
+Bugzilla->usage_mode(USAGE_MODE_CMDLINE);
+
+# Number of jobs required in the queue before we alert
+
+use constant WARN_COUNT => 500;
+use constant ALARM_COUNT => 750;
+
+use constant NAGIOS_OK => 0;
+use constant NAGIOS_WARNING => 1;
+use constant NAGIOS_CRITICAL => 2;
+
+my $connector = shift
+ || die "Syntax: $0 connector\neg. $0 TCL\n";
+$connector = uc($connector);
+
+my $sql = <<EOF;
+ SELECT COUNT(*)
+ FROM push_backlog
+ WHERE connector = ?
+EOF
+
+my $dbh = Bugzilla->switch_to_shadow_db;
+my ($count) = @{ $dbh->selectcol_arrayref($sql, undef, $connector) };
+
+if ($count < WARN_COUNT) {
+ print "push $connector OK: $count messages found.\n";
+ exit NAGIOS_OK;
+} elsif ($count < ALARM_COUNT) {
+ print "push $connector WARNING: $count messages found.\n";
+ exit NAGIOS_WARNING;
+} else {
+ print "push $connector CRITICAL: $count messages found.\n";
+ exit NAGIOS_CRITICAL;
+}