nagios客户端nrped服务方式启动脚本
1、平時配置nagios客戶端nrped啟動最常用的就是在/etc/rc.local文件配置:
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
2、但是還有更好的方式(這樣方便使用腳本啟動或者關閉):
在/etc/init.d目錄下創建nrped腳本文件,并執行?chmod +x /etc/init.d/nrped 賦予執行權限
chkconfig --add nrped 或執行直接執行chkconfig nrped on 來添加為服務啟動
nrped 腳本文件內容(這個腳本不是我寫的):
#!/bin/sh
#
# ?Created 2000-01-03 by jaclu@grm.se
#
# nrpe ? ? ? ? ?This shell script takes care of starting and stopping
# ? ? ? ? ? ? ? nrpe.
#
# chkconfig: 2345 80 30
# description: nrpe is a daemon for a remote nagios server, \
# ? ? ? ? ? ? ?running nagios plugins on this host.
# processname: nrpe
# config: /usr/local/nagios/etc/nrpe.cfg
# Source function library
if [ -f /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
elif [ -f /etc/init.d/functions ]; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/functions ]; then
. /etc/rc.d/functions
fi
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
NrpeBin=/usr/local/nagios/bin/nrpe
NrpeCfg=/usr/local/nagios/etc/nrpe.cfg
LockFile=/var/lock/subsys/nrpe
# See how we were called.
case "$1" in
? start)
? ? ? ? # Start daemons.
? ? ? ? echo -n "Starting nrpe: "
? ? ? ? daemon $NrpeBin -c $NrpeCfg -d
? ? ? ? echo
? ? ? ? touch $LockFile
? ? ? ? ;;
? stop)
? ? ? ? # Stop daemons.
? ? ? ? echo -n "Shutting down nrpe: "
? ? ? ? killproc nrpe
? ? ? ? echo
? ? ? ? rm -f $LockFile
? ? ? ? ;;
? restart)
? ? ? ? $0 stop
? ? ? ? $0 start
? ? ? ? ;;
? status)
? ? ? ? status nrpe
? ? ? ? exit $?
? ? ? ? ;;
? *)
? ? ? ? echo "Usage: nrpe {start|stop|restart|status}"
? ? ? ? exit 1
esac
exit 0
轉載于:https://blog.51cto.com/xinyuan8/1616376
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的nagios客户端nrped服务方式启动脚本的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Create view failed w
- 下一篇: 反转链表-剑指offer-16