Environment: centos6.2
1. Download and install the Epel package
Links Http://fedoraproject.org/wiki/EPEL
2. Installing Nagios and plugins
Yum Install Nagios Nagios-nrpe nagios-plugins*-y
3. Start httpd
Service httpd Start;chkconfig httpd on
4. Create an administrative user
HTPASSWD-CM/ETC/NAGIOS/PASSWD user1
5. Change the default administrative user name
Vim/etc/nagios/cgi.cfg
:%s/nagiosadmin/user1/g
6. Configuring Nagios and Pnp4nagios
6.1. Vim/etc/nagios/nagios.cfg
Process_performance_data=0//0 changed to 1
Host_perfdata_command=process-host-perfdata//Remove annotations
Service_perfdata_command=process-service-perfdata//Remove annotations
6.2. Vim/etc/nagios/objects/commands.cfg
define command{
command_name Process-host-perfdata
Command_line /usr/bin/perl/usr/libexec/pnp4nagios/process_perfdata.pl-d Hostperfdata
}
Define Command{
Command_name Process-service-perfdata
command_line/user/bin/perl/usr/libexec/pnp4nagios/process_perfdata.pl
}
6.3. Vim/etc/nagios/objects/templates.cfg
Define Host{
Name Host-pnp
action_url/pnp4nagios/graph?host= $HOSTNAME $&srv=_host_
Register 0
Process_perf_data 1
}
Define Service{
Name Service-pnp
action_url/pnp4nagios/graph?host= $HOSTNAME $&srv= $SERVICEDESC $
Register 0
Process_perf_data 1
}
6.4. cd/etc/nagios/objects///default Localhost.cfg file contains configuration for native and native services
Vim Hosts.cfg//New host configuration file Hosts.cfg
Define Host{
Use Linux-server,host-pnp
HOST_NAME localhost
Alias localhost
Address 127.0.0.1
}
Define Hostgroup{
Hostgroup_name linux-servers
Alias Linux Servers
Members localhost
}
Vim Services.cfg//New host's service configuration file
Define Service{
Use Local-service,service-pnp
HOST_NAME localhost
Service_description PING
Check_command check_ping!100.0,20%!500.0,60%
}
6.5. vim/etc/nagios/nagios.cfg//Add the following 2 lines
Cfg_file=/etc/nagios/objects/hosts.cfg
Cfg_file=/etc/nagios/objects/services.cfg
6.6. Vim/etc/nagios/cgi.cfg
#default_user_name =guest//Remove annotations, modify to Nagios manage user userr1
Default_user_name=user1
7. Start the Nagios service
Service NPCD Start;chkconfig NPCD on
Service Nagios Start;chkconfig Nagios on
This article is from "Wei Bao Jia" blog, please make sure to keep this source http://zengbaobao.blog.51cto.com/2672985/1438075