aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntoine Beaupre <anarcat@koumbit.org>2010-11-12 17:36:40 -0500
committerAntoine Beaupré <anarcat@koumbit.org>2015-04-17 17:49:39 -0400
commita52fa9dc3db79627e1654766a752db5c62ccf499 (patch)
treee5309ede34b3f352150a5f8f5d54ea12fc3d68c6
parent2105d828ea5c3373289ab4e928bcde90bf6b40e1 (diff)
downloadpuppet-backupninja-a52fa9dc3db79627e1654766a752db5c62ccf499.tar.gz
puppet-backupninja-a52fa9dc3db79627e1654766a752db5c62ccf499.tar.bz2
add an option to directly pipe results to nagios to avoid timeouts
-rwxr-xr-xfiles/checkbackups.pl16
1 files changed, 13 insertions, 3 deletions
diff --git a/files/checkbackups.pl b/files/checkbackups.pl
index 106463a..0ea4805 100755
--- a/files/checkbackups.pl
+++ b/files/checkbackups.pl
@@ -44,10 +44,11 @@ our $opt_c = 48 * 60 * 60;
our $opt_w = 24 * 60 * 60;
our $opt_v = 0;
our $opt_o;
+our $opt_s;
-if (!getopts('d:c:w:vo')) {
+if (!getopts('d:c:w:s:vo')) {
print <<EOF
-Usage: $0 [ -d <backupdir> ] [ -c <threshold> ] [ -w <threshold> ] [ -o ] [ -v ]
+Usage: $0 [ -d <backupdir> ] [ -c <threshold> ] [ -w <threshold> ] [ -o ] [ -s <host> ] [ -v ]
EOF
;
exit();
@@ -122,7 +123,16 @@ sub print_status {
if (!$service) {
$service = 'backups';
}
- printf "$host\t$service\t$state\t$state_msg $message\n";
+ $line = "$host\t$service\t$state\t$state_msg $message\n";
+ if ($opt_s) {
+ $opt_v && print STDERR "sending results to nagios...\n";
+ open(NSCA, "|/usr/sbin/send_nsca -H $opt_s") or die("cannot start send_nsca: $!\n");
+ print NSCA $line;
+ close(NSCA) or warn("could not close send_nsca pipe correctly: $!\n");
+ }
+ if (!$opt_s || $opt_v) {
+ printf $line;
+ }
}
sub check_flag {