#! /bin/sh # # check PCP QA setup # # Copyright (c) 1997-2002 Silicon Graphics, Inc. All Rights Reserved. # # $Id$ # tmp=/var/tmp/$$ trap "rm -f $tmp.*; exit 0" 0 1 2 3 15 _fail() { echo "... check failed!" exit 1 } _check_pmcd() { # 5 seconds default seems like a reasonble max time to establish # contact rm -f $tmp.ok _can_wait=5 _host=$1 _i=0 _dead=true while [ $_i -lt $_can_wait ] do _sts=`pmprobe -n $PCP_VAR_DIR/pmns/root_pmcd -h $_host pmcd.numclients 2>/dev/null | $PCP_AWK_PROG '{print $2}'` if [ "${_sts:-0}" -gt 0 ] then # numval really > 0, we're done # _dead=false break fi sleep 1 _i=`expr $_i + 1` done if $_dead then : else touch $tmp.ok fi } # files in the PCP distribution # fail=false for file in /etc/pcp.env do if [ ! -f "$file" ] then echo "$0: Error: cannot file \"$file\" from the PCP distribution" fail=true fi done # files in the PCP QA distribution # for file in mk.localconfig common.rc common.setup common.product \ common.check common.config do if [ ! -f "$file" ] then echo "$0: Error: cannot file \"$file\" from the PCP QA distribution" fail=true fi done # no point proceeding if any of these files are missing # $fail && _fail if [ ! -f localconfig ] then # need localconfig # if ./mk.localconfig then make setup | egrep -v 'Entering|Leaving|Nothing' else echo "$0: Error: need to fix failure in mk.localconfig" _fail fi if [ ! -f localconfig ] then echo "$0: Error: mk.localconfig failed to create the file \"localconfig\"" _fail fi fi # source hierarchy # # common.product # common.setup # common.rc # /etc/pcp.env # localconfig # common.check # common.config # localconfig # . ./common.product . ./common.check . ./common.config # things we care about from /etc/pcp.env # # files # for var in PCP_PMCDCONF_PATH PCP_PMCDOPTIONS_PATH PCP_MAGIC_FILE do eval file=\$$var if [ -z "$file" ] then echo "$0: Error: variable \$$var is not set from /etc/pcp.env" fail=true else if [ ! -f "$file" ] then echo "$0: Error: cannot find file \"$file\" (\$$var from /etc/pcp.env)" fail=true fi fi done # programs # for var in PCP_AWK_PROG PCP_XCONFIRM_PROG do eval prog=\$$var if [ -z "$prog" ] then echo "$0: Error: variable \$$var is not set from /etc/pcp.env" fail=true else if which $prog >/dev/null 2>&1 then : else echo "$0: Error: cannot find executable program \"$prog\" (\$$var from /etc/pcp.env)" fail=true fi fi done # directories # # these ones should be in /etc/pcp.conf but are not currently used in # the QA scripts, but are tested here for completeness # xtra="PCP_SYSCONFIG_DIR PCP_LIB_DIR PCP_LIB_COMPAT_DIR PCP_INC_DIR PCP_MAN_DIR" # for var in PCP_RC_DIR PCP_PMDAS_DIR PCP_VAR_DIR PCP_DEMOS_DIR PCP_LOG_DIR \ PCP_BIN_DIR PCP_BINADM_DIR PCP_TMP_DIR PCP_SHARE_DIR PCP_DOC_DIR \ $xtra do eval dir=\$$var if [ -z "$dir" ] then echo "$0: Error: variable \$$var is not set from /etc/pcp.env" fail=true else if [ ! -d "$dir" ] then echo "$0: Error: cannot find directory \"$prog\" (\$$var from /etc/pcp.env)" fail=true fi fi done # common.rc will unconditionally set these ones, else fail ... so no need to # check # $PCP_PMCD_PROG # $PCP_PMCDLOG_PATH # localconfig will unconditionally set these ones ... no real sane checking # I can do here! # $PCP_PLATFORM (redundant, copied from /etc/pcp.conf) # $PCP_VER # $PCP_EOE_VER # $PCP_EOE_NOSHIP_VER # files from common.product # for var in PCP_PMCD_PATH do eval file=\$$var if [ -z "$file" ] then echo "$0: Error: variable \$$var is not set from common.product" fail=true else if [ ! -f "$file" ] then echo "$0: Error: cannot find file \"$file\" (\$$var from common.product)" fail=true fi fi done # no point proceeding if any of these files are missing # $fail && _fail # down to the common.config things ... these are the most contentious # and the ones that need local tuning ... # # $PCPQA_CLOSE_X_SERVER is set here, but is not used in the open # source version of the PCP QA and is hard to check, so skip that # one. # for var in PCPQA_FAR_PMCD PCPQA_HYPHEN_HOST do eval host=\$$var if [ -z "$host" ] then echo "$0: Warning: variable \$$var is not set from common.config" else # try to contact pmcd ... # echo -n "Contacting pmcd at $host ... " _check_pmcd $host if [ -f $tmp.ok ] then echo "OK" else echo "no response (warning)" fi fi done # no point proceeding if any of these variables are not set # $fail && _fail # the other pmcd's we think we can talk to ... # make qa_hosts >/dev/null 2>&1 if [ ! -f qa_hosts ] then echo "$0: Error: make failed to create the file \"qa_hosts\"" _fail fi # failures here are not fatal ... some of the hosts may be off with the # pixies # echo "hullo world" >$tmp.hullo for host in `cat qa_hosts` do # try to contact remote pmcd ... # echo -n "Contacting remote pmcd at $host ... " _check_pmcd $host if [ -f $tmp.ok ] then echo "OK" # if the host is there, then the login for pcpqa needs to be # setup and and rsh/rcp working without passwords echo -n "Trying rcp/rsh for login pcpqa at $host ... " echo "== rsh 1st rm ==" >$tmp.out rsh -l pcpqa $host rm -f chk.hullo >>$tmp.out 2>&1 echo "== rcp -> $host ==" >>$tmp.out rcp $tmp.hullo pcpqa@$host:chk.hullo >>$tmp.out 2>&1 echo "== rsh cat ==" >>$tmp.out rsh -l pcpqa $host cat chk.hullo >$tmp.ans 2>>$tmp.out echo "== rsh 2nd rm ==" >>$tmp.out rsh -l pcpqa $host rm -f chk.hullo >>$tmp.out 2>&1 if [ "`cat $tmp.ans`" = "`cat $tmp.hullo`" ] then echo "OK" else echo "failed" fail=true echo "Expected output: \"`cat $tmp.hullo`\"" echo "Actual output: \"`cat $tmp.ans`\"" echo "Diagnostic Log:" cat $tmp.out fi else echo "no response (warning)" fi done # down to pmcd on the local host # for host in localhost `hostname` `_get_fqdn` do # try to contact pmcd ... # echo -n "Contacting local pmcd at $host ... " _check_pmcd $host if [ -f $tmp.ok ] then echo "OK" else echo "no response (fatal)" fail=true fi done # no point proceeding if any of these cannot be contacted # $fail && _fail echo "Check the sanity of these:" echo -n " \$PCP_PLATFORM=$PCP_PLATFORM [y] ? " read ans [ ! -z "$ans" -a "$ans" != y ] && _fail echo -n " \$PCP_VERSION=$PCP_VERSION [y] ? " read ans [ ! -z "$ans" -a "$ans" != y ] && _fail exit 0