From: Wolfram Schneider Date: Mon, 18 Mar 2013 11:09:43 +0000 (+0000) Subject: need a nagios alert script to check irspy updates, IR-336 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=813831baeff1fbcf5ee6b79ec447942dc429331d;p=irspy-moved-to-github.git need a nagios alert script to check irspy updates, IR-336 --- diff --git a/Changes b/Changes index 921b9b5..227f333 100644 --- a/Changes +++ b/Changes @@ -32,6 +32,7 @@ Revision history for Perl extension ZOOM::IRSpy. from distribution entirely in a subsequent release. - Support new "irspy_data" log-level to register information written to target description record. + - need a nagios alert script to check irspy updates, IR-336 1.02 Wed Jul 7 16:43:36 BST 2010 - Enhance setrlimit program so that it can set maximum diff --git a/bin/irspy-nagios.pl b/bin/irspy-nagios.pl new file mode 100755 index 0000000..8ec764b --- /dev/null +++ b/bin/irspy-nagios.pl @@ -0,0 +1,61 @@ +#!/usr/bin/perl +# Copyright (c) 2013 IndexData ApS, http://indexdata.com +# +# irspy-nagios.pl - check if IRSpy updates run + +use strict; +use warnings; + +use LWP::Simple; +use HTTP::Date; +use Getopt::Long; + +my $help; +my $debug = 0; +my $update_cycle_days = 7; +my $url = 'http://irspy.indexdata.com/raw.html?id=Z39.50%3Aopencontent.indexdata.com%3A210%2Foaister'; + +sub usage () { + < \$debug, + "days=i" => \$update_cycle_days, + "url=s" => \$url, +) or die usage; +die usage if $help; + +my $data = get $url; + +die "No data for $url\n" if !defined $data; +warn $data if $debug >= 2; + +if ($data =~ m,(.*?),) { + my $date = $1; + my $time = str2time($date); + + my $last_update = time() - $time; + warn "last update: $last_update seconds ago\n" if $debug; + + if ($last_update > 24*3600* $update_cycle_days) { + die "Last update is older than $last_update seconds: $date\n"; + } + +} else { + die "cannot parse date field from $url\n"; +} + +exit 0; +