# 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表示脚本的行数,此命令是把shell后面的gz文件提出来。 sed -n -e '1,/^exit 0$/!p' $0 > ${dir}/packages.tar.gz 2>/dev/null #跟上面一个意思,这个是从第一行到"exit 0"这行结束提出来。 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 #脚本执行完需要退出,不然会重复执行,此处很重要。。。3.然后封装成bin文件
# cat install_nagios_client.sh packages.tar.gz >nagios.bin # chmod +x nagios.bin # ./nagios.bin
4.验证是否正常运行
# 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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。