From 2d5d844978e5a48058d0906ed566322b8f62c8e8 Mon Sep 17 00:00:00 2001 From: Michael Howe Date: Sat, 17 Oct 2015 13:29:25 +0000 Subject: [PATCH] Tag 0.10 --- Makefile | 1 + debian/changelog | 12 ++++++++ plugins/check_configtool | 66 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100755 plugins/check_configtool diff --git a/Makefile b/Makefile index 5239f17..445f331 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,7 @@ install: $(INSTALL) -m 0755 $(PLUGINDIR)/check_ldaps_ip $(DSTPLUGINDIR) $(INSTALL) -m 0755 $(PLUGINDIR)/check_networkclients $(DSTPLUGINDIR) $(INSTALL) -m 0755 $(PLUGINDIR)/check_krb5 $(DSTPLUGINDIR) + $(INSTALL) -m 0755 $(PLUGINDIR)/check_configtool $(DSTPLUGINDIR) clean: $(RM) plugins/check_ldaps_ip diff --git a/debian/changelog b/debian/changelog index 45763aa..27a376f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +nagios-plugins-local (0.10) unstable; urgency=medium + + * Fix Makefile + + -- Michael Howe Sat, 17 Oct 2015 13:09:17 +0100 + +nagios-plugins-local (0.9) unstable; urgency=medium + + * Add check_configtool plugin + + -- Michael Howe Sat, 17 Oct 2015 11:08:47 +0100 + nagios-plugins-local (0.8) unstable; urgency=low * Add more dependencies, used by check_cert diff --git a/plugins/check_configtool b/plugins/check_configtool new file mode 100755 index 0000000..76a9ffe --- /dev/null +++ b/plugins/check_configtool @@ -0,0 +1,66 @@ +#!/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'}; -- 2.39.5