Nagios 用戶端簡單安裝

來源:互聯網
上載者:User

標籤:nagios用戶端簡單安裝

安裝nagios 用戶端


用戶端僅僅需要安裝下面內容

Class-Accessor-0.31.tar.gz

Config-Tiny-2.12.tar.gz

Math-Calc-Units-1.07.tar.gz

Nagios-Plugin-0.34.tar.gz

Params-Validate-0.91.tar.gz

Regexp-Common-2010010201.tar.gz

check_iostat

check_memory.pl

nrpe-2.12.tar.gz


第一步:修改YUM源碼

cd /etc/yum.repos.d/

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo


第二步:調整字元集

echo ‘export LC_ALL=C‘>> /etc/profile

source /etc/profile

echo $LC_ALL

第三部:關閉防火牆

/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  #永久生效

setenforce 0    

sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/selinux/config  


第四部:時間同步

/usr/sbin/ntpdate pool.ntp.org

echo ‘#time sync‘>>/var/spool/cron/root

echo ‘*/10 * * * * /usr/sbin/ntpdate pool.ntp.org >/dev/null 2>&1‘>>/var/spool/cron/root

crontab -l


第五步:建立nagios使用者

/usr/sbin/useradd -m nagios -s /sbin/nologin


第六步:安裝nagios用戶端外掛程式

[ ! -d /home/lvnian/tools  ] &&  mkdir /home/lvnian/tools -p

cd /home/lvnian/tools


yum -y install perl-devel openssl-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


cd /home/lvnian/tools/

tar zxf nrpe-2.12.tar.gz

cd nrpe-2.12

./configure

make all

make install-plugin

make install-daemon

make install-daemon-config

cd ..

#---------------------------------------- 

cd /home/lvnian/tools/

tar zxvf Params-Validate-0.91.tar.gz 

cd Params-Validate-0.91 

perl Makefile.PL 

make  

make install 

cd .. 

#---------------------------------------- 

cd /home/lvnian/tools/

tar zxvf Class-Accessor-0.31.tar.gz

cd Class-Accessor-0.31

perl Makefile.PL

make

make install

cd ..

#---------------------------------------- 

cd /home/lvnian/tools/

tar zxvf Config-Tiny-2.12.tar.gz

cd Config-Tiny-2.12

perl Makefile.PL

make

make install

cd ..

#---------------------------------------- 

cd /home/lvnian/tools/

tar zxvf Math-Calc-Units-1.07.tar.gz

cd Math-Calc-Units-1.07

perl Makefile.PL

make

make install

cd ..

#---------------------------------------- 

cd /home/lvnian/tools/

tar zxvf Regexp-Common-2010010201.tar.gz

cd Regexp-Common-2010010201

perl Makefile.PL

make

make install

cd ..

#---------------------------------------- 

cd /home/lvnian/tools/

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

yum install dos2unix -y 

/bin/cp /home/lvnian/tools/check_memory.pl /usr/local/nagios/libexec

/bin/cp /home/lvnian/tools/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


##################################################

配置nrpe 設定檔

perl -pi -e ‘s/allowed_hosts=127.0.0.1/allowed_hosts=127.0.0.1,10.0.0.3/g‘ /usr/local/nagios/etc/nrpe.cfg 

或者 sed -i ‘s/allowed_hosts=127.0.0.1/allowed_hosts=127.0.0.1,10.0.0.3/g‘ /usr/local/nagios/etc/nrpe.cfg 

這一步的目的是,讓nagios服務端能夠到這來擷取設計


#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[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



啟動nagios 用戶端 nrpe

pkill nrpe 

sleep 2

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

echo  "#nagios nrpe process cmd by lvnian 2012-6-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 


重啟nagios  nrpe的命令:

pkill nrpe && /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d ||/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d 

netstat -lnt | grep 5666


檢查外掛程式數量

[[email protected] etc]# ls /usr/local/nagios/libexec/|wc -l

64

[[email protected] tools]# ls /usr/local/nagios/libexec/|wc -l

62


本文出自 “奮鬥吧” 部落格,請務必保留此出處http://lvnian.blog.51cto.com/7155281/1703150

Nagios 用戶端簡單安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.