+nagios-plugins-local (0.9) unstable; urgency=medium
+
+ * Add check_configtool plugin
+
+ -- Michael Howe <michael@michaelhowe.org> Sat, 17 Oct 2015 11:08:47 +0100
+
nagios-plugins-local (0.8) unstable; urgency=low
* Add more dependencies, used by check_cert
--- /dev/null
+#!/usr/bin/perl
+#
+# $HeadURL$
+# $LastChangedRevision$
+# $LastChangedDate$
+# $LastChangedBy$
+#
+#
+# check_configtool - check that configtool is enabled and has a cronjob that runs.
+#
+# Conditions:
+# * configtool disabled: warning
+# * configtool cronjob not present: critical
+# * configtool.disable file location not defined: unknown
+
+use strict;
+use warnings;
+
+use lib '/usr/lib/nagios/plugins';
+use utils qw(%ERRORS);
+
+use Configtool::Config;
+
+my $config = Configtool::Config->new();
+
+unless( $config->disablepath ){
+ print "UNKNOWN: cannot find location of configtool.disable file in configuration (is configtool installed?)\n";
+ exit $ERRORS{'UNKNOWN'};
+}
+# Check that the repository exists:
+unless( -d $config->repository ){
+ printf "UNKNOWN: repository directory %s does not exist (running as correct user?)\n", $config->repository;
+ exit $ERRORS{'UNKNOWN'};
+}
+
+# Check configtool cronjob exists
+my $cronjob_exists = 0;
+CRONTABS: foreach my $file ( glob '/etc/cron.d/*' ){
+ # letters, digits, underscores and hyphens, per cron(8)
+ next unless $file =~ m{[a-z0-9_-]+}i;
+ open( my $fh, "<", $file )
+ or die "Could not open $file for reading: $!";
+ while( my $line = <$fh> ){
+ chomp( $line );
+ next if $line =~ m{^#};
+ if( $line =~ m{configtool$} ){
+ $cronjob_exists = 1;
+ last CRONTABS;
+ }
+ }
+ close( $fh );
+}
+
+unless( $cronjob_exists ){
+ print "CRITICAL: cannot find a cronjob running configtool\n";
+ exit $ERRORS{'CRITICAL'};
+}
+
+# Check if configtool is disabled
+if ( -f $config->disablepath ){
+ printf "WARNING: configtool disabled (%s exists)\n", $config->disablepath;
+ exit $ERRORS{'WARNING'};
+}
+
+print "OK: cronjob exists, configtool enabled\n";
+exit $ERRORS{'OK'};