monitoring/NPalert/NPalert.spec | 6 ++
monitoring/NPalert/scripts/monitor-queue | 54 +++++++++++++++++++++++
monitoring/NPalert/scripts/queue_remote_check.pl | 52 +++++++++++++++++++---
3 files changed, 105 insertions(+), 7 deletions(-)
New commits:
commit 5a3abbfa337d031c0af11bbb994fb9c5a007b5e4
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Sep 27 18:39:52 2010 +0200
636211 - include man page for queue_remote_check.pl
diff --git a/monitoring/NPalert/NPalert.spec b/monitoring/NPalert/NPalert.spec
index 044bbdb..1d87aa9 100644
--- a/monitoring/NPalert/NPalert.spec
+++ b/monitoring/NPalert/NPalert.spec
@@ -93,6 +93,7 @@ install -p -m 644 cron/notification
$RPM_BUILD_ROOT%{_sysconfdir}/cron.d/
mkdir -p $RPM_BUILD_ROOT%{_mandir}/man3
/usr/bin/pod2man $RPM_BUILD_ROOT/%{_bindir}/monitor-queue | gzip >
$RPM_BUILD_ROOT%{_mandir}/man3/monitor-queue.3pm.gz
+/usr/bin/pod2man $RPM_BUILD_ROOT/%{_bindir}/queue_remote_check.pl | gzip >
$RPM_BUILD_ROOT%{_mandir}/man3/queue_remote_check.pl.3pm.gz
%post
if [ $1 -eq 2 ]; then
@@ -128,6 +129,7 @@ fi
%attr(644,%notif_user,%notif_user) %{_sysconfdir}/notification/static/*
%{_sysconfdir}/notification/stage/config/static
%{_mandir}/man3/monitor-queue*
+%{_mandir}/man3/queue_remote_check.pl*
%clean
rm -rf $RPM_BUILD_ROOT
diff --git a/monitoring/NPalert/scripts/queue_remote_check.pl
b/monitoring/NPalert/scripts/queue_remote_check.pl
index 0d8185f..d9ebb4d 100755
--- a/monitoring/NPalert/scripts/queue_remote_check.pl
+++ b/monitoring/NPalert/scripts/queue_remote_check.pl
@@ -2,16 +2,16 @@
use strict;
use NOCpulse::Config;
+use Pod::Usage;
- my $CFG=NOCpulse::Config->new;
+my $CFG=NOCpulse::Config->new;
my $queue_name=$ARGV[0];
my $WARNING_QUEUE_SIZE = $ARGV[1];
my $CRITICAL_QUEUE_SIZE = $ARGV[2];
unless ($queue_name && $WARNING_QUEUE_SIZE && $CRITICAL_QUEUE_SIZE) {
- &help;
- exit(1);
+ pod2usage(1)
}
my $OK_EXIT = 0;
@@ -24,6 +24,10 @@ use NOCpulse::Config;
ACKS => 'ack_queue_dir',
REQUESTS => 'request_queue_dir' };
+ if (not $CFG) {
+ bailout("Error: /etc/NOCpulse.ini do not exist\n");
+ }
+
# Locate queue directory
my $QUEUE_DIR = $CFG->get('notification', $queue->{$queue_name});
chdir $QUEUE_DIR || &bailout("unable to find queue directory\n");
@@ -49,7 +53,41 @@ sub bailout {
exit($UNKNOWN_EXIT);
}
-sub help {
- print "$0 [queue name (ALERTS|ACKS|REQUESTS)] [warning level] [critical
level]\n";
- print "This script is meant for use with the Command Center remote program check
with data. It tracks the number of unprocessed requests current on disk for the specified
queue.\n"
-}
+=pod
+
+=head1 NAME
+
+queue_remote_check.pl - monitor the queues from Spacewalk monitoring.
+
+=head1 SYNOPSIS
+
+queue_remote_check.pl QUEUE WARNING_QUEUE_SIZE CRITICAL_QUEUE_SIZE
+
+=head1 DESCRIPTION
+
+This script is give you content of the alert, acknowledgement, and request queues.
+There exist version for running as cronjob: monitor-queue.
+
+=head1 OPTIONS
+
+QUEUE
+ Name of notification queue. Should be ALERTS, ACKS or REQUESTS.
+
+WARNING_QUEUE_SIZE
+ Size of queue, which should produce warning. In cron we use 50.
+ If queue reach this limit. Script exit with code 1.
+
+CRITICAL_QUEUE_SIZE
+ Size of queue, which is critical. In cron we use 100.
+ If queue reach this limit, script exit with code 2.
+
+=head1 SEE ALSO
+
+monitor-queue(3)
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2009--2010 Red Hat, Inc.
+Released under GNU General Public License, version 2 (GPLv2).
+
+=cut
commit 1430a68ebeb74542801ed60047cc8fe80352dae6
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Sep 27 18:38:51 2010 +0200
636211 - include man page for monitor-queue
diff --git a/monitoring/NPalert/NPalert.spec b/monitoring/NPalert/NPalert.spec
index e93a576..044bbdb 100644
--- a/monitoring/NPalert/NPalert.spec
+++ b/monitoring/NPalert/NPalert.spec
@@ -91,6 +91,9 @@ install -p -m 644 httpd/templates/*.html
$RPM_BUILD_ROOT%httpd_prefix/template
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/cron.d/
install -p -m 644 cron/notification
$RPM_BUILD_ROOT%{_sysconfdir}/cron.d/notification
+mkdir -p $RPM_BUILD_ROOT%{_mandir}/man3
+/usr/bin/pod2man $RPM_BUILD_ROOT/%{_bindir}/monitor-queue | gzip >
$RPM_BUILD_ROOT%{_mandir}/man3/monitor-queue.3pm.gz
+
%post
if [ $1 -eq 2 ]; then
ls /opt/notification/config/generated/* 2>/dev/null | xargs -I file mv file
%{_sysconfdir}/notification/generated
@@ -124,6 +127,7 @@ fi
%attr (755,%notif_user,%notif_user) %dir %log_dir/ticketlog
%attr(644,%notif_user,%notif_user) %{_sysconfdir}/notification/static/*
%{_sysconfdir}/notification/stage/config/static
+%{_mandir}/man3/monitor-queue*
%clean
rm -rf $RPM_BUILD_ROOT
diff --git a/monitoring/NPalert/scripts/monitor-queue
b/monitoring/NPalert/scripts/monitor-queue
index 37ab28a..8382f52 100755
--- a/monitoring/NPalert/scripts/monitor-queue
+++ b/monitoring/NPalert/scripts/monitor-queue
@@ -7,8 +7,17 @@ use strict;
use NOCpulse::Config;
use NOCpulse::Gritch;
use NOCpulse::NOCpulseini;
+use Pod::Usage;
+
+pod2usage(0) unless $ARGV[0];
my $CFG=NOCpulse::Config->new;
+
+if (not $CFG) {
+ print "Error: /etc/NOCpulse.ini do not exist. Enable monitoring
first.\n";
+ exit(1);
+}
+
my $recipient=$CFG->get('notification','notif_emergency_email');
my $queue_name=$ARGV[0];
@@ -45,3 +54,48 @@ if ($queue_size >= $CRITICAL_QUEUE_SIZE) {
print "$body\n";
$soapbox->gritch('Possible Notification Meltdown!!!',$body);
}
+
+=pod
+
+=head1 NAME
+
+monitor-queue - monitor the queues from Spacewalk monitoring.
+
+=head1 SYNOPSIS
+
+monitor-queue QUEUE WARNING_QUEUE_SIZE CRITICAL_QUEUE_SIZE
+
+=head1 DESCRIPTION
+
+This script is called by cron to monitor the alert, acknowledgement, and request queues.
+You should not execute it manually unless you know what are you doing. For standalone
usage is intended
+executable queue_remote_check.pl
+
+This works independent from the notification system and uses SMTP to deliver warning
messages.
+
+=head1 OPTIONS
+
+QUEUE
+ Name of notification queue. Should be ALERTS, ACKS or REQUESTS.
+
+WARNING_QUEUE_SIZE
+ Size of queue, which should produce warning. In cron we use 50.
+ Currently nothing happen, if queue reach this limit.
+
+CRITICAL_QUEUE_SIZE
+ Size of queue, which is critical. In cron we use 100.
+ If queue reach this limit, email is sent with subject
+ 'Possible Notification Meltdown!!!'
+ Email address is taken from NOCpulse.ini, from section notification, variable
notif_emergency_email.
+
+=head1 SEE ALSO
+
+queue_remote_check.pl(3)
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 2010 Red Hat, Inc.
+Released under GNU General Public License, version 2 (GPLv2).
+
+=cut
+