2343图2 发表于 2016-12-28 10:54:41

nagios监控的安装

一.服务端的安装
所需的安装包:http://pan.baidu.com/s/1dFKaM8D
环境:centos7IP:192.168.217.131

(1)step 1:install gcc and lamp env etcyum install gccglibc glibc-common -yyum install gdgd-devel -yyum installhttpd php php-gd -yyum installmysql* -y
(2) step 2:add nagiosuser and group/usr/sbin/useradd-m nagios#/usr/sbin/useraddapache/usr/sbin/groupaddnagcmd/usr/sbin/usermod-a -G nagcmd nagios/usr/sbin/usermod-a -G nagcmd apache
(3)step 3:download and install nagiosunzipoldboy_training_nagios_soft.ziptar xzfnagios-3.5.1.tar.gzcd nagios./configure 【--with-group=nagios --with-user=nagios】--with-command-group=nagcmdmake allmake installmakeinstall-initmakeinstall-configmakeinstall-commandmodemakeinstall-webconf          #出现404,说明没执行这个(4)step 4:config web authhtpasswd -cb/usr/local/nagios/etc/htpasswd.users tong 123456 //用户认证,登录nagios
(5) step 5:install nagios-pluginsyum -y installperl-develtar zxfnagios-plugins-2.1.1.tar.gzcdnagios-plugins-2.1.1./configure--with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modulesmake &&make installls /usr/local/nagios/libexec/|wc-l   看有几个
(6)step 6:install nrpetar zxvfnrpe-2.12.tar.gzcd nrpe-2.12./configuremake allmakeinstall-pluginmakeinstall-daemonmakeinstall-daemon-config
(7)step 7:startup service and check/etc/init.d/nagios startservice httpd startecho -----------lsof -i tcp:80echo ----------ps -ef|grepnagios   没进程就iptables -Fecho"NAGIOS is successfully installed."echo ok我的访问地址:http://192.168.217.131/nagios/

二.客户端的安装
环境:centos7   IP:192.168.217.137

(1)step 1: add nagios user#useradd -mnagios -s /sbin/nologin
(2)step 2: install nagios-plugins   yum -y install perl-develtar zxfnagios-plugins-2.1.1.tar.gzcdnagios-plugins-2.1.1./configure--prefix=/usr/local/nagios --enable-perl-modules --enable-redhat-pthread-workaroundmake &&make installls/usr/local/nagios/libexec/|wc -l
(3)step 3: install nrpe   tar zxfnrpe-2.12.tar.gzcd nrpe-2.12./configuremake allmakeinstall-pluginmakeinstall-daemonmakeinstall-daemon-config
(4)step 4: install soft for iostat    tar zxvfParams-Validate-0.91.tar.gzcdParams-Validate-0.91perl Makefile.PLmake make install#----------------------------------------tar zxvfClass-Accessor-0.31.tar.gzcdClass-Accessor-0.31perl Makefile.PLmakemake install#----------------------------------------tar zxvfConfig-Tiny-2.12.tar.gzcd Config-Tiny-2.12perl Makefile.PLmakemake install#----------------------------------------tar zxvfMath-Calc-Units-1.07.tar.gzcdMath-Calc-Units-1.07perl Makefile.PLmakemake install#----------------------------------------tar zxvfRegexp-Common-2010010201.tar.gzcdRegexp-Common-2010010201perl Makefile.PLmakemake install#----------------------------------------tar zxvfNagios-Plugin-0.34.tar.gzcdNagios-Plugin-0.34perl Makefile.PLmakemake install#______________________#for monitoriostatyum installsysstat -y【check_memory.pl安装包有】/bin/cp/home/oldboy/tools/check_memory.pl /usr/local/nagios/libexec/bin/cp/home/oldboy/tools/check_iostat /usr/local/nagios/libexec
chmod 755/usr/local/nagios/libexec/check_memory.plchmod 755/usr/local/nagios/libexec/check_iostat
yum install -ydos2unixdos2unix/usr/local/nagios/libexec/check_memory.pldos2unix/usr/local/nagios/libexec/check_iostatls/usr/local/nagios/libexec/|wc -l   插件数量
(5)step 5: 修改nrpe.cfgcd/usr/local/nagios/etc/#配置文件路径#cp nrpe.cfgnrpe.cfg.bk   备份#vim nrpe.cfg+79perl -pi -e 's/allowed_hosts=127.0.0.1/
【allowed_hosts=127.0.0.1,192.168.217.131(服务端)】/g'#delete 199--203【删掉的行】cp/usr/local/nagios/etc/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg.ori #复制sed -i'199,203d' /usr/local/nagios/etc/nrpe.cfg
echo"command=/usr/local/nagios/libexec/check_load -w 15,10,6-c30,25,20">>/usr/local/nagios/etc/nrpe.cfg
echo"command=/usr/local/nagios/libexec/check_memory.pl -w 6%-c3%">>/usr/local/nagios/etc/nrpe.cfg
echo"command=/usr/local/nagios/libexec/check_disk -w 20% -c8% -p/">>/usr/local/nagios/etc/nrpe.cfg
echo"command=/usr/local/nagios/libexec/check_swap -w 20% -c10%">>/usr/local/nagios/etc/nrpe.cfg
echo"command=/usr/local/nagios/libexec/check_iostat -w 6-c10">>/usr/local/nagios/etc/nrpe.cfg(6)step 6: start nagios client#start nagiosclientpkill nrpesleep 2#/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d #启动
#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"

muzisheng 发表于 2017-2-17 09:06:05

学习了

muzisheng 发表于 2017-2-17 09:06:16

学习了
页: [1]
查看完整版本: nagios监控的安装