diff options
Diffstat (limited to 'sitesummary-nodes')
-rwxr-xr-x | sitesummary-nodes | 31 |
1 files changed, 30 insertions, 1 deletions
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' }, |