From: Mike Taylor Date: Fri, 22 Mar 2013 09:34:51 +0000 (+0000) Subject: Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/irspy X-Git-Url: http://git.indexdata.com/?p=irspy-moved-to-github.git;a=commitdiff_plain;h=4ea0039ab12cfd6b1921e0496c0cc4f7daca4e4b;hp=dc3c028e1f9a890e1a682e177a0095a5a6a717c2 Merge branch 'master' of ssh://git.indexdata.com:222/home/git/pub/irspy --- 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; +