Main Page/Nagios add Indirect Host and Service Checks: Difference between revisions
| Line 159: | Line 159: | ||
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg | /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg | ||
Reload nagios | Reload nagios | ||
/etc/init.d/nagios reload | /etc/init.d/nagios reload | ||
Latest revision as of 19:58, 30 October 2013
File:/root/Desktop/indirectsvccheck converted.jpg
Headline text[edit]
NAGIOS INDIRECT MAPPING OF HOSTS
For Environments that have multiple servers and only one server or firewall is accessible directly i.e one server is accessible and all others may be accessed through it internally . Nagios mapping may be done via Indirect Host and Service Checks using nrpe.
Indirect checks are useful for: Monitoring "local" resources (such as disk usage, processer load, etc.) on remote hosts
Monitoring services and hosts behind firewalls
Obtaining more realistic results from checks of time-sensitive services between remote hosts (i.e. ping response times between two remote hosts)
Indirect service check Senario :
As in 2coms there is a backup server associated with the main server indirectly accessible via the mailserver
Access IP : zimbraserver.2coms.com/115.248.160.99
Mailserver Internal Ip : 192.168.1.3 ( primary server)
Backup server Ip :`192.168.1.5 (secondary server)
Procedure Taken :[edit]
on directly accessible ( primary ) server :[edit]
1. Access mail-server ( server already mapped as directly accesible )
2. Install check_nrpe plugin if not present
- yum install nagios-plugins-nrpe
3. now add entry in nrpe.cfg for each service you want to check on the secondary/passive server as shown below :
COMMANDS FOR MAIN SERVER
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 7% -c 5% -p /dev/sda3
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_cpu]=/usr/local/nagios/libexec/check_cpu.sh -w 60 -c 70
command[check_mem]=/usr/local/nagios/libexec/check_mem_avail -w 130 -c 150
command[check_clam]=/usr/local/nagios/libexec/check_clamd -H localhost
command[check_queue]=/usr/local/nagios/libexec/check_postfix_queue -w 300 -c 500
command[check_zimbra_clam_ud]=sudo -u zimbra /usr/local/nagios/libexec/check_clamav -w 2 -c 5
command[check_zimbra_lmtp]=/usr/local/nagios/libexec/check_smtp -H localhost -p 7025 -e '220 zimbraserver.2coms.com Zimbra LMTP server ready'
# following commands are for backup server 192.168.1.5
command[check_users2]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_users
command[check_load2]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_load
command[check_hda12]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_hda1
command[check_hda22]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_hda2
command[check_hda32]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_hda3
command[check_zombie_procs2]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_zombie_procs
command[check_cpu2]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_cpu
command[check_mem2]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_mem
command[check_clam2]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_clam
command[check_queue2]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_queue
command[check_zimbra_lmtp2]=/usr/local/nagios/libexec/check_nrpe -H 192.168.1.5 -c check_zimbra_lmtp
on Secondary ( Backup ) server :[edit]
Install nrpe and nagios plugins :
# yum install nrpe nagios-plugins-all
edit nrpe.cfg as follows :
allowed_hosts=127.0.0.1,192.168.1.3
And also add plugin definition as :
command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10
command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/lib64/nagios/plugins/check_disk -w 7% -c 5% -p /dev/hda3
command[check_hda2]=/usr/lib64/nagios/plugins/check_disk -w 7% -c 5% -p /dev/hda1
command[check_hda3]=/usr/lib64/nagios/plugins/check_disk -w 10% -c 5% -p /dev/sda1
command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z
command[check_cpu]=/usr/lib64/nagios/plugins/check_cpu.sh -w 60 -c 70
command[check_mem]=/usr/lib64/nagios/plugins/check_mem_avail -w 130 -c 150
command[check_clam]=/usr/lib64/nagios/plugins/check_clamd -H localhost
command[check_queue]=/usr/lib64/nagios/plugins/check_postfix_queue -w 300 -c 500
Restart nrpe on this server
Restart nrpe on Primary server
On Nagios Server :[edit]
Add Host entry in /usr/local/nagios/etc/objects/linux-box.cfg with Access Ip :
Entries for Primary Server :
define host{
use linux-server
host_name zimbraserver.2coms.com
alias zimbraserver.2coms.com
address 182.71.172.155
hostgroups Tetra Clients ; Host groups
}
Entries for Secondary Server :
define host{
use linux-server
host_name backupserver.2coms.com
alias backupserver.2coms.com
address 182.71.172.155
hostgroups Tetra Clients ; Host groups
}
Note : address field is same for both host
add service definition in /usr/local/nagios/etc/service/backupserver.2coms.com.cfg for all services already defined in nrpe.cfg on primary host
eg :
define service{
use generic-service
host_name backupserver.2coms.com
service_description Current Users
check_command check_nrpe!check_users2
}
check nagios configuration /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Reload nagios /etc/init.d/nagios reload