diff options
author | Petter Reinholdtsen <pere@hungry.com> | 2010-01-17 20:58:42 +0000 |
---|---|---|
committer | Petter Reinholdtsen <pere@hungry.com> | 2010-01-17 20:58:42 +0000 |
commit | 46a9d10631cfd3c56154e9b219c9518e4b288efc (patch) | |
tree | 049ba5e68f168a3bc8f806440c1fef111d4ec468 | |
parent | ed3efbfa28cfb9b28142062f5061192c4a53bfe3 (diff) | |
download | sitesummary-46a9d10631cfd3c56154e9b219c9518e4b288efc.tar.gz sitesummary-46a9d10631cfd3c56154e9b219c9518e4b288efc.tar.bz2 sitesummary-46a9d10631cfd3c56154e9b219c9518e4b288efc.tar.xz |
Make sure a ping check is generated for each hosts default route.
-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' }, |