Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:12.2:PowerPC
nagios-nrpe
nrpe.init
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File nrpe.init of Package nagios-nrpe
#!/bin/bash # # Copyright (c) 2010 SUSE Linux Products GmbH # Authors: Lars Vogdt (2010) # # /etc/init.d/nrpe # and its symbolic link # /usr/sbin/rcnrpe # ### BEGIN INIT INFO # Provides: nagios-nrpe # Required-Start: $remote_fs $syslog $network # Should-Start: cron # Required-Stop: $remote_fs $syslog # Should-Stop: cron # Default-Start: 3 5 # Default-Stop: 0 1 2 6 # Short-Description: NRPE Nagios Remote Plugin Executor # Description: Start NRPE to allow remote execution of # Nagios plugins. ### END INIT INFO NRPE_BIN="/usr/sbin/nrpe" test -x $NRPE_BIN || { echo "$NRPE_BIN not installed"; if [ "$1" = "stop" ]; then exit 0; else exit 5; fi; } # Check for existence of needed config file and read it NRPE_CONFIG="/etc/nagios/nrpe.cfg" test -r $NRPE_CONFIG || { echo "$NRPE_CONFIG not existing"; if [ "$1" = "stop" ]; then exit 0; else exit 6; fi; } DEFAULT_PIDFILE="/var/run/nrpe/nrpe.pid" function get_value() { if [ -n "$2" ]; then set -- `grep ^$1 $2 | sed 's@=@ @' | tr -d '[:cntrl:]'` else set -- `grep ^$1 $NRPE_CONFIG | sed 's@=@ @' | tr -d '[:cntrl:]'` fi shift # remove first ARG => search-string echo $* } # Shell functions sourced from /etc/rc.status: . /etc/rc.status # Reset status of this service rc_reset case "$1" in start) echo -n "Starting Nagios NRPE " pid_file="$(get_value pid_file)" nrpe_group="$(get_value nrpe_group)" nrpe_user="$(get_value nrpe_user)" : ${pid_file=:=$DEFAULT_PIDFILE} : ${nrpe_group:=nagios} : ${nrpe_user:=nagios} if [ -z "$pid_file" ]; then PIDDIR=$(dirname $pid_file) else PIDDIR=$(dirname $DEFAULT_PIDFILE) fi case "$PIDDIR" in /var/run) if [ x"$nrpe_user" != x"root" ]; then DATESTRING=`date +"%Y%m%d"` mv -f "$NRPE_CONFIG" "$NRPE_CONFIG-$DATESTRING" sed -e "s|^pid_file.*|pid_file=$DEFAULT_PIDFILE|g" "$NRPE_CONFIG-$DATESTRING" > "$NRPE_CONFIG" /bin/logger -t rcnrpe "Configured $pid_file in $NRPE_CONFIG moved to $DEFAULT_PIDFILE. Backup is $NRPE_CONFIG-$DATESTRING" test -f "$pid_file" && rm "$pid_file" install -d -m755 -o$nrpe_user -g$nrpe_group $(dirname "$DEFAULT_PIDFILE") else test -d "$PIDDIR" || mkdir -p "$PIDDIR" fi ;; *) test -d $(dirname "$DEFAULT_PIDFILE") || install -d -m755 -o$nrpe_user -g$nrpe_group $(dirname "$DEFAULT_PIDFILE") ;; esac /sbin/startproc $NRPE_BIN -c $NRPE_CONFIG -d # Remember status and be verbose rc_status -v ;; stop) # Stop daemons. echo -n "Shutting down Nagios NRPE " /sbin/killproc -TERM $NRPE_BIN # Remember status and be verbose rc_status -v ;; try-restart|condrestart) if test "$1" = "condrestart"; then echo "${attn} Use try-restart ${done}(LSB)${attn} rather than condrestart ${warn}(RH)${norm}" fi $0 status if test $? = 0; then $0 restart else rc_reset # Not running is not a failure. fi # Remember status and be quiet rc_status ;; restart) ## Stop the service and regardless of whether it was ## running or not, start it again. $0 stop $0 start # Remember status and be quiet rc_status ;; reload|force-reload) echo -n "Reload service Nagios NRPE " /sbin/killproc -HUP $NRPE_BIN # Remember status and be verbose rc_status -v ;; status) echo -n "Checking for service Nagios NRPE " ## Check status with checkproc(8), if process is running ## checkproc will return with exit status 0. # Status has a slightly different for the status command: # 0 - service running # 1 - service dead, but /var/run/ pid file exists # 2 - service dead, but /var/lock/ lock file exists # 3 - service not running /sbin/checkproc $NRPE_BIN # Remember status and be verbose rc_status -v ;; *) echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|reload}" exit 1 esac rc_exit
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor