From: Peter Palfrader Date: Wed, 16 Apr 2008 11:39:49 +0000 (-0400) Subject: [project @ peter@palfrader.org-20080416113949-px1j82hob5fdm2ka] X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=51f02d8f5f8eed3a4fc758b54509e0a8300c3209;p=mirror%2Fdsa-nagios.git [project @ peter@palfrader.org-20080416113949-px1j82hob5fdm2ka] Add dsa-check-udldap-freshness --- diff --git a/dsa-nagios-nrpe-config/debian/changelog b/dsa-nagios-nrpe-config/debian/changelog index cff50a1..ec5ac86 100644 --- a/dsa-nagios-nrpe-config/debian/changelog +++ b/dsa-nagios-nrpe-config/debian/changelog @@ -1,3 +1,9 @@ +dsa-nagios-nrpe-config (32) unstable; urgency=low + + * Add dsa-check-udldap-freshness. + + -- Peter Palfrader Wed, 16 Apr 2008 07:39:21 -0400 + dsa-nagios-nrpe-config (31) unstable; urgency=low * dsa-check-dabackup: Use last time's log file if backup is currently running. diff --git a/dsa-nagios-nrpe-config/debian/rules b/dsa-nagios-nrpe-config/debian/rules index 8d85dfb..e42d5c3 100755 --- a/dsa-nagios-nrpe-config/debian/rules +++ b/dsa-nagios-nrpe-config/debian/rules @@ -17,6 +17,7 @@ install: install -m 755 dsa-check-raid-sw $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins install -m 755 dsa-check-da-in-aliases $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins install -m 755 dsa-check-dabackup $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins + install -m 755 dsa-check-udldap-freshness $(CURDIR)/debian/dsa-nagios-nrpe-config/usr/lib/nagios/plugins binary-indep: install diff --git a/dsa-nagios-nrpe-config/dsa-check-udldap-freshness b/dsa-nagios-nrpe-config/dsa-check-udldap-freshness new file mode 100755 index 0000000..be2a6da --- /dev/null +++ b/dsa-nagios-nrpe-config/dsa-check-udldap-freshness @@ -0,0 +1,50 @@ +#!/usr/bin/perl -w + +use strict; +my %CODE = ( + 'UNDEF' => -1, + 'OK' => 0, + 'WARNING' => 1, + 'CRITICAL' => 2, + 'UNKNOWN' => 3 +); + +my $f; + +$SIG{__DIE__ } = sub() { + print shift; + exit $CODE{'UNKNOWN'}; +}; + +if ( -e "/var/lib/misc/thishost/passwd.tdb" ) { + $f = "/var/lib/misc/thishost/passwd.tdb"; +} else { + my $hostname = `hostname -f`; + chomp $hostname; + $hostname =~ m/^([a-z]+(?:\.[a-z]+)+)$/; + die "Weird hostname '$hostname'\n" unless defined $1; + $hostname = $1; + if ( -e "/var/lib/misc/$hostname/passwd.tdb" ) { + $f = "/var/lib/misc/$hostname/passwd.tdb"; + }; +}; + +die "Could not find passwd.tdb" unless defined $f; + +my @stat = stat($f) or die ("Cannot stat $f: $!\n"); +my $age = time - $stat[10]; +my $hage; +if ($age > 48 * 3600) { + $hage = sprintf("%.1f days", $age / 24 / 3600); +} elsif ($age > 3600) { + $hage = sprintf("%.1f hours", $age / 3600); +} else { + $hage = sprintf("%d minutes", $age / 60); +}; + +if ($age > 60*60) { + print "WARNING: ud-ldap info is $hage old\n"; + exit $CODE{'WARNING'}; +}; +print "OK: ud-ldap info is $hage old\n"; +exit $CODE{'OK'};