From a30da43bcb5d4d1d53b7a6619105d724a079fbf6 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sat, 16 Jan 2010 00:44:41 +0000 Subject: Rewrite how nagios configuration is generated to use a function to generate each service check. --- debian/changelog | 7 ++ sitesummary-nodes | 211 +++++++++++++++++++++--------------------------------- 2 files changed, 90 insertions(+), 128 deletions(-) diff --git a/debian/changelog b/debian/changelog index 4c23785..d27e396 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +sitesummary (0.0.54) UNRELEASED; urgency=low + + * Rewrite how nagios configuration is generated to use a function to + generate each service check. + + -- Petter Reinholdtsen Sat, 16 Jan 2010 01:39:35 +0100 + sitesummary (0.0.53) unstable; urgency=low * Collect software raid status from /proc/mdstat if it exist. diff --git a/sitesummary-nodes b/sitesummary-nodes index 4f01059..c79a4ff 100755 --- a/sitesummary-nodes +++ b/sitesummary-nodes @@ -21,7 +21,7 @@ EOF } my %opts; -getopts("hmnw", \%opts) || (usage(), exit(1)); +getopts("hmnwr", \%opts) || (usage(), exit(1)); my %hostnames; @@ -34,7 +34,7 @@ if ($opts{'h'}) { print_munin_list(); } elsif ($opts{'w'}) { print_ip_hw_list(); -} elsif ($opts{'n'}) { # XXX Nagios config generation do not work yet +} elsif ($opts{'n'}) { generate_nagios_config(); } else { print_list(); @@ -113,6 +113,31 @@ sub is_remote_nagios_client { is_pkg_installed($hostid, "nagios3")); } +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) { + $check_args =~ s/!/ /; + $cmd .= " -a $check_args"; + } + } else { + $cmd = "$check"; + $cmd .= "!$check_args" if defined $check_args; + } + print <{package})); my $servicename = $tcpservices{$port}->{name}; - print <