[ Pobierz całość w formacie PDF ]
.9 proc_watch_timed.ksh shell script listing.(continued) Process Monitoring 235# Put anything that you want to execute WHEN, or AS, the# monitored process STARTS in this function: # No-OP - Needed as a place holder for an empty function# Comment Out the Above colon,  :STARTUP_RC=$?return $STARTUP_RC}####################################################post_event_script (){# Put anything that you want to execute AFTER the# monitored process ENDS in this function: # No-OP - Need as a place holder for an empty function# Comment Out the Above colon,  :POST_RC=$?return $POST_RC}##################################################### This function is used to test character stringstest_string (){if (( $# != 1 ))thenecho  ERRORreturnfiC_STRING=$1# Test the character string for its compositioncase $C_STRING in+([0-9])) echo  POS_INT # Integer >= 0;;+([-0-9])) echo  NEG_INT # Integer $TTYecho  STARTUP EVENT: Executing Startup Event Script. \>> $LOGFILEstartup_event_script # USER DEFINED FUNCTION!!!RC=$? # Check the Return Code!!if ((  RC == 0 ))thenecho  SUCCESS: Startup Event Script Completed RC -${RC} > $TTYecho  SUCCESS: Startup Event Script Completed RC -${RC} >> $LOGFILEelseecho  FAILURE: Startup Event Script FAILED RC -${RC} > $TTYecho  FAILURE: Startup Event Script FAILED RC -${RC} >> $LOGFILEfifiinteger PROC_COUNT= -1 # Reset the Countersinteger LAST_COUNT= -1# Loop until the process(es) end(s)until ((  PROC_COUNT == 0 ))do# This function is a Co-Process.$BREAK checks to see if#  Program Interrupt has taken place.If so BREAK will# be  Y and we exit both the loop and function.read BREAKListing 8.9 proc_watch_timed.ksh shell script listing.(continued) Process Monitoring 237if [[ $BREAK =  Y ]]thenreturn 3fiPROC_COUNT=$(ps -ef | grep -v  grep $PROCESS \| grep -v $SCRIPT_NAME \| grep $PROCESS | wc -l) >/dev/null 2>&1if ((  LAST_COUNT > 0 &&  LAST_COUNT !=  PROC_COUNT ))then# The Process Count has Changed.TIMESTAMP=$(date +%D@%T)# Get a list of the PID of all of the processesPID_LIST=$(ps -ef | grep -v  grep $PROCESS \| grep -v $SCRIPT_NAME \| grep $PROCESS | awk  {print $2} )echo  PROCESS COUNT: $PROC_COUNT $PROCESS\Processes Running ==> $TIMESTAMP >> $LOGFILE &echo  PROCESS COUNT: $PROC_COUNT $PROCESS\Processes Running ==> $TIMESTAMP > $TTYecho ACTIVE PIDS: $PID_LIST >> $LOGFILE &echo ACTIVE PIDS: $PID_LIST > $TTYfiLAST_COUNT=$PROC_COUNTsleep $INTERVAL # Needed to reduce CPU load!doneRUN= N # Turn the RUN Flag OffTIMESTAMP=$(date +%D@%T)echo  ENDING PROCESS: $PROCESS END time ==>\$TIMESTAMP >> $LOGFILE &echo  ENDING PROCESS: $PROCESS END time ==>\$TIMESTAMP > $TTY# This will run the post_event_script, which is a functionif [[ $RUN_POST_EVENT =  Y ]]thenecho  POST EVENT: Executing Post Event Script. \> $TTYecho  POST EVENT: Executing Post Event Script. \>> $LOGFILE &post_event_script # USER DEFINED FUNCTION!!!integer RC=$?if ((  RC == 0 ))Listing 8.9 proc_watch_timed.ksh shell script listing.(continues) 238 Chapter 8thenecho  SUCCESS: Post Event Script Completed RC -${RC} > $TTYecho  SUCCESS: Post Event Script Completed RC -${RC} >> $LOGFILEelseecho  FAILURE: Post Event Script FAILED RC - ${RC} \> $TTYecho  FAILURE: Post Event Script FAILED RC - ${RC} \>> $LOGFILEfifi;; N )# This will run the pre_event_script, which is a functionif [[ $RUN_PRE_EVENT =  Y ]]thenecho  PRE EVENT: Executing Pre Event Script. > $TTYecho  PRE EVENT: Executing Pre Event Script. >> $LOGFILEpre_event_script # USER DEFINED FUNCTION!!!RC=$? # Check the Return Code!!!if ((  RC == 0 ))thenecho  SUCCESS: Pre Event Script Completed RC - ${RC} \> $TTYecho  SUCCESS: Pre Event Script Completed RC - ${RC} \>> $LOGFILEelseecho  FAILURE: Pre Event Script FAILED RC - ${RC} \> $TTYecho  FAILURE: Pre Event Script FAILED RC - ${RC} \>> $LOGFILEfifiecho  WAITING: Waiting for $PROCESS tostartup.Monitoring.integer PROC_COUNT= -1 # Initialize to a fake value# Loop until at least one process startsuntil ((  PROC_COUNT > 0 ))Listing 8.9 proc_watch_timed.ksh shell script listing.(continued) Process Monitoring 239do# This is a Co-Process.This checks to see if a  Program# Interrupt has taken place [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • gieldaklubu.keep.pl
  •