Commit 581a5ff4 authored by Andrea Sciaba's avatar Andrea Sciaba
Browse files

Compact version of swinst

parent 4a7d91ee
#!/bin/bash
# Change needed for Nagios
SAME_INFO=$SAME_OK
SAME_NOTICE=$SAME_WARNING
export LANG=C
info=0
notice=0
warning=0
error=0
isEGEE=0
isOSG=0
hasCVMFS=0
export LANG=C
cat $SAME_SENSOR_HOME/tests/CMS-SAM-Banner.html
echo '<h1><a href="#summary">Jump to test summary</a></h1>'
echo "<h2>Preliminary checks</h2>"
echo "<pre>"
echo "version 13-10-2014 14:00"
uname -a
cat /etc/issue
date
date --utc
voms-proxy-info -identity -fqan
id
workdir=`mktemp -d workdirXXXXXX`
cd $workdir
cp -v $SAME_SENSOR_HOME/tests/cmssw_required_version_list.txt .
cp -v $SAME_SENSOR_HOME/tests/fetch-from-web .
cp -v $SAME_HOME/.BrokerInfo .
[ -n "$GLITE_WMS_RB_BROKERINFO" ] && cp -v $GLITE_WMS_RB_BROKERINFO .
[ -n "$EDG_WL_RB_BROKERINFO" ] && cp -v $EDG_WL_RB_BROKERINFO .
echo "</pre>"
echo "<p>Memory:</p>"
echo "<pre>"
cat /proc/meminfo | grep Mem
echo "</pre>"
echo "<h2>Checking software directory for CMS VO</h2>"
cp $SAME_SENSOR_HOME/tests/cmssw_required_version_list.txt .
isEGEE=0
isOSG=0
hasCVMFS=0
if [ -n "$OSG_GRID" ] ; then
isOSG=1
echo "<p>OSG Middleware</p>"
[ -f $OSG_GRID/setup.sh ] && source $OSG_GRID/setup.sh
if [ -d $OSG_APP/cmssoft/cms ] ;then
SW_DIR=$OSG_APP/cmssoft/cms
if [ -L $SW_DIR ]; then
if [ `file $SW_DIR | awk '{print $5}' | grep -c cvmfs` -gt 0 ]; then
hasCVMFS=1
echo "<p>CVMFS mode</p>"
fi
fi
echo "<p>Checking variable: \$OSG_APP/cmssoft/cms=$OSG_APP/cmssoft/cms</p>"
SW_DIR=$OSG_APP/cmssoft/cms
elif [ -d $CVMFS/cms.cern.ch ] ; then
SW_DIR=$CVMFS/cms.cern.ch
if [ -n "$CVMFS" ]; then
hasCVMFS=1
echo "<p>CVMFS mode</p>"
fi
echo "<p>Checking variable: \$CVMFS/cms.cern.ch=$CVMFS/cms.cern.ch</p>"
SW_DIR=$CVMFS/cms.cern.ch
elif [ -d /cvmfs/cms.cern.ch ] ; then
SW_DIR=/cvmfs/cms.cern.ch
hasCVMFS=1
echo "<p>Checking fallback location: /cvmfs/cms.cern.ch</p>"
SW_DIR=/cvmfs/cms.cern.ch
else
echo "<p>"
echo "Cannot find CMS software area."
echo "</p>"
exit $SAME_ERROR
echo "ERROR: Cannot find CMS software in OSG node"
echo "summary: SW_DIR_UNDEF"
exit $SAME_ERROR
fi
echo "SwArea: $SW_DIR"
elif [ -n "$VO_CMS_SW_DIR" ] ; then
isEGEE=1
echo "EMI or ARC middleware"
SW_DIR=$VO_CMS_SW_DIR
echo "<p>Checking variable: \$VO_CMS_SW_DIR=$VO_CMS_SW_DIR</p>"
echo "SwArea: $SW_DIR"
elif [ -d $CVMFS/cms.cern.ch ] ; then
hasCVMFS=1
SW_DIR=$CVMFS/cms.cern.ch
echo "SwArea: $SW_DIR"
elif [ -d /cvmfs/cms.cern.ch ] ; then
hasCVMFS=1
SW_DIR=/cvmfs/cms.cern.ch
echo "SwArea: $SW_DIR"
else
echo "<p><strong>"
echo "ERROR: Neither VO_CMS_SW_DIR nor proper OSG variables defined"
echo "</strong></p>"
echo "ERROR: Neither VO_CMS_SW_DIR nor OSG_GRID defined and no CVMFS"
echo "summary: SW_DIR_UNDEF"
exit $SAME_ERROR
fi
echo "<pre>"
ls -ld $SW_DIR
result=$?
echo "</pre>"
if [ $result != 0 ]
then
echo "<p><strong>"
echo "ERROR: software $SW_DIR directory non existent or non readable"
echo "</strong></p>"
if [ ! -d $SW_DIR -o ! -r $SW_DIR ] ; then
echo "ERROR: software directory non existent or non readable"
echo "summary: SW_DIR_NOT_READABLE"
exit $SAME_ERROR
fi
echo "<h2><a name=\"DiskSpace\"></a>Some trivial checks</h2>"
echo
echo -n "Software location: "
if [ "`echo $SW_DIR | cut -d / -f 2`" == "afs" ]; then
echo "<p>AFS mode</p>"
SPACE=`fs lq $SW_DIR | tail -1 | awk '{print (\$2-\$3)/1024 }'`
echo "AFS"
SPACE=`fs lq $SW_DIR | tail -1 | awk '{print (\$2-\$3)/1024 }'`
elif [ "`echo $SW_DIR | cut -d / -f 2`" == "cvmfs" ]; then
echo "<p>CVMFS mode</p>"
hasCVMFS=1
hasCVMFS=1
echo "CVMFS"
else
SPACE=`df -k -P $SW_DIR | tail -1 | awk '{print \$4/1024}'`
echo "local"
SPACE=`df -k -P $SW_DIR | tail -1 | awk '{print \$4/1024}'`
fi
# Disk space check only for non-CVMFS
if [ $hasCVMFS == 0 ]; then
echo "<p>Free disk space in $SW_DIR: $SPACE MB</p>"
fi
# CERN needs some exceptions
atCERN=`echo $SW_DIR | grep -c cern.ch 2>/dev/null`
cantwrite=0
# on EGEE (but not CERN) check that lcgadmin can write to SW area
# Also skip for CVMFS
if [ $isEGEE == 1 ] && [ $hasCVMFS == 0 ] && [ $atCERN == 0 ]
then
echo "<pre>"
touch $SW_DIR/.sametest
result=$?
echo "</pre>"
if [ $result != 0 ]
then
cantwrite=1
echo "<p>WARNING: cannot write to software area</p>"
fi
echo "FreeSWAreaSpace: $SPACE MB"
fi
if [ ! -f $SW_DIR/cmsset_default.sh ] ; then
echo "<h3>"
echo "<p>ERROR: cmssw setup file $SW_DIR/cmsset_default.sh not existing</p>"
echo "</h3>"
tmpfile=`mktemp /tmp/tmp.XXXXXXXXXX`
source $SW_DIR/cmsset_default.sh > $tmpfile 2>&1
result=$?
if [ $result != 0 ] ; then
cat $tmpfile
rm -f $tmpfile
echo "ERROR: CMS software initialisation script cmsset_default.sh failed"
echo "summary: NO_SETUP_SCRIPT"
exit $SAME_ERROR
fi
rm -f $tmpfile
echo "<h2>Sourcing the CMS environment</h2>"
echo "<pre>"
echo "source $SW_DIR/cmsset_default.sh"
source $SW_DIR/cmsset_default.sh > /dev/null
echo "Default SCRAM arch: $SCRAM_ARCH"
echo "</pre>"
archs_defined='slc5_amd64_gcc434 slc5_amd64_gcc462 slc5_amd64_gcc472 slc6_amd64_gcc472 slc6_amd64_gcc481'
archs_to_test='slc5_amd64_gcc462 slc5_amd64_gcc472'
swok=0
for arch in $archs_to_test ; do
if [ $swok != 1 ] ; then
export SCRAM_ARCH=$arch
export BUILD_ARCH=$arch
echo "<p>Testing with SCRAM_ARCH=$arch ...</p>"
echo "<pre>"
rm -f cmsset.log
source $SW_DIR/cmsset_default.sh > cmsset.log 2>&1
result=$?
cat cmsset.log
echo "</pre>"
grep 'No such file or directory' cmsset.log > /dev/null 2>&1
res=$?
if [ $res == 0 ] ; then
result=1
fi
if [ $result != 0 ]
then
echo "<p>WARNING: CMS software initialisation script cmsset_default.sh failed for SCRAM_ARCH=$arch</p>"
else
swok=1
fi
fi
done
if [ $swok != 1 ]
then
echo "<p><strong>"
echo "ERROR: CMS software initialisation script cmsset_default.sh failed for all architectures"
echo "</strong></p>"
exit $SAME_ERROR
fi
echo "<p>OK</p>"
echo
echo "Default SCRAM_ARCH: $SCRAM_ARCH"
echo "<h2>Make sure configuration directory is there</h2>"
echo "<p>Checking variable: \$CMS_PATH=$CMS_PATH</p>"
if [ -z $CMS_PATH ]; then
echo "<p><strong>"
echo "ERROR: CMS_PATH not defined"
echo "</strong></p>"
exit $SAME_ERROR
echo "ERROR: CMS_PATH not defined"
echo "summary: CMS_PATH_UNDEF"
exit $SAME_ERROR
fi
if [ ! -d $CMS_PATH ] ; then
echo "<p><strong>"
echo "ERROR: CMS_PATH directory $CMS_PATH not existing"
echo "</strong></p>"
exit $SAME_ERROR
echo "ERROR: CMS_PATH directory $CMS_PATH not existing"
echo "summary: NO_CMS_PATH"
exit $SAME_ERROR
fi
echo "<p>OK</p>"
echo "<h2>Check that scramv1 command is present</h2>"
echo "<pre>"
echo "scramv1 version"
echo -n "scramv1_version: "
scramv1 version
result=$?
echo "</pre>"
if [ $result != 0 ]
then
echo "<p><strong>"
echo "ERROR: scramv1 command not found"
echo "</strong></p>"
exit $SAME_ERROR
echo "ERROR: scramv1 command not found"
echo "summary: NO_SCRAMV1"
exit $SAME_ERROR
fi
echo "<p>OK</p>"
#cd $SAME_SENSOR_WORK
echo "<h2>Retrieve list of CMSSW versions installed</h2>"
echo
echo "Retrieving list of CMSSW versions installed..."
archs_defined='slc5_amd64_gcc434 slc5_amd64_gcc462 slc5_amd64_gcc472 slc6_amd64_gcc472 slc6_amd64_gcc481'
for arch in $archs_defined
do
export SCRAM_ARCH=$arch
export BUILD_ARCH=$arch
echo "<pre>"
echo "Architecture: $arch"
echo "scramv1 list -c CMSSW"
scramv1 list -c CMSSW > scramv1_list_output.txt
listerror=$?
echo "</pre>"
if [ $listerror != 0 ]
then
echo "<p>WARNING: scramv1 list error</p>"
fi
touch scramv1_list_output.txt
cat scramv1_list_output.txt | tr -s " " | cut -d " " -f2 | sort -u > cmssw_installed_${arch}.txt
cat cmssw_installed_${arch}.txt >> cmssw_installed_version_list.txt
if [ $listerror == 0 ] # don't try to parse the error message for CMSSW versions
then
echo "<pre>"
cat cmssw_installed_${arch}.txt | while read line
do
line=`echo $line | sed -e 's/^CMSSW_//'`
echo $line
done
echo "</pre>"
fi
echo "<p>OK</p>"
echo "<p>"
if [ -d $CMS_PATH/${arch}/cms/cms-common/1.0 ]; then
echo "Recent cms-common RPM already installed:"
ls -d $CMS_PATH/${arch}/cms/cms-common/1.0/* | grep -v etc
else
echo "Old style cms-common RPM installed."
fi
echo "</p>"
export SCRAM_ARCH=$arch
export BUILD_ARCH=$arch
echo "SCRAM_ARCH: $arch"
scramv1 list -c CMSSW > scramv1_list_output.txt
listerror=$?
if [ $listerror != 0 ]
then
echo "WARNING: could not list CMSSW versions with scramv1"
fi
touch scramv1_list_output.txt
cat scramv1_list_output.txt | tr -s " " | cut -d " " -f2 | sort -u > cmssw_installed_${arch}.txt
rm -f scramv1_list_output.txt
cat cmssw_installed_${arch}.txt >> cmssw_installed_version_list.txt
if [ -d $CMS_PATH/${arch}/cms/cms-common/1.0 ]; then
echo "Recent cms-common RPM already installed:"
ls -d $CMS_PATH/${arch}/cms/cms-common/1.0/* | grep -v etc
else
echo "Old style cms-common RPM installed."
fi
echo
done
echo "<h2>Verify creation of work area for some CMSSW version(s)</h2>"
missing=0
failproject=0
failrunt=0
for cmsver in `cat $SAME_SENSOR_HOME/tests/cmssw_required_version_list.txt`
for cmsver in `cat cmssw_required_version_list.txt`
do
grep -x $cmsver cmssw_installed_version_list.txt >& /dev/null
result=$?
if [ $result != 0 ]
then
echo "<p><strong>"
echo "Required CMSSW version $cmsver not installed"
echo "</strong></p>"
missing=1
else
echo "<p>Checking version $cmsver installation</p>"
# execute in a subprocess commands that require scram
$SAME_SENSOR_HOME/tests/TestCmsswVersion.sh $cmsver
TestResult=$?
if [ $TestResult != 0 ]
grep -x $cmsver cmssw_installed_version_list.txt >& /dev/null
result=$?
if [ $result != 0 ]
then
failproject=1
echo "ERROR: Required CMSSW version $cmsver not installed"
error=1
errorSummary="REQ_CMSSW_NOT_FOUND"
else
echo "Checking version $cmsver installation..."
# execute in a subprocess commands that require scram
$SAME_SENSOR_HOME/tests/TestCmsswVersion.sh $cmsver
TestResult=$?
if [ $TestResult != 0 ]
then
error=1
echo "ERROR: Some of the required CMSSW versions not working"
errorSummary="summary: REQ_CMSSW_NOT_WORKING"
fi
fi
fi
done
echo "<h2> No Verify Architecture Tags anymore</h2>"
# check that installed version list matches published tags
retrieve_published_list_fail=0
empty_tag_list=0
missing_arch_tag=0
missing_version_tag=0
missing_published_version=0
missing_production_release=0
#Removed all code for checking of architecture tags.
# Check for Python2.6 installation needed for WMAgent
# Check for a SW tag to be added
no_comp_area=0
no_phython_found=0
echo "<h2>Check for Python2.6 for WMAgent</h2>"
echo
echo "Check for Python2.6 for WMAgent..."
wma_arch=slc5_amd64_gcc434
if [ -d $CMS_PATH/COMP ]; then
echo "<p>COMP area appears to exist</p>"
if [ -d $CMS_PATH/COMP/slc5_amd64_gcc434/external/python ]; then
declare -a PYTHON26
PYTHON26=($(ls $CMS_PATH/COMP/slc5_amd64_gcc434/external/python |
grep 2.6))
N_PYTHON26=${#PYTHON26[*]}
if [ $N_PYTHON26 -lt 1 ]; then
echo "<p>ERROR: No Python2.6 installed in COMP area. It is broken!</p>"
no_python_found=1
else
echo "<p>This/These $N_PYTHON26 Python2.6 version(s) is/are existing:</p>"
echo "<pre>"
echo "${PYTHON26[@]}"
echo "</pre>"
echo "<p>OK</p>"
if [ -d $CMS_PATH/COMP/$wma_arch/external/python ]; then
declare -a PYTHON26
PYTHON26=($(ls $CMS_PATH/COMP/$wma_arch/external/python | grep 2.6))
N_PYTHON26=${#PYTHON26[*]}
if [ $N_PYTHON26 -lt 1 ]; then
error=1
echo "ERROR: No Python2.6 installed in COMP area. It is broken!"
errorSummary="summary: NO_PYTHON26_FOUND"
else
echo "These Python2.6 versions exist:"
echo "${PYTHON26[@]}"
fi
else
error=1
echo "ERROR: No Python releases found in COMP area - it's broken!"
errorSummary="summary: NO_PYTHON_FOUND"
fi
else
echo "ERROR: No Python releases found in COMP area - it's broken!"
no_python_found=1
fi
else
echo "<p>WARNING: No COMP area found</p>"
no_comp_area=1
fi
echo "<hr />"
echo '<h1><a name="summary"> Test Summary</a></h1>'
if [ $retrieve_published_list_fail == 1 ]
then
echo "<p>NOTICE: Fail to retrieve list of published tags from cmsdoc</p>"
note=1
fi
if [ $missing_production_release == 1 ]
then
echo "<p>NOTICE: One or more production releases are not installed</p>"
notice=1
fi
if [ $cantwrite == 1 ]
then
echo "<p>WARNING: Cannot write to CMSSW installation area</p>"
warning=1
fi
if [ $missing == 1 ]
then
echo "<p>WARNING: Some of the required CMSSW versions not found</p>"
warning=1
fi
if [ $empty_tag_list == 1 ]
then
echo "<p>WARNING: No CMS tags are published</p>"
warning=1
fi
if [ $missing_version_tag == 1 ]
then
echo "<p>INFO: Some CMS VO Tags are missing</p>"
# Change in Jan 2014 - Info is OK, no warning in Nagios
# With CVMFS and Glideins we anyhow do not really care.
info=1
fi
if [ $missing_arch_tag == 1 ]
then
echo "<p>WARNING: Needed CMS VO architecture TAG not published</p>"
warning=1
fi
if [ $missing_published_version == 1 ]
then
echo "<p>ERROR: Some CMSSW version published but not present</p>"
error=1
fi
if [[ $failproject == 1 || $failrunt == 1 ]]
then
echo "<p>Some of the required CMSSW versions not working</p>"
error=1
warning=1
echo "WARNING: No COMP area found"
echo "summary: NO_COMP_AREA"
fi
echo
if [[ $error == 1 ]]
then
echo "<p><strong> ERROR </strong></p>"
exit $SAME_ERROR
echo $errorSummary
exit $SAME_ERROR
fi
if [[ $warning == 1 ]]
then
echo "<p><strong> WARNING </strong></p>"
exit $SAME_WARNING
fi
if [ $notice == 1 ]
then
echo "<p><strong> NOTE </strong></p>"
exit $SAME_NOTICE
fi
if [ $info == 1 ]
then
echo "<p><strong> INFO </strong></p>"
exit $SAME_INFO
echo $errorSummary
exit $SAME_WARNING
fi
echo "<p><strong> OK </strong></p>"
echo "All checks OK"
echo "summary: OK"
exit $SAME_OK
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment