Installation & Configuration of Nagios & Nagios Client (NRPE) on CentOS 5
Installation
Add RPMForge Yum Repository
It is recommended that you configure yum-priorities prior to following this tutorial to avoid having base CentOS packages being overwritten by the RPMForge repository. Instructions to do so can be found on the CentOS Wiki.
Before starting any configuration make it a habit to backup all configuration files. This will save us a lot of time in troubleshooting. Having a backup will also allow us to restore the most recent configuration to the system. We can also make the backup configuration as a future reference in case we need something :
[mylogin@hostname nagios]# cd /etc
[mylogin@hostname nagios]# cp -frp nagios nagios.backup-<date>
[mylogin@hostname nagios]# cp -rf /etc/nagios/objects/localhost.cfg /etc/nagios/objects/server1.cfg
[mylogin@hostname nagios]# chown -R nagios:nagios server1.cfg
[mylogin@hostname nagios]# nano /etc/nagios/objects/server1.cfg
Your Configuration will be like this . Now save that config.
[mylogin@hostname nagios]#service nagios restart
[mylogin@hostname nagios]# chkconfig nagios on
[mylogin@hostname nagios]# service nrpe restart
[mylogin@hostname nagios]# chkconfig nrpe on
[mylogin@hostname nagios]# nagios -v /etc/nagios/nagios.cfg
Nagios Client Configuration
[mylogin@hostname nagios]# nano /etc/nagios/nrpe.cfg
change server_address=127.0.0.1 to your nagios server ip
[mylogin@hostname nagios]# service nagios restart
[mylogin@hostname nagios]# chkconfig nagios on
[mylogin@hostname nagios]# service nrpe restart
[mylogin@hostname nagios]# chkconfig nrpe on
Installation
Add RPMForge Yum Repository
It is recommended that you configure yum-priorities prior to following this tutorial to avoid having base CentOS packages being overwritten by the RPMForge repository. Instructions to do so can be found on the CentOS Wiki.
- For x86 (32-bit) systems
- For x64 (64-bit) systems
- Install Apache
- yum install httpd php gcc glibc glibc-common gd gd-devel
- Configure Apache to start on boot
- chkconfig httpd on
- Configure iptables to allow Apache traffic
- /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
- /etc/init.d/iptables save
- /etc/init.d/iptables restart
- Install Nagios (Server Side)
[mylogin@hostname nagios]# yum install nagios nagios-plugins nagios-plugins-nrpe nagios-devel - Install Nagios (Client Side)
- Create the default Nagios web access user & set a password
- htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
- Verify default config files
- nagios -v /etc/nagios/nagios.cfg
- Start Nagios
- /etc/init.d/nagios start
- Start Apache
- /etc/init.d/httpd start
- Try logging into your new Nagios installation by going to http://YourIpAddress/nagios/ and logging in with nagiosadmin and the password you set.
Before starting any configuration make it a habit to backup all configuration files. This will save us a lot of time in troubleshooting. Having a backup will also allow us to restore the most recent configuration to the system. We can also make the backup configuration as a future reference in case we need something :
[mylogin@hostname nagios]# cd /etc
[mylogin@hostname nagios]# cp -frp nagios nagios.backup-<date>
[mylogin@hostname nagios]# cp -rf /etc/nagios/objects/localhost.cfg /etc/nagios/objects/server1.cfg
[mylogin@hostname nagios]# chown -R nagios:nagios server1.cfg
[mylogin@hostname nagios]# nano /etc/nagios/objects/server1.cfg
Code:
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name server1
alias server1
address your client server ip
}
define hostgroup{
hostgroup_name server1-servers ; The name of the hostgroup
alias server1 Servers ; Long name of the group
members server1 ; Comma separated list of hosts that belong to this group
}
define service{
use local-service ; Name of service template to use
host_name server1
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use local-service ; Name of service template to use
host_name server1
service_description Root Partition
check_command check_local_disk!20%!10%!/
}
define service{
use local-service ; Name of service template to use
host_name server1
service_description Current Users
check_command check_local_users!20!50
}
define service{
use local-service ; Name of service template to use
host_name server1
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
}
# Define a service to check the load on the local machine.
define service{
use local-service ; Name of service template to use
host_name server1
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
define service{
use local-service ; Name of service template to use
host_name server1
service_description Swap Usage
check_command check_local_swap!20!10
}
define service{
use local-service ; Name of service template to use
host_name server1
service_description SSH
check_command check_ssh
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name server1
service_description HTTP
check_command check_http
notifications_enabled 0
}
[mylogin@hostname nagios]# chkconfig nagios on
[mylogin@hostname nagios]# service nrpe restart
[mylogin@hostname nagios]# chkconfig nrpe on
[mylogin@hostname nagios]# nagios -v /etc/nagios/nagios.cfg
Nagios Client Configuration
[mylogin@hostname nagios]# nano /etc/nagios/nrpe.cfg
change server_address=127.0.0.1 to your nagios server ip
[mylogin@hostname nagios]# service nagios restart
[mylogin@hostname nagios]# chkconfig nagios on
[mylogin@hostname nagios]# service nrpe restart
[mylogin@hostname nagios]# chkconfig nrpe on
Last edited: