码迷,mamicode.com
首页 > 移动开发 > 详细

nagios客户端nrped服务方式启动脚本

时间:2015-03-02 11:26:10      阅读:474      评论:0      收藏:0      [点我收藏+]

标签: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


本文出自 “心愿” 博客,请务必保留此出处http://xinyuan8.blog.51cto.com/677906/1616376

nagios客户端nrped服务方式启动脚本

标签:nagios客户端nrped服务方式启动脚本

原文地址:http://xinyuan8.blog.51cto.com/677906/1616376

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!