1.服务器端环境准备yum updatechkconfig iptables offchkconfig ip6tables offvi /etc/sysconfig/selinuxSELINUX=disabledrpm -i http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-7.noarch.rpm rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-*2.软件安装yum install nagios nagios-plugins nagios-plugins-all nagios-plugins-nrpe php php-pear mod_ssl net-snmp net-snmp-utils sendmailhtpasswd /etc/nagios/passwd nagiosadminnagios -v /etc/nagios/nagios.cfgusermod -a -G nagios apachechkconfig nagios onchkconfig httpd onchkconfig sendmail onservice sendmail restartservice httpd restart

3.配置

vim /etc/nagios/nagios.cfgcfg_dir= /etc/nagios/serversvim /etc/nagios/objects/commands.cfgdefine command{command_name check_nrpecommand_line /usr/lib64/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$}mkdir /etc/nagios/serverschown root:nagios /etc/nagios/serversservice nagios restart

4.客户端软件安装

yum install nagios-plugins-nrpe nagios-plugins-all nagios-nrpe openssl

5.监控路由器

cisco2811(config)# snmp-server community gnet ROcisco2811(config)# snmp-server host 192.168.0.7 gnetcisco2811(config)# snmp-server enable traps

添加监控路由器的nagios端配置文件efine host{ use generic-switch ; Inherit default values from a template host_name cisco2811 ; The name we're giving to this switch alias cisco2811 ; A longer name associated with the switch address 192.168.1.1 ; IP address of the switch hostgroups routers ; Host groups this switch is associated with }define hostgroup{ hostgroup_name routers ; The name of the hostgroup alias Network router ; Long name of the group }define service{ use generic-service ; Inherit values from a template host_name cisco2811 ; The name of the host the service is associated with service_description PING ; The service description check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service normal_check_interval 5 ; Check the service every 5 minutes under normal conditions retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined }define service{ use generic-service ; Inherit values from a template host_name cisco2811 service_description Uptime check_command check_snmp_time! -C gnet -o sysUpTime.0 }# Monitor Port 1 status via SNMPdefine service{ use generic-service ; Inherit values from a template host_name cisco2811 service_description Port 1 Link Status check_command check_snmp_time! -C gnet -o ifOperStatus.1 -r 1 -m RFC1213-MIB }define service{use generic-servicehost_name cisco2811service_description CPUis_volatile 0check_period 24x7max_check_attempts 3retry_check_interval 1contact_groups adminsnotification_interval 120notification_period 24x7check_command check_cisco_cpu!gnet!60!69!70!80}

6被监控端nrpe配置

yum install nagios-plugins-nrpe nagios-plugins-all nagios-nrpe opensslvim /etc/nagios/nrpe.cfgallowed_hosts=127.0.0.1,192.168.0.7chown nrpe:nrpe /etc/nagios/nrpe.cfgvim /etc/servicesnrpe 5666/tcp # NRPEchkconfig nrpe on