一.服務(wù)端的安裝
目前創(chuàng)新互聯(lián)已為數(shù)千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、雅安服務(wù)器托管、網(wǎng)站改版維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、莊浪網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶(hù)導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶(hù)和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。所需的安裝包:http://pan.baidu.com/s/1dFKaM8D
環(huán)境:centos7 IP:192.168.217.131
(1) step 1:install gcc and lamp env etc
yum install gccglibc glibc-common -y
yum install gdgd-devel -y
yum installhttpd php php-gd -y
yum installmysql* -y
(2) step 2:add nagios user 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 nagios
unzipoldboy_training_nagios_soft.zip
tar xzfnagios-3.5.1.tar.gz
cd nagios
./configure 【--with-group=nagios --with-user=nagios
】--with-command-group=nagcmd
make all
make install
makeinstall-init
makeinstall-config
makeinstall-commandmode
makeinstall-webconf #出現(xiàn)404,說(shuō)明沒(méi)執(zhí)行這個(gè)
(4) step 4:config web auth
htpasswd -cb/usr/local/nagios/etc/htpasswd.users tong 123456 //用戶(hù)認(rèn)證,登錄nagios
(5) step 5:install nagios-plugins
yum -y installperl-devel
tar zxfnagios-plugins-2.1.1.tar.gz
cdnagios-plugins-2.1.1
./configure--with-nagios-user=nagios --with-nagios-group=nagios --
enable-perl-modules
make &&make install
ls /usr/local/nagios/libexec/|wc-l 看有幾個(gè)
(6) step 6:install nrpe
tar zxvfnrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
makeinstall-plugin
makeinstall-daemon
makeinstall-daemon-config
(7) step 7:startup service and check
/etc/init.d/nagios start
service httpd start
echo -----------
lsof -i tcp:80
echo ----------
ps -ef|grepnagios 沒(méi)進(jìn)程就iptables -F
echo"NAGIOS is successfully installed."
echo ok
我的訪問(wèn)地址:http://192.168.217.131/nagios/
二.客戶(hù)端的安裝
環(huán)境: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-devel
tar zxfnagios-plugins-2.1.1.tar.gz
cdnagios-plugins-2.1.1
./configure--prefix=/usr/local/nagios --enable-perl-modules --enable-redhat-pthread-workaround
make &&make install
ls/usr/local/nagios/libexec/|wc -l
(3) step 3: install nrpe
tar zxfnrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
makeinstall-plugin
makeinstall-daemon
makeinstall-daemon-config
(4) step 4: install soft for iostat
tar zxvfParams-Validate-0.91.tar.gz
cdParams-Validate-0.91
perl Makefile.PL
make
make install
#----------------------------------------
tar zxvfClass-Accessor-0.31.tar.gz
cdClass-Accessor-0.31
perl Makefile.PL
make
make install
#----------------------------------------
tar zxvfConfig-Tiny-2.12.tar.gz
cd Config-Tiny-2.12
perl Makefile.PL
make
make install
#----------------------------------------
tar zxvfMath-Calc-Units-1.07.tar.gz
cdMath-Calc-Units-1.07
perl Makefile.PL
make
make install
#----------------------------------------
tar zxvfRegexp-Common-2010010201.tar.gz
cdRegexp-Common-2010010201
perl Makefile.PL
make
make install
#----------------------------------------
tar zxvfNagios-Plugin-0.34.tar.gz
cdNagios-Plugin-0.34
perl Makefile.PL
make
make install
#______________________
#for monitoriostat
yum 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.pl
chmod 755/usr/local/nagios/libexec/check_iostat
yum install -ydos2unix
dos2unix/usr/local/nagios/libexec/check_memory.pl
dos2unix/usr/local/nagios/libexec/check_iostat
ls/usr/local/nagios/libexec/|wc -l 插件數(shù)量
(5) step 5: 修改nrpe.cfg
cd/usr/local/nagios/etc/ #配置文件路徑
#cp nrpe.cfgnrpe.cfg.bk 備份
#vim nrpe.cfg+79
perl -pi -e 's/allowed_hosts=127.0.0.1/
【allowed_hosts=127.0.0.1,192.168.217.131(服務(wù)端)】/g'
#delete 199--203【刪掉的行】
cp/usr/local/nagios/etc/nrpe.cfg /usr/local/nagios/etc/nrpe.cfg.ori #復(fù)制
sed -i'199,203d' /usr/local/nagios/etc/nrpe.cfg
echo"command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,6
-c30,25,20">>/usr/local/nagios/etc/nrpe.cfg
echo"command[check_mem]=/usr/local/nagios/libexec/check_memory.pl -w 6%
-c3%">>/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
-c10">>/usr/local/nagios/etc/nrpe.cfg
(6) step 6: start nagios client
#start nagiosclient
pkill nrpe
sleep 2
#/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d #啟動(dòng)
#echo"/usr/local/nagios/bin/nrpe -c- /usr/local/nagios/etc/nrpe.cfg -
d">>/etc/rc.local 開(kāi)機(jī)自動(dòng)啟動(dòng)
#netstat-lnt|grep 5666 && echo "nagios client is ok"
三.登錄驗(yàn)證:
由于沒(méi)有啟動(dòng)客戶(hù)端的機(jī)器,所以只能看到服務(wù)器的機(jī)器up
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。