diff options
-rw-r--r-- | debian/changelog | 1 | ||||
-rwxr-xr-x | sitesummary-nodes | 31 |
2 files changed, 31 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog index 2d26578..e5d23cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ sitesummary (0.0.55) UNRELEASED; urgency=low * Update documetation on how to enable NRPE configuration on the clients. + * Make sure a ping check is generated for each hosts default route. -- Petter Reinholdtsen <pere@debian.org> Sat, 16 Jan 2010 21:06:29 +0100 diff --git a/sitesummary-nodes b/sitesummary-nodes index 11f8987..cb44a30 100755 --- a/sitesummary-nodes +++ b/sitesummary-nodes @@ -70,6 +70,21 @@ sub is_pkg_installed { return undef; } +sub get_default_route { + my $hostid = shift; + my $path = get_filepath_current($hostid, "/system/route-n"); + if (open(my $fh, $path)) { + while (<$fh>) { + if (m/^0.0.0.0\s+(\S+)\s+/) { + close($fh); + return $1; + } + } + close($fh); + } + return undef; +} + sub is_munin_client { my $hostid = shift; return is_pkg_installed($hostid, "munin-node"); @@ -158,6 +173,7 @@ EOF } sub generate_nagios_config { + my %hosts; for my $hostname (sort keys %hostnames) { my $hostid = $hostnames{$hostname}; @@ -169,16 +185,29 @@ sub generate_nagios_config { # Only check laptops that have the nagios tools installed next if is_laptop($hostid) && ! $remote; + my $defaultroute = gethostbyaddr(inet_aton(get_default_route($hostid)), + AF_INET); + print <<EOF; ##################### $hostname ####################### EOF - print_nagios_host_check($hostname, $address); + print_nagios_host_check($hostname, $address) + unless (exists $hosts{$hostname}); + $hosts{$hostname} = $address; # first, check ping to see if the other checks should be performed print_nagios_service_check(0, $hostname, "ping", "check_ping", "100.0,20%!500.0,60%"); + # Also check default route host + if (defined $defaultroute && !exists $hosts{$defaultroute}) { + print_nagios_host_check($defaultroute, $defaultroute); + $hosts{$defaultroute} = $defaultroute; + print_nagios_service_check(0, $defaultroute, "ping", + "check_ping", "100.0,20%!500.0,60%"); + } + my %tcpservices = ( 139 => { name => 'samba', package => 'samba' }, |