Environment: Redhat Enterprise Linux 5 or CentOS 5
Objective: Some tips to make Nagios configuration easier
Steps:
1. setting up monitor host (localhost) first
2. Follow Nagios website PDF document for NRPE to configure monitored host
note:
Install Nagios plugin and NRPE, add monitor host ip into /etc/xinetd.d/nrpe as follows:
only_from = 127.0.0.1 10.0.0.20
use 'chkconfig xinetd on' command to make xinetd auto restart then 'service xinetd restart'
3. Public services monitoring
From locahost which is installed Nagios core monitor host, you can add some public services for monitoring:
it's better you can use the different configuration file name for each monitored host and public service, because you can later use vi to global replace the servername and ip address easily.
in /usr/local/nagios/etc/nagios.cfg ,you can add the following to cfg_file section:
cfg_file=/usr/local/nagios/etc/objects/server1.cfg
cfg_file=/usr/local/nagios/etc/objects/server2.cfg
cfg_file=/usr/local/nagios/etc/objects/publicservices.cfg
For publicservices.cfg ,here is an example:
define service{
use generic-service
max_check_attempts 2
host_name localhost
service description tomcat on app server 1
check_command check_tomcat_app1
}
define command{
command_name check_tomcat_app1
commane_line $USER1/check_http -I ip address -u /url/jsp/index.jsp -p 8443 -S -s "Having trouble"
}
define service{
use generic-service
max_check_attempts1
host_name localhost
service description real user login test
check_command check_www
}
define command{
command_name check_www
commane_line $USER1$nagios.sh ipaddress
}
note: nagios.sh script must have return code, 0 means OK, 1 means warning, 2 means critical.
4. individual server configuration
for server1.cfg:
define host{
use generic-host
host_name server1.domain.com
max_check_attempts 2
address 1.2.3.4
}
define service {
use general-service
host_name server1.domain.com
service_description Current Load
check_command check_nrpe!check_load
define service {
use general-service
host_name server1.domain.com
service_description Current Load
check_command check_nrpe!check_usrlocal
}
on server1 nrpe.cfg, you need to define check_usrlocal and check_load(default,built-in).
For server1, you can copy from server1 then use vi to global replace server1 to server2 and change ip address.
5. Windows monitored host
install NSClient++, during installation ,in 'allowed host', type in '127.0.0.1,1.2.3.4' (1.2.3.4 is your monitor host), tick 'enable common check plugins' and 'enable NRPE server'.
After finishing installation, in c:\program files\nsclient++\nsc.ini, to uncomment out checkexternalscript.dll line so that you can use alias part.
# windows1.cfg
define host{
use generic-host
host_name windows1.domain.com
address 2.3.4.5
}
define service{
use general-service
host_name windows1.domain.com
check_command check_nrpe! -H windows1 -p 5666 -c alias_cpu
}
note: some other alias like alias_disk, alias_up, alias_service, alias_mem
6. FAQ
a.
check_http.c:807: undefined reference to `np_net_ssl_write`.
solution: make clean first, then make again.
c. how to check remote server ? (disable check-host-alive)
use check_ssh command instead:
check_command check_ssh
d. ./configure hangs for nagios-plugin on RHEL4
If you find that the configure script appears to hang on this line:
checking for redhat spopen problem...
use './configure --enable-redhat-pthread-workaround' instead