diff options
-rw-r--r-- | nagios-templates.cfg | 5 | ||||
-rwxr-xr-x | sitesummary-nodes | 37 |
2 files changed, 29 insertions, 13 deletions
diff --git a/nagios-templates.cfg b/nagios-templates.cfg index 9732e8e..766cee6 100644 --- a/nagios-templates.cfg +++ b/nagios-templates.cfg @@ -156,3 +156,8 @@ define command{ command_name check-host-alive command_line /usr/lib/nagios/plugins/check_ping -H $HOSTADDRESS$ -w 5000,100% -c 5000,100% -p 1 } + +define command{ + command_name check_nrpe + command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ +} diff --git a/sitesummary-nodes b/sitesummary-nodes index 0f1b5f3..153084e 100755 --- a/sitesummary-nodes +++ b/sitesummary-nodes @@ -105,6 +105,14 @@ sub print_ip_hw_list { } } +sub is_remote_nagios_client { + my $hostid = shift; + return is_pkg_installed($hostid, "nagios-nrpe-server") && ! + (is_pkg_installed($hostid, "nagios-text") || + is_pkg_installed($hostid, "nagios2") || + is_pkg_installed($hostid, "nagios3")); +} + sub generate_nagios_config { for my $hostname (sort keys %hostnames) { my $hostid = $hostnames{$hostname}; @@ -112,6 +120,9 @@ sub generate_nagios_config { my $address = get_dns_address($hostid); + my $redirect = ""; + $redirect = "check_nrpe!" if is_remote_nagios_client($hostid); + # first, check ping to see if the other checks should be performed print <<EOF; ##################### $hostname ####################### @@ -130,13 +141,13 @@ define service { use server-service host_name $hostname service_description swap - check_command check_swap!10%!5% + check_command ${redirect}check_swap!10%!5% } define service { use server-service host_name $hostname service_description zombie procs - check_command check_procs_zombie!20!100 + check_command ${redirect}check_procs_zombie!20!100 } EOF @@ -171,7 +182,7 @@ define service { use server-service host_name $hostname service_description disk $partition - check_command check_disk!$warn%!$crit%!$partition + check_command ${redirect}check_disk!$warn%!$crit%!$partition } EOF } @@ -197,7 +208,7 @@ define service { use server-service host_name $hostname service_description $servicename - check_command check_tcp!$port + check_command ${redirect}check_tcp!$port } EOF } @@ -208,7 +219,7 @@ define service { use server-service host_name $hostname service_description sw-raid - check_command check_linux_raid + check_command ${redirect}check_linux_raid } EOF } @@ -225,7 +236,7 @@ define service { use server-service host_name $hostname service_description dns - check_command check_dns + check_command ${redirect}check_dns } EOF # Check IMAPS server @@ -234,7 +245,7 @@ define service { use server-service host_name $hostname service_description imaps - check_command check_imaps + check_command ${redirect}check_imaps } EOF # Check NFS server @@ -243,7 +254,7 @@ define service { use server-service host_name $hostname service_description nfs - check_command check_nfs + check_command ${redirect}check_nfs } EOF # Check Squid web proxy @@ -252,7 +263,7 @@ define service { use server-service host_name $hostname service_description squid - check_command check_squid!3128!http://www + check_command ${redirect}check_squid!3128!http://www } EOF @@ -262,7 +273,7 @@ define service { use server-service host_name $hostname service_description ssh - check_command check_ssh + check_command ${redirect}check_ssh } EOF print <<EOF if (is_pkg_installed($hostid, "apache") || is_pkg_installed($hostid, "apache2")); @@ -270,7 +281,7 @@ define service { use server-service host_name $hostname service_description http - check_command check_http + check_command ${redirect}check_http } EOF @@ -279,7 +290,7 @@ define service { use server-service host_name $hostname service_description ntp time server - check_command check_ntp!-H!localhost + check_command ${redirect}check_ntp!-H!localhost } EOF # Check unix load @@ -288,7 +299,7 @@ define service { use server-service host_name $hostname service_description load as in top - check_command check_load!75,75,75!90,90,90 + check_command ${redirect}check_load!75,75,75!90,90,90 } EOF } |