Configure new Nagios clients
- 安装
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum install -y gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel xinetd bc
安装nagios插件
yum -y install nagios-plugins-all nagios-plugins-nrpe
nagios-plugins目录:/usr/lib64/nagios/plugins/
安装nrpe
yum -y install nrpe - 修改nrpe设置
vi /etc/nagios/nrpe.cfg
only_from = 127.0.0.1,Server_IP - 修改防火墙设置
添加5666端口,重启iptables - 修改services服务
vi /etc/services
添加
nrpe 5666/tcp # NRPE
service xinetd restart - 测试nrpe是否安装成功
cd /usr/lib64/nagios/plugins/
./check_nrpe -H 127.0.0.1
若提示失败,可能是nrpe未安装或nrpe.cfg配置文件设置错误导致 - 修改nrpe.cfg
vi /etc/nagios/nrpe.cfg
注释掉目录不存在的nagios插件命令
#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 20% -c 10% -p /dev/hda1 #command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z #command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200 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_sda1]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1 command[check_zombie_procs]=/usr/lib64/nagios/plugins/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200
测试命令是否能够执行
cd /usr/lib64/nagios/plugins/
./check_nrpe -H 127.0.0.1 -c check_users
./check_nrpe -H 127.0.0.1 -c check_load
./check_nrpe -H 127.0.0.1 -c check_sda1
./check_nrpe -H 127.0.0.1 -c check_zombie_procs
./check_nrpe -H 127.0.0.1 -c check_total_procs - 配置Nagios监控端服务器
cd /usr/lib64/nagios/plugins/
./check_nrpe -H Remote_linux_ip_address(被监控的ServerIP)
显示 NRPE v2.15 即正常
cd /etc/nagios/objects
touch hosts.cfg touch services.cfg
vi hosts.cfg 注意修改IP
## Default Linux Host Template ## define host{ name linux-box ; Name of this template use generic-host ; Inherit default values check_period 24x7 check_interval 5 retry_interval 1 max_check_attempts 10 check_command check-host-alive notification_period 24x7 notification_interval 30 notification_options d,r contact_groups admins register 0 ; DONT REGISTER THIS - ITS A TEMPLATE } ## Default define host{ use linux-box ; Inherit default values from a template host_name Nagios_Centos_Client1 ; The name we're giving to this server alias CentOS 6 ; A longer name for the server address remote_linux_ip_address ; IP address of Remote Linux host }
vi services.cfg
define service{ use generic-service host_name Nagios_Centos_Client1 service_description CPU Load check_command check_nrpe!check_load } define service{ use generic-service host_name Nagios_Centos_Client1 service_description Total Processes check_command check_nrpe!check_total_procs } define service{ use generic-service host_name Nagios_Centos_Client1 service_description Current Users check_command check_nrpe!check_users } define service{ use generic-service host_name Nagios_Centos_Client1 service_description Disk Monitoring check_command check_nrpe!check_sda1 } define service{ use generic-service host_name Nagios_Centos_Client1 service_description Zombie Monitoring check_command check_nrpe!check_zombie_procs }
修改nagios.cfg
vi /etc/nagios/nagios.cfg 添加如下两行配置
cfg_file=/etc/nagios/objects/services.cfg
cfg_file=/etc/nagios/objects/hosts.cfg
修改command.cfg
vi /etc/nagios/objects/commamds.cfg 添加define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }
检验nagios的配置是否正常
cd /etc/nagios
nagios -v nagios.cfg
提示没有错误,重启nagios即可 - 参考文档:http://www.tecmint.com/how-to-add-linux-host-to-nagios-monitoring-server/
- 官方nrpe下载地址
打开:http://sourceforge.net/projects/nagios/files/nrpe-2.x/
wget http://liquidtelecom.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
Learn how to learn~~