1.改yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
2.调整字符集
echo 'export LC_ALL=C'>> /etc/profile source /etc/profile
3.关闭SELINUX,防火墙
/etc/init.d/iptables stop /etc/init.d/iptables stop chkconfig iptables off setenforce 0 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
4.时间同步
/usr/sbin/ntpdate pool.ntp.org echo '#time sync by qinzc at 2018-9-6'>>/var/spool/cron/root echo '*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1'>>/var/spool/cron/root crontab -l
5.添加Nagios用户
/usr/sbin/useradd -m nagios -s /sbin/nologin
6.解压并编译Nagios相关包
unzip oldboy_training_nagios_soft.zip
点击下载:oldboy_training_nagios_soft.zip
7.安装插件
yum -y install perl-devel //安装插件必安装 tar zxf nagios-plugins-1.4.16.tar.gz cd nagios-plugins-1.4.16 ./configure --prefix=/usr/local/nagios --enable-perl-modules --enable-redhat-pthread-workaround make && make install cd ../ ls /usr/local/nagios/libexec/|wc -l
8.安装nrpe
tar zxvf nrpe-2.12.tar.gz cd nrpe-2.12 ./configure make all make install-plugin make install-daemon make install-daemon-config cd ..
9.安装iostat插件
tar zxvf Params-Validate-0.91.tar.gz cd Params-Validate-0.91 perl Makefile.PL make make install cd .. #---------------------------------------- tar zxvf Class-Accessor-0.31.tar.gz cd Class-Accessor-0.31 perl Makefile.PL make make install cd .. #---------------------------------------- tar zxvf Config-Tiny-2.12.tar.gz cd Config-Tiny-2.12 perl Makefile.PL make make install cd .. #---------------------------------------- tar zxvf Math-Calc-Units-1.07.tar.gz cd Math-Calc-Units-1.07 perl Makefile.PL make make install cd .. #---------------------------------------- tar zxvf Regexp-Common-2010010201.tar.gz cd Regexp-Common-2010010201 perl Makefile.PL make make install cd .. #---------------------------------------- tar zxvf Nagios-Plugin-0.34.tar.gz cd Nagios-Plugin-0.34 perl Makefile.PL make make install cd .. #---------------------------------------- #for monitor iostat yum install sysstat -y //系统性能命令工具 /bin/cp ~/tools/nagios/check_memory.pl /usr/local/nagios/libexec /bin/cp ~/tools/nagios/check_iostat /usr/local/nagios/libexec chmod 755 /usr/local/nagios/libexec/check_memory.pl chmod 755 /usr/local/nagios/libexec/check_iostat dos2unix /usr/local/nagios/libexec/check_memory.pl dos2unix /usr/local/nagios/libexec/check_iostat
10.修改nrpe.cfg配置文件
vim /usr/local/nagios/etc/nrpe.cfg +79 79行增加服务端IP allowed_hosts=127.0.0.1,192.168.1.15 删除199-203行内容
添加: echo "command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,6 -c 30,25,20">>/usr/local/nagios/etc/nrpe.cfg echo "command[check_mem]=/usr/local/nagios/libexec/check_memory.pl -w 6% -c 3%">>/usr/local/nagios/etc/nrpe.cfg echo "command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 8% -p /">>/usr/local/nagios/etc/nrpe.cfg echo "command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%">>/usr/local/nagios/etc/nrpe.cfg echo "command[check_iostat]=/usr/local/nagios/libexec/check_iostat -w 6 -c 10">>/usr/local/nagios/etc/nrpe.cfg
11.开启Nagios客户端,开机自启
pkill nrpe sleep 2 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d echo "#nagios nrpe process cmd by qinzc 2018-9-7" >> /etc/rc.local echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d">>/etc/rc.local netstat -lnt|grep 5666 && echo "nagios client is ok"
至此客户端安装配置完毕
停留在世界边缘,与之惜别