[project @ peter@palfrader.org-20080416113949-px1j82hob5fdm2ka]
authorPeter Palfrader <peter@palfrader.org>
Wed, 16 Apr 2008 11:39:49 +0000 (07:39 -0400)
committerPeter Palfrader <peter@palfrader.org>
Wed, 16 Apr 2008 11:39:49 +0000 (07:39 -0400)
Add dsa-check-udldap-freshness

dsa-nagios-nrpe-config/debian/changelog
dsa-nagios-nrpe-config/debian/rules
dsa-nagios-nrpe-config/dsa-check-udldap-freshness [new file with mode: 0755]

index cff50a1..ec5ac86 100644 (file)
@@ -1,3 +1,9 @@
+dsa-nagios-nrpe-config (32) unstable; urgency=low
+
+  * Add dsa-check-udldap-freshness.
+
+ -- Peter Palfrader <weasel@debian.org>  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.
index 8d85dfb..e42d5c3 100755 (executable)
@@ -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 (executable)
index 0000000..be2a6da
--- /dev/null
@@ -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'};