#!/bin/csh -f #+ #OSIRIS library of scripts # #NAME # osirisCheckServer - check if server is alive # #SYNOPSIS # osirisCheckServer service # #DESCRIPTION # Checks if the specified server is running by checking the lastalive # keyword, and reports 1 if the server is alive, 0 if not. # #OPTIONS # service # rpc server name to check # #EXAMPLES # osirisCheckServer otcs # Returns 1 is server is alive, 0 if not # #ENVIRONMENT VARIABLES # none # #FILES # none # #SERVERS & KEYWORDS # service = all osiris servers # keywords: lastalive # #SCRIPTS CALLED # list of the scripts called by this script, for example: # # help, syncheck # #EXIT STATUS # 0 - normal exit, no error # 1 - script aborted by an interrupt # 2 - syncheck error # 3 - error parsing command line input # other errors... # #SEE ALSO # ??? #- # # Modification History: # 20050202 - MB: Initial version created # # Boiler plate for "-h" support for command autohelp. if ("$1" == "-h") then help $0 | more exit $status endif # Boilerplate for syncheck. # Note that the boiler plate should be transparent for all usages, # but to make correct use of syncheck you will need to specify the # correct pattern. set noglob set servlist = "[oids,osds,otcs,ot1s,ot2s,op1s,op2s,oprs,om1s,om2s,om3s,\ om4s,om5s,om6s,osiris,obbs]" set CheckStatus = `syncheck -command $0 $* -pattern ${servlist}` unset noglob if ("$CheckStatus" != "OK") then help $0 exit 2 endif # End of help/syncheck boiler plate. # Set up to trap interrupts (Ctrl-C, etc.) onintr abort # Set default variable values # Get the command line argument set service = $1 # Check if the server is running show -s ${service} lastalive >& /dev/null set exitcode = $status if ($exitcode == 0) then # server is alive echo 1 goto done else # assume the server is dead echo 0 exit $exitcode endif goto done abort: # Block of code to handle interrupts. exit 1 done: # is there anything that needs to go here? exit