| 1 | #!/bin/ksh | 
|---|
| 2 | # IBM_PROLOG_BEGIN_TAG | 
|---|
| 3 | # This is an automatically generated prolog. | 
|---|
| 4 | # | 
|---|
| 5 | # | 
|---|
| 6 | # | 
|---|
| 7 | # Licensed Materials - Property of IBM | 
|---|
| 8 | # | 
|---|
| 9 | # (C) COPYRIGHT International Business Machines Corp. 2004,2005 | 
|---|
| 10 | # All Rights Reserved | 
|---|
| 11 | # | 
|---|
| 12 | # US Government Users Restricted Rights - Use, duplication or | 
|---|
| 13 | # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. | 
|---|
| 14 | # | 
|---|
| 15 | # IBM_PROLOG_END_TAG | 
|---|
| 16 | # @(#)85 1.4.1.5 src/avs/fs/mmfs/ts/admin/mmpmon.sh, mmfs, avs_rgpfs24, rgpfs240610b 6/16/05 01:55:25 | 
|---|
| 17 | ####################################################################### | 
|---|
| 18 | # | 
|---|
| 19 | # Usage:  mmpmon [-d integerDelayValue] [-i fileName] [-p] | 
|---|
| 20 | #                [-r integerRunValue] [-s] [-t timeout_in_sec] | 
|---|
| 21 | # | 
|---|
| 22 | ####################################################################### | 
|---|
| 23 |  | 
|---|
| 24 | # Include global declarations and service routines | 
|---|
| 25 | . /usr/lpp/mmfs/bin/mmglobfuncs | 
|---|
| 26 | . /usr/lpp/mmfs/bin/mmsdrfsdef | 
|---|
| 27 | . /usr/lpp/mmfs/bin/mmfsfuncs | 
|---|
| 28 |  | 
|---|
| 29 | sourceFile="mmpmon.sh" | 
|---|
| 30 | [[ -n $DEBUG || -n $DEBUGmmpmon ]] && set -x | 
|---|
| 31 | $mmTRACE_ENTER "$*" | 
|---|
| 32 |  | 
|---|
| 33 | ################################### | 
|---|
| 34 | # Set up trap exception handling. | 
|---|
| 35 | ################################### | 
|---|
| 36 | trap pretrap2 HUP INT QUIT KILL | 
|---|
| 37 |  | 
|---|
| 38 | # Local variables | 
|---|
| 39 |  | 
|---|
| 40 | usageMsg=186 | 
|---|
| 41 | noUsageMsg=0 | 
|---|
| 42 | integer rc=0 | 
|---|
| 43 | integer delayValue=1000  # default value for delay (1000 ms) | 
|---|
| 44 | integer runValue=1       # default value for run | 
|---|
| 45 | parsable="0"             # default to human-readable output. | 
|---|
| 46 | emitPrompts="1"          # default value for no explicit file name. | 
|---|
| 47 | fileName="" | 
|---|
| 48 | timeout_in_sec=60 | 
|---|
| 49 |  | 
|---|
| 50 | ################################## | 
|---|
| 51 | # Get the correct socket name. | 
|---|
| 52 | ################################## | 
|---|
| 53 | useThisNamedSocket=$mmpmonNamedSocketFile | 
|---|
| 54 |  | 
|---|
| 55 | ################################## | 
|---|
| 56 | # Process the command arguments. | 
|---|
| 57 | ################################## | 
|---|
| 58 | [[ $arg1 = '-?' || $arg1 = '-h' || $arg1 = '--help' || $arg1 = '--' ]] && \ | 
|---|
| 59 | syntaxError "help" $usageMsg | 
|---|
| 60 |  | 
|---|
| 61 | # Parse the optional parameters. | 
|---|
| 62 | while getopts :d:i:psr:t: OPT | 
|---|
| 63 | do | 
|---|
| 64 | case $OPT in | 
|---|
| 65 | d) delayValue=$(checkIntRange "-d" $OPTARG 500 8000000) | 
|---|
| 66 | [[ $? -ne 0 ]] && cleanupAndExit | 
|---|
| 67 | ;; | 
|---|
| 68 |  | 
|---|
| 69 | i) [[ -n $fileName ]] && syntaxError "multiple" $noUsageMsg "-$OPT" | 
|---|
| 70 | emitPrompts="0" | 
|---|
| 71 | fileName=$OPTARG | 
|---|
| 72 | if [[ ! -r $fileName ]] | 
|---|
| 73 | then | 
|---|
| 74 | # Cannot open the file | 
|---|
| 75 | printErrorMsg 43 $mmcmd $fileName | 
|---|
| 76 | cleanupAndExit | 
|---|
| 77 | fi | 
|---|
| 78 | ;; | 
|---|
| 79 |  | 
|---|
| 80 | p) parsable="1" | 
|---|
| 81 | ;; | 
|---|
| 82 |  | 
|---|
| 83 | r) runValue=$(checkIntRange "-r" $OPTARG 0 8000000) | 
|---|
| 84 | [[ $? -ne 0 ]] && cleanupAndExit | 
|---|
| 85 | ;; | 
|---|
| 86 |  | 
|---|
| 87 | s) emitPrompts="0" | 
|---|
| 88 | ;; | 
|---|
| 89 |  | 
|---|
| 90 | t) timeout_in_sec=$(checkIntRange "-t" $OPTARG 1 8000000) | 
|---|
| 91 | [[ $? -ne 0 ]] && cleanupAndExit | 
|---|
| 92 | ;; | 
|---|
| 93 |  | 
|---|
| 94 | +[diprst]) # invalid option specified | 
|---|
| 95 | syntaxError "invalidOption" $usageMsg $OPT | 
|---|
| 96 | ;; | 
|---|
| 97 |  | 
|---|
| 98 | :) # missing required value after an option | 
|---|
| 99 | syntaxError "missingValue" $usageMsg $OPTARG | 
|---|
| 100 | ;; | 
|---|
| 101 |  | 
|---|
| 102 | *) # invalid option specified | 
|---|
| 103 | syntaxError "invalidOption" $usageMsg $OPTARG | 
|---|
| 104 | ;; | 
|---|
| 105 | esac | 
|---|
| 106 | done | 
|---|
| 107 | shift OPTIND-1 | 
|---|
| 108 | [[ $# != 0 ]] && syntaxError "extraArg" $usageMsg $1 | 
|---|
| 109 |  | 
|---|
| 110 | if [[ -n $DEBUG || -n $DEBUGmmpmon ]] | 
|---|
| 111 | then | 
|---|
| 112 | debugOption="1" | 
|---|
| 113 | else | 
|---|
| 114 | debugOption="0" | 
|---|
| 115 | fi | 
|---|
| 116 |  | 
|---|
| 117 | ################################### | 
|---|
| 118 | # Invoke the tspmon command. | 
|---|
| 119 | ################################### | 
|---|
| 120 | if [[ -n $fileName ]] | 
|---|
| 121 | then | 
|---|
| 122 | ${mmcmdDir}/${links}/mmpmon \ | 
|---|
| 123 | $delayValue $parsable $runValue $debugOption $emitPrompts  \ | 
|---|
| 124 | $timeout_in_sec $useThisNamedSocket < $fileName | 
|---|
| 125 | rc=$? | 
|---|
| 126 | else | 
|---|
| 127 | ${mmcmdDir}/${links}/mmpmon \ | 
|---|
| 128 | $delayValue $parsable $runValue $debugOption $emitPrompts  \ | 
|---|
| 129 | $timeout_in_sec $useThisNamedSocket | 
|---|
| 130 | rc=$? | 
|---|
| 131 | fi | 
|---|
| 132 |  | 
|---|
| 133 | cleanupAndExit $rc | 
|---|
| 134 |  | 
|---|