扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
-------------------------------Monitoring Client-------------------------------
成都创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站设计、成都做网站、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的平南网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!Add username for nagios system:
[root@FTP backup]# useradd -s /sbin/nologin nagios
Install the necessary plug-ins:
[root@FTP backup]# tar -xzf nagios-plugins-1.4.16.tar.gz
[root@FTP backup]# cd nagios-plugins-1.4.16
[root@FTP nagios-plugins-1.4.16]# ./configure --sysconfdir=/etc/nagios \
> --with-nagios-user=nagios \
> --with-nagios-group=nagios \
> --prefix=/usr/local/nagios
[root@FTP nagios-plugins-1.4.16]# make
[root@FTP nagios-plugins-1.4.16]# make install
Install the NRPE plugin:
[root@FTP backup]# tar -xzf nrpe-2.12.tar.gz
[root@FTP backup]# cd nrpe-2.12
[root@FTP nrpe-2.12]# ./configure --sysconfdir=/etc/nrpe \
> --with-nrpe-user=nagios \
> --with-nrpe-group=nagios \
> --with-nagios-user=nagios \
> --with-nagios-group=nagios \
> --enable-command-args \
> --enable-ssl
[root@FTP nrpe-2.12]# make all
[root@FTP nrpe-2.12]# make install
[root@FTP nrpe-2.12]# make install-daemon-config
Configure the service port number file:
[root@FTP nrpe-2.12]# vi /etc/services
#Add by Kingcraft nrpe 5666/tcp # NRPE
Configuring the NRPE configuration file:
[root@FTP nrpe-2.12]# vi /etc/nrpe/nrpe.cfg
#Add by Kingcraft server_address=172.17.3.98 allowed_hosts=172.17.3.4 command[check_procs]=/usr/local/nagios/customexec/check_procs.sh -a python -w 3 -c 6
Monitoring plugin:
[root@FTP nrpe-2.12]# mkdir /usr/local/nagios/customexec
[root@FTP nrpe-2.12]# vi /usr/local/nagios/customexec/check_procs.sh
#!/bin/sh #Author:zhai_kang,20131024 COUNT=`ps -ef | grep -v grep | grep $2 | wc -l` PROC=`expr $COUNT - 2` if [[ $PROC -ge $6 ]] then line=`echo "Critical - PROC=$PROC"` RC=2 elif [[ $PROC -ge $4 ]] then line=`echo "Warning - PROC=$PROC"` RC=1 elif [[ $PROC -ge 1 ]] then line=`echo "OK - PROC=$PROC"` RC=0 else line=`echo "Unknown - PROC=null"` RC=3 fi echo $line \| proc=$PROC exit $RC
[root@FTP nrpe-2.12]# chown -R nagios:nagios /usr/local/nagios/customexec/
[root@FTP nrpe-2.12]# chmod +x /usr/local/nagios/customexec/*
Start the nrpe service:
[root@FTP nrpe-2.12]# /usr/local/nagios/bin/nrpe -c /etc/nrpe/nrpe.cfg -d
-------------------------------Monitoring Server-------------------------------
Install the NRPE plugin:
[root@RHEL5 backup]# tar -xzf nrpe-2.12.tar.gz
[root@RHEL5 backup]# cd nrpe-2.12
[root@RHEL5 nrpe-2.12]# ./configure --sysconfdir=/etc/nrpe \
> --with-nrpe-user=nagios \
> --with-nrpe-group=nagios \
> --with-nagios-user=nagios \
> --with-nagios-group=nagios \
> --enable-command-args \
> --enable-ssl
[root@RHEL5 nrpe-2.12]# make all
[root@RHEL5 nrpe-2.12]# make install-plugin
Define the monitoring command:
[root@RHEL5 nrpe-2.12]# cd /etc/nagios/objects/
[root@RHEL5 nrpe-2.12]# vi commands.cfg
#Add by Kingcraft define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }
Definition monitor file:
[root@RHEL5 objects]# vi /etc/nagios/Linuxhosts/CSV.cfg
#Add by Kingcraft define host{ use linux-server,host-pnp host_name CSV alias CSV address 172.17.3.98 } define service{ use local-service,srv-pnp host_name CSV service_description check_procs check_command check_nrpe!check_procs }
Empowering for monitoring files:
[root@RHEL5 objects]# chown nagios:nagios /etc/nagios/Linuxhosts/*
Modify the nagios configuration file:
[root@RHEL5 objects]# vi /etc/nagios/nagios.cfg
#Add by Kingcraft cfg_dir=/etc/nagios/Linuxhosts
Syntax checking:
[root@RHEL5 objects]# /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg
restart nagios:
[root@RHEL5 objects]# service nagios restart
Verification:
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流