1、nrpe(nagios客户端)系统开机自启动脚本:
#!/bin/bash
#chkconfig: - 60 98
#description: This shell script is used to control nrpe(nagios's client) service===>{start|stop|status|restart} the nrpe.
#scriptname: /etc/init.d/nrped
#explain: my nrpe's prefix path is "/usr/local/nagios"
#
#There are some commands below:
#chmod u+x /etc/init.d/nrped
#chkconfig --add nrped
#chkconfig nrped off
#
#cat >>/etc/rc.local<<EOF
#
##This shell script is used to control nrpe(nagios's client) service===>{start|stop|status|restart} the nrpe.
#/etc/init.d/nrped start
#
#EOF
#
#author:freeflybird
#blog:https://blog.csdn.net/CPPCPPCPPCPP
[ $UID -ne 0 ] && {
echo "You must use the \"root\" user to operation nrpe!"
exit 1
}
[ -f /etc/init.d/functions ] && . /etc/init.d/functions
workdirPrefix=/usr/local
if [ ! -d $workdirPrefix ];then
mkdir -p $workdirPrefix || {
echo "Unknown ERROR!Anyway,this directory \"$workdirPrefix\" does not exist!"
exit 1
}
fi
nrpeBin=$workdirPrefix/nagios/bin/nrpe
nrpeCfg=$workdirPrefix/nagios/etc/nrpe.cfg
statusnrpeCmd="ps -ef|grep 'nrpe.cfg'|grep -v grep"
#state value of return
RETVAL=0
actionInfo(){
#arg1:execute stat