"Fossies" - the Fresh Open Source Software Archive

Member "freeha-1.0/service_scripts/pidfile.monitor" (23 Nov 2006, 1331 Bytes) of package /linux/privat/old/freeha-1.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 
    4 #-------------------------------------------------------------------------#
    5 #  picfile.monitor                                                        #
    6 #  This script verifies that a pidfile exists, and that the pid is running#
    7 #                                                                         #
    8 #  Standard UNIX status: returns 0 on good, non-0 on bad.                 #
    9 #                                                                         #
   10 #  Provided as a tool to be called from 'monitorhasrv'                    #
   11 #                                                                         #
   12 #-------------------------------------------------------------------------#
   13 
   14 
   15 
   16 PIDFILE="$1"
   17 
   18 if [ "$PIDFILE" = "" ] ; then
   19     echo pidfile.monitor: ERROR: no pidfile specified
   20     exit 1
   21 fi
   22 
   23 if [ ! -f "$PIDFILE" ] ; then
   24     echo pidfile.monitor: ERROR: file $PIDFILE does not exist
   25     exit 1
   26 fi
   27 
   28 PID=`cat $PIDFILE`
   29 if [ "$PID" = "" ] ; then
   30     echo invalid/unreadable pid file $PIDFILE
   31     exit 1
   32 fi
   33 
   34 if [ -d /proc ] ; then
   35     ls -d /proc/$PID >/dev/null
   36     if [ $? -eq 0 ] ; then
   37         exit 0
   38     else
   39         echo pidfile.monitor: pid $PID does not exist
   40         exit 1
   41     fi
   42 fi
   43 
   44 
   45 esac
   46 if [ -x /usr/ucb/ps ] ; then
   47     PROCLIST="/usr/ucb/ps ax"
   48 else
   49     PROCLIST="ps -e"
   50 fi
   51 $PROCLIST |grep "^$PID ">/dev/null
   52 
   53 if [ $? -eq 0 ] ; then
   54     exit 0 
   55 fi
   56 
   57 exit 1
   58