diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | README | 2 | ||||
-rwxr-xr-x | collect.d/nagios | 14 | ||||
-rw-r--r-- | debian/changelog | 5 | ||||
-rw-r--r-- | debian/sitesummary-client.postinst | 12 | ||||
-rw-r--r-- | debian/sitesummary-client.templates | 7 | ||||
-rwxr-xr-x | debian/sitesummary.cron.daily | 3 | ||||
-rw-r--r-- | debian/sitesummary.postinst | 12 | ||||
-rw-r--r-- | debian/sitesummary.templates | 6 | ||||
-rwxr-xr-x | sitesummary-nodes | 99 |
10 files changed, 115 insertions, 46 deletions
@@ -17,6 +17,7 @@ INSTALL_DATA = $(INSTALL) -m 644 COLLECTORS = \ collect.d/debian \ collect.d/debian-edu \ + collect.d/nagios \ collect.d/system \ collect.d/siteinfo @@ -50,7 +50,7 @@ the trick. aptitude install nagios-nrpe-server nagios-plugins-standard sitesummary-client - cat >> /etc/nagios/nrpe_local.cfg <<EOF + cat > /etc/nagios/nrpe.d/sitesummary-nrpe.cfg <<EOF allowed_hosts=myserver dont_blame_nrpe=1 include=/etc/nagios/sitesummary-nrpe-commands.cfg diff --git a/collect.d/nagios b/collect.d/nagios index e2de8d1..caf83d0 100755 --- a/collect.d/nagios +++ b/collect.d/nagios @@ -4,9 +4,11 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin mkdir nagios && cd nagios -if [ -e /etc/nagios/nrpe.cfg ] ; then - cp /etc/nagios/nrpe.cfg nrpe.cfg -fi -if [ -e /etc/nagios/nrpe_local.cfg ] ; then - cp /etc/nagios/nrpe_local.cfg nrpe_local.cfg -fi +for file in /etc/nagios/nrpe.cfg \ + /etc/nagios/nrpe_local.cfg \ + /etc/nagios/nrpe.d/sitesummary-nrpe.cfg \ + ; do + if [ -e $file ] ; then + cp $file $(basename $file) + fi +done diff --git a/debian/changelog b/debian/changelog index e9d7232..a63c7ee 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,11 @@ sitesummary (0.0.55) UNRELEASED; urgency=low conffile questions during upgrades if the contacts are changed and only the commands change. * Drop Nagios dhcp check, as it do not seem to work. + * Provide debconf preseeding suppport (using hidden questions) for + activating Nagios NRPE configuration on clients and Nagios + autoconfiguration on the server. + * Automatically detect if remote NRPE commands can be used for + Nagios checks, and if arguments can be passed or not. -- Petter Reinholdtsen <pere@debian.org> Sat, 16 Jan 2010 21:06:29 +0100 diff --git a/debian/sitesummary-client.postinst b/debian/sitesummary-client.postinst index 4a21703..ae1a242 100644 --- a/debian/sitesummary-client.postinst +++ b/debian/sitesummary-client.postinst @@ -79,6 +79,18 @@ else echo "$HOSTCLASS" > /etc/sitesummary/hostclass fi +config=/etc/nagios/nrpe.d/sitesummary-nrpe.cfg +if [ ! -f $config ] ; then + db_get sitesummary-client/enable-nagios-nrpe-config + if [ true = "$RET" ] ; then + mkdir -p $(dirname $config) + cat > $config <<EOF +dont_blame_nrpe=1 +include=/etc/nagios/sitesummary-nrpe-commands.cfg +EOF + fi +fi + db_stop # Switched from cron.d to cron.daily script in version 0.0.12 diff --git a/debian/sitesummary-client.templates b/debian/sitesummary-client.templates index 1adcaab..8247234 100644 --- a/debian/sitesummary-client.templates +++ b/debian/sitesummary-client.templates @@ -23,3 +23,10 @@ Type: string _Description: Host class: Insert string identifying the host class, like workstation, server, laptop, thin client etc. + +Template: sitesummary-client/enable-nagios-nrpe-config +Type: boolean +Default: false +Description: Activate the Nagios NRPE config feature? + This is an internal (hidden) debconf question. It should not be translated. + diff --git a/debian/sitesummary.cron.daily b/debian/sitesummary.cron.daily index 36623f9..e408a7a 100755 --- a/debian/sitesummary.cron.daily +++ b/debian/sitesummary.cron.daily @@ -7,7 +7,6 @@ set -e daylimit=120 makewebreport=/usr/sbin/sitesummary-makewebreport nodes=/usr/sbin/sitesummary-nodes -nagiosopts=-r # Modify this in collector.cfg to /etc/munin/ to automatically replace # the default munin configuration. @@ -75,7 +74,7 @@ EOF generate_nagios_config() { ( - sitesummary-nodes -n $nagiosopts + sitesummary-nodes -n if [ -f $NAGIOSDIR/nagios-generated.cfg.post ] ; then cat $NAGIOSDIR/nagios-generated.cfg.post diff --git a/debian/sitesummary.postinst b/debian/sitesummary.postinst index b013708..aa08ae1 100644 --- a/debian/sitesummary.postinst +++ b/debian/sitesummary.postinst @@ -33,6 +33,18 @@ case "$1" in fi fi + config=/etc/default/nagios3 + if grep -q '^NAGIOSCFG="/etc/nagios3/sitesummary.cfg"$' "$config"; then + : + else + db_get sitesummary/enable-nagios-config + if [ true = "$RET" ] ; then + mkdir -p $(dirname $config) + echo 'NAGIOSCFG="/etc/nagios3/sitesummary.cfg"' \ + >> /etc/default/nagios3 + fi + fi + # Generate the web page at install time [ -f /var/lib/sitesummary/www/index.html ] || \ /etc/cron.daily/sitesummary diff --git a/debian/sitesummary.templates b/debian/sitesummary.templates index a09b956..aa279d7 100644 --- a/debian/sitesummary.templates +++ b/debian/sitesummary.templates @@ -4,3 +4,9 @@ Default: false Description: Activate the munin config replacement feature? This is an internal (hidden) debconf question. It should not be translated. +Template: sitesummary/enable-nagios-config +Type: boolean +Default: false +Description: Activate the Nagios autoconfig feature? + This is an internal (hidden) debconf question. It should not be translated. + diff --git a/sitesummary-nodes b/sitesummary-nodes index 626ec68..77c0f8b 100755 --- a/sitesummary-nodes +++ b/sitesummary-nodes @@ -17,13 +17,12 @@ Usage: $0 [-hmnw] -h Show usage information -m Generate munin configuration for all munin clients -n Generate nagios configuration for all nagios clients - -r Do not generate nagios checks requiring nrpe configuration on remote hosts -w List all client DNS/IP-addresses and MAC addresses EOF } my %opts; -getopts("hmnwr", \%opts) || (usage(), exit(1)); +getopts("hmnw", \%opts) || (usage(), exit(1)); my %hostnames; @@ -145,11 +144,28 @@ sub is_remote_nagios_client { is_pkg_installed($hostid, "nagios3")); } +sub is_remote_nrpe_config_active { + my $hostid = shift; + + my $path = get_filepath_current($hostid, "/nagios/sitesummary-nrpe.cfg"); + if (open(my $fh, $path)) { + while (<$fh>) { + if (m/^dont_blame_nrpe=1$/) { + close($fh); + return "args"; + } + } + close($fh); + return "noargs"; + } + return undef; +} + + sub print_nagios_service_check { my ($remote, $hostname, $description, $check, $check_args) = @_; my $template = "server-service"; my $cmd; - return if $opts{'r'} && $remote; if ($remote) { $cmd = "check_nrpe!$check"; if (defined $check_args) { @@ -193,6 +209,7 @@ sub generate_nagios_config { my $redirect = ""; my $nagiosclient = is_nagios_client($hostid); my $remote = is_remote_nagios_client($hostid); + my $nrpestatus = is_remote_nrpe_config_active($hostid); # Only check laptops that have the nagios tools installed next if is_laptop($hostid) && ! $remote && ! $nagiosclient; @@ -244,7 +261,48 @@ sub generate_nagios_config { is_pkg_installed($hostid, "apache2")); # The rest of the checks only work if NRPE is installed and configured - next unless ($nagiosclient); + next unless ((!$remote && $nagiosclient) + || ($remote && defined $nrpestatus)); + + # These work without any argument passing. + + # Check for APT upgrades + print_nagios_service_check($remote, $hostname, "apt-updates", + "check_apt"); + +# print_nagios_service_check($remote, $hostname, "dhcp", +# "check_dhcp") +# if is_pkg_installed($hostid, "dhcp3-server"); + + # Check DNS server + print_nagios_service_check($remote, $hostname, "dns", + "check_dns") + if is_pkg_installed($hostid, "pdns-server"); + + # Check FTP server + print_nagios_service_check($remote, $hostname, "ftp", + "check_ftp") + if is_pkg_installed($hostid, "proftpd"); + + # Check IMAPS server + print_nagios_service_check($remote, $hostname, "imaps", + "check_imaps") + if is_pkg_installed($hostid, "courier-imap-ssl"); + + # check software raid status + if ( -e get_filepath_current($hostid, "/system/mdstat") ) { + print_nagios_service_check($remote, $hostname, "sw-raid", + "check_linux_raid"); + } + + # Check NFS server + print_nagios_service_check($remote, $hostname, "nfs", + "check_nfs") + if is_pkg_installed($hostid, "nfs-kernel-server"); + + # These need argument passing (as in dont_blame_nrpe=1) + next unless ((!$remote && $nagiosclient) + || ($remote && "args" eq $nrpestatus)); print_nagios_service_check($remote, $hostname, "swap", "check_swap", "10%!5%"); @@ -254,8 +312,6 @@ sub generate_nagios_config { "check_procs", "500!1000"); print_nagios_service_check($remote, $hostname, "processes zombie", "check_procs_zombie", "20!100"); - print_nagios_service_check($remote, $hostname, "apt-updates", - "check_apt"); # Check unix load print_nagios_service_check($remote, $hostname, "load as in top", "check_load", "75,75,75!90,90,90"); @@ -293,33 +349,12 @@ sub generate_nagios_config { } } - # check software raid status - if ( -e get_filepath_current($hostid, "/system/mdstat") ) { - print_nagios_service_check($remote, $hostname, "sw-raid", - "check_linux_raid"); - } - # check munin if munin-node is installed # check hw raid status # check hardware status # check LDAP and LDAPS using the protocol - # Check DNS server - print_nagios_service_check($remote, $hostname, "dns", - "check_dns") - if is_pkg_installed($hostid, "pdns-server"); - - # Check IMAPS server - print_nagios_service_check($remote, $hostname, "imaps", - "check_imaps") - if is_pkg_installed($hostid, "courier-imap-ssl"); - - # Check NFS server - print_nagios_service_check($remote, $hostname, "nfs", - "check_nfs") - if is_pkg_installed($hostid, "nfs-kernel-server"); - # Check Squid web proxy print_nagios_service_check($remote, $hostname, "squid", "check_squid", "3128!http://www") @@ -334,15 +369,5 @@ sub generate_nagios_config { print_nagios_service_check($remote, $hostname, "process - cron", "check_procs_cron", "1:15!1:25") if (is_pkg_installed($hostid, "cron")); - -# print_nagios_service_check($remote, $hostname, "dhcp", -# "check_dhcp") -# if is_pkg_installed($hostid, "dhcp3-server"); - - # Check FTP server - print_nagios_service_check($remote, $hostname, "ftp", - "check_ftp") - if is_pkg_installed($hostid, "proftpd"); - } } |