sudo apt-get install nagios3 --no-install-recommends # use "--no-install-recommends" in order not to install samba packages sudo apt-get install nagios-images sudo apt-get install nsca && update-rc.d nsca enable
sudo mkdir -p /etc/nagios3/custom/{commands,hosts,services,templates}
--- nagios.cfg.orig 2012-02-15 21:10:11.000000000 +0400 +++ nagios.cfg 2012-05-17 14:40:43.734332705 +0400 @@ -55,6 +55,10 @@ #cfg_dir=/etc/nagios3/printers #cfg_dir=/etc/nagios3/switches #cfg_dir=/etc/nagios3/routers +cfg_dir=/etc/nagios3/custom/commands +cfg_dir=/etc/nagios3/custom/hosts +cfg_dir=/etc/nagios3/custom/services +cfg_dir=/etc/nagios3/custom/templates @@ -142,7 +146,8 @@ # you will have to enable this. # Values: 0 = disable commands, 1 = enable commands -check_external_commands=0 +#check_external_commands=0 +check_external_commands=1 @@ -1027,7 +1032,8 @@ # manner. # Values: 1 = enabled freshness checking, 0 = disable freshness checking -check_host_freshness=0 +#check_host_freshness=0 +check_host_freshness=1
# Change directory permissions and make the changes permanent in order to make external commands work (check /usr/share/doc/nagios3/README.Debian for more information) /etc/init.d/nagios3 stop dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3 /etc/init.d/nagios3 start
define host{ name generic-host-passive use generic-host active_checks_enabled 0 check_freshness 1 check_command return-unknown register 0 }
define service{ name generic-service-passive use generic-service active_checks_enabled 0 check_freshness 1 check_command return-unknown register 0 }
# Create htpasswd file and set a password for nagiosadmin (this information is used to access the web-interface) htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin
# Define host "server1" define host{ use generic-host-passive host_name server1 }
# Define service "Disk Space" define service{ use generic-service-passive host_name server1 service_description PING }
sudo /etc/init.d/nagios3 reload
sudo apt-get install nagios3-core sudo apt-get install nagios3-cgi --no-install-recommends # use "--no-install-recommends" in order not to install apache2 packages sudo apt-get install nsca
sudo rename 's/$/.disabled/' /etc/nagios3/conf.d/{extinfo_nagios2,hostgroups_nagios2,localhost_nagios2,services_nagios2}.cfg
--- nagios.cfg.orig 2011-06-07 17:08:33.000000000 +0400 +++ nagios.cfg 2012-05-18 14:57:29.343833057 +0400 @@ -55,6 +55,9 @@ #cfg_dir=/etc/nagios3/printers #cfg_dir=/etc/nagios3/switches #cfg_dir=/etc/nagios3/routers +cfg_dir=/etc/nagios3/commands +cfg_dir=/etc/nagios3/hosts +cfg_dir=/etc/nagios3/services @@ -808,7 +811,8 @@ # service notifications when it is initially (re)started. # Values: 1 = enable notifications, 0 = disable notifications -enable_notifications=1 +#enable_notifications=1 +enable_notifications=0 @@ -913,7 +917,8 @@ # implementing distributed monitoring. # Values: 1 = obsess over services, 0 = do not obsess (default) -obsess_over_services=0 +#obsess_over_services=0 +obsess_over_services=1 @@ -926,6 +931,7 @@ # more information on implementing distributed monitoring. #ocsp_command=somecommand +ocsp_command=submit_check_result_via_nsca_service @@ -937,7 +943,8 @@ # implementing distributed monitoring. # Values: 1 = obsess over hosts, 0 = do not obsess (default) -obsess_over_hosts=0 +#obsess_over_hosts=0 +obsess_over_hosts=1 @@ -950,6 +957,7 @@ # more information on implementing distributed monitoring. #ochp_command=somecommand +ochp_command=submit_check_result_via_nsca_host
--- resource.cfg.orig 2011-06-07 17:07:47.000000000 +0400 +++ resource.cfg 2012-05-12 17:39:46.125679961 +0400 @@ -24,7 +24,7 @@ $USER1$=/usr/lib/nagios/plugins # Sets $USER2$ to be the path to event handlers -#$USER2$=/usr/lib/nagios/plugins/eventhandlers +$USER2$=/usr/share/nagios3/plugins/eventhandlers # Store some usernames and passwords (hidden from the CGIs) #$USER3$=someuser
define command{ command_name submit_check_result_via_nsca_host command_line $USER2$/distributed-monitoring/submit_check_result_via_nsca $HOSTNAME$ $HOSTSTATEID$ '$HOSTOUTPUT$|$HOSTPERFDATA$' }
define command{ command_name submit_check_result_via_nsca_service command_line $USER2$/distributed-monitoring/submit_check_result_via_nsca $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATEID$ '$SERVICEOUTPUT$|$SERVICEPERFDATA$' }
define host{ use generic-host host_name server1 address 127.0.0.1 }
define service { use generic-service service_description PING check_command check_ping!100.0,20%!500.0,60% host_name server1 }
sudo /etc/init.d/nagios3 reload