62 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
	
		
			1.9 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable file
		
	
	
	
	
#!/bin/sh
 | 
						|
################################################################################
 | 
						|
#
 | 
						|
#  Rattail -- Retail Software Framework
 | 
						|
#  Copyright © 2010-2018 Lance Edgar
 | 
						|
#
 | 
						|
#  This file is part of Rattail.
 | 
						|
#
 | 
						|
#  Rattail is free software: you can redistribute it and/or modify it under the
 | 
						|
#  terms of the GNU General Public License as published by the Free Software
 | 
						|
#  Foundation, either version 3 of the License, or (at your option) any later
 | 
						|
#  version.
 | 
						|
#
 | 
						|
#  Rattail is distributed in the hope that it will be useful, but WITHOUT ANY
 | 
						|
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 | 
						|
#  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 | 
						|
#  details.
 | 
						|
#
 | 
						|
#  You should have received a copy of the GNU General Public License along with
 | 
						|
#  Rattail.  If not, see <http://www.gnu.org/licenses/>.
 | 
						|
#
 | 
						|
################################################################################
 | 
						|
#
 | 
						|
# This is a simple script which will output a single line of info, and exit
 | 
						|
# with a return code which indicates status of a given Rattail daemon.  It was
 | 
						|
# designed for use with Shinken monitoring.  Invoke like so:
 | 
						|
#
 | 
						|
#    check-rattail-daemon NAME
 | 
						|
#
 | 
						|
# Where NAME refers to the service, e.g. 'rattail-datasync'.  Exit code may be:
 | 
						|
#
 | 
						|
#  * 0 = daemon is confirmed running
 | 
						|
#  * 2 = daemon is confirmed *not* running
 | 
						|
#  * 3 = unknown state
 | 
						|
#
 | 
						|
################################################################################
 | 
						|
 | 
						|
NAME="$1"
 | 
						|
if [ "$NAME" = "" ]; then
 | 
						|
    echo "Usage: check-rattail-daemon NAME"
 | 
						|
    exit 3
 | 
						|
fi
 | 
						|
 | 
						|
PIDFILE="/var/run/rattail/$NAME.pid"
 | 
						|
if [ ! -f "$PIDFILE" ]; then
 | 
						|
    echo "PID file not found: $PIDFILE"
 | 
						|
    exit 2
 | 
						|
fi
 | 
						|
 | 
						|
PID=`cat $PIDFILE`
 | 
						|
if [ "$PID" = "" ]; then
 | 
						|
    echo "File exists but contains no PID: $PIDFILE"
 | 
						|
    exit 3
 | 
						|
fi
 | 
						|
ps -p $PID >/dev/null
 | 
						|
if [ ! $? ]; then
 | 
						|
    echo "No process found for PID $PID; per file: $PIDFILE"
 | 
						|
    exit 2
 | 
						|
fi
 | 
						|
 | 
						|
echo "Rattail daemon $NAME is running with PID $PID"
 | 
						|
exit 0
 |