您好,登錄后才能下訂單哦!
# tar zcvf packages.tar.gz nagios-plugins-1.4.16.tar.gz nrpe-2.12.tar.gz
#!/bin/bash for rpm in {automake,make,gcc,libgcc,xinetd};do rpm -q $rpm || yum install $rpm ;done dir=/tmp/install/ if [ -e $dir ];then rm -rf $dir/* else mkdir $dir fi #tail -n +30 $0 >$dir/packages.tar.gz #30表示腳本的行數(shù),此命令是把shell后面的gz文件提出來(lái)。 sed -n -e '1,/^exit 0$/!p' $0 > ${dir}/packages.tar.gz 2>/dev/null #跟上面一個(gè)意思,這個(gè)是從第一行到"exit 0"這行結(jié)束提出來(lái)。 cd $dir tar xf packages.tar.gz echo "###useradd nagios###" id nagios if [ $? -eq 0 ];then echo "user nagios was exist" ; else useradd -s /sbin/nologin nagios ; fi echo "###install nagios-plugins###" cd $dir tar xf nagios-plugins-1.4.16.tar.gz && cd nagios-plugins-1.4.16 && ./configure || echo "configure is wrong" && make && make install echo "###chown privilege for directory nagios####" chown nagios. /usr/local/nagios -R echo "###install nrpe###" cd $dir tar xf nrpe-2.12.tar.gz && cd nrpe-2.12 && ./configure || echo "configure was wrong" && make all && make install-plugin && make ins tall-daemon && make install-daemon-config && make install-xinetd echo "###change config file###" sed -i '/only_from/s/127\.0\.0\.1/127\.0\.0\.1 10\.6\.8\.200/g' /etc/xinetd.d/nrpe echo "nrpe 5666/tcp # nrpe" >> /etc/services echo "###start services###" /etc/init.d/xinetd restart && echo "xinetd services was running" || echo "xinetd services was wrong" exit 0 #腳本執(zhí)行完需要退出,不然會(huì)重復(fù)執(zhí)行,此處很重要。。。3.然后封裝成bin文件
# cat install_nagios_client.sh packages.tar.gz >nagios.bin # chmod +x nagios.bin # ./nagios.bin
4.驗(yàn)證是否正常運(yùn)行
# netstat -lutnp |grep 5666 tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 28374/xinetd # /usr/local/nagios/libexec/check_nrpe -H 10.6.1.34 NRPE v2.12
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。