centos6.5下制作bin文件
# tar zcvf packages.tar.gz nagios-plugins-1.4.16.tar.gz nrpe-2.12.tar.gz2.编辑安装脚本
#!/bin/bashfor rpm in {automake,make,gcc,libgcc,xinetd};do rpm -q $rpm || yum install $rpm ;donedir=/tmp/install/if [ -e $dir ];then rm -rf $dir/*else mkdir $dirfi#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 $dirtar xf packages.tar.gzecho "###useradd nagios###"id nagiosif [ $? -eq 0 ];then echo "user nagios was exist" ; else useradd -s /sbin/nologin nagios ; fiecho "###install nagios-plugins###"cd $dirtar xf nagios-plugins-1.4.16.tar.gz && cd nagios-plugins-1.4.16 && ./configure || echo "configure is wrong" && make && make installecho "###chown privilege for directory nagios####"chown nagios. /usr/local/nagios -Recho "###install nrpe###"cd $dirtar xf nrpe-2.12.tar.gz && cd nrpe-2.12 && ./configure || echo "configure was wrong" && make all && make install-plugin && make install-daemon && make install-daemon-config && make install-xinetdecho "###change config file###"sed -i '/only_from/s/127\.0\.0\.1/127\.0\.0\.1 10\.6\.8\.200/g' /etc/xinetd.d/nrpeecho "nrpe 5666/tcp # nrpe" >> /etc/servicesecho "###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 5666tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 28374/xinetd# /usr/local/nagios/libexec/check_nrpe -H 10.6.1.34NRPE v2.12
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。