7 # Default-Start: 2 3 4 5
9 # Short-Description: pnp4nagios NPCD Daemon Version 0.6.5
10 # Description: Nagios Performance Data C Daemon
13 # chkconfig: 345 99 01
19 . lib
/omd
/init_profile
24 exec_prefix
=###ROOT###
25 NpcdBin
=###ROOT###/bin/npcd
26 NpcdCfgFile
=###ROOT###/etc/pnp4nagios/npcd.cfg
27 NpcdVarDir
=###ROOT###/var/pnp4nagios
28 NpcdRunFile
=###ROOT###/tmp/pnp4nagios/run/npcd.pid
29 NpcdLockDir
=###ROOT###/tmp/pnp4nagios/lock
36 if ps
-p $NpcdPID > /dev
/null
2>&1; then
39 if test -f $NpcdLockDir/$NpcdLockFile; then
49 if status_npcd
$1 $2; then
50 echo "$servicename (pid $NpcdPID) is running..."
52 elif test $?
= 2; then
53 echo "$servicename is not running but subsystem locked"
56 echo "$servicename is not running"
68 if [ -f "$NpcdRunFile" ]; then
69 # Handle stale pidfiles
70 TMPPID
=`head -n 1 $NpcdRunFile`
71 if ps
-p $TMPPID >/dev
/null
2>&1; then
77 # It might happen that there is no pidfile or a stale pidfile but
78 # a process is running. As fallback check the process table for the
79 # oldest process executed by the site user
80 PID
=$
(pgrep
-u $OMD_SITE -o -f $NpcdBin)
81 if [ -n "$PID" ]; then
89 # Source function library
90 # Solaris doesn't have an rc.d directory, so do a test first
91 if [ -f /etc
/rc.d
/init.d
/functions
]; then
92 .
/etc
/rc.d
/init.d
/functions
93 elif [ -f /etc
/init.d
/functions
]; then
94 .
/etc
/init.d
/functions
97 # Start only if PNP is enabled
98 .
###ROOT###/etc/omd/site.conf
99 if ( [ "$CONFIG_PNP4NAGIOS" != on
] && [ "$CONFIG_PNP4NAGIOS" != npcd
] ) ; then
103 # Check that npcd exists.
104 if [ ! -f $NpcdBin ]; then
105 echo "Executable file $NpcdBin not found. Exiting."
109 # Check that npcd.cfg exists.
110 if [ ! -f $NpcdCfgFile ]; then
111 echo "Configuration file $NpcdCfgFile not found. Exiting."
115 # See how we were called.
116 __init_hook
$0 $1 pre
120 if [ $?
-eq 0 ]; then
121 echo "$servicename already started..."
124 echo -n "Starting $servicename..."
126 chown
$NpcdUser:$NpcdGroup $NpcdRunFile
127 $NpcdBin -d -f $NpcdCfgFile
128 if [ -d $NpcdLockDir ]; then touch $NpcdLockDir/$NpcdLockFile; fi
130 __init_hook
$0 $1 post
136 if ! [ $?
-eq 0 ]; then
137 echo "$servicename was not running... could not stop"
140 echo -n "Stopping $servicename..."
145 # now we have to wait for npcd to exit and remove its
146 # own NpcdRunFile, otherwise a following "start" could
147 # happen, and then the exiting npcd will remove the
148 # new NpcdRunFile, allowing multiple npcd daemons
149 # to (sooner or later) run - John Sellens
150 # echo -n 'Waiting for npcd to exit .'
151 for i
in 1 2 3 4 5 6 7 8 9 10 ; do
152 if status_npcd
> /dev
/null
; then
159 if status_npcd
> /dev
/null
; then
161 echo 'Warning - $servicename did not exit in a timely manner'
165 rm -f $NpcdLockDir/$NpcdLockFile
166 __init_hook
$0 $1 post
180 echo "Usage: $servicename {start|stop|restart|reload|status}"