|
Packit |
857059 |
#!/bin/bash
|
|
Packit |
857059 |
# BEGIN_ICS_COPYRIGHT8 ****************************************
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# Copyright (c) 2015-2018, Intel Corporation
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# Redistribution and use in source and binary forms, with or without
|
|
Packit |
857059 |
# modification, are permitted provided that the following conditions are met:
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# * Redistributions of source code must retain the above copyright notice,
|
|
Packit |
857059 |
# this list of conditions and the following disclaimer.
|
|
Packit |
857059 |
# * Redistributions in binary form must reproduce the above copyright
|
|
Packit |
857059 |
# notice, this list of conditions and the following disclaimer in the
|
|
Packit |
857059 |
# documentation and/or other materials provided with the distribution.
|
|
Packit |
857059 |
# * Neither the name of Intel Corporation nor the names of its contributors
|
|
Packit |
857059 |
# may be used to endorse or promote products derived from this software
|
|
Packit |
857059 |
# without specific prior written permission.
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
Packit |
857059 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
Packit |
857059 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
Packit |
857059 |
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
Packit |
857059 |
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
Packit |
857059 |
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
Packit |
857059 |
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
Packit |
857059 |
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
Packit |
857059 |
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
Packit |
857059 |
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
857059 |
#
|
|
Packit |
857059 |
# END_ICS_COPYRIGHT8 ****************************************
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# [ICS VERSION STRING: unknown]
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# Usage: opacablehealthcron
|
|
Packit |
857059 |
# At regular intervals executes cablehealth and saves the data in a file
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Usage_full()
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
echo "Usage: opacablehealthcron" >&2
|
|
Packit |
857059 |
echo " opacablehealthcron --help" >&2
|
|
Packit |
857059 |
echo " --help - produce full help text" >&2
|
|
Packit |
857059 |
echo "This script will at regular intervals execute opareport -o cablehealth" >&2
|
|
Packit |
857059 |
echo "The output of the program is stored in an already specified location" >&2
|
|
Packit |
857059 |
echo "It is defined in FF_CABLE_HEALTH_REPORT_DIR of opafastfabric.conf" >&2
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
Usage()
|
|
Packit |
857059 |
{
|
|
Packit |
857059 |
Usage_full
|
|
Packit |
857059 |
exit 2
|
|
Packit |
857059 |
}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ x"$1" = "x--help" ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
Usage_full
|
|
Packit |
857059 |
exit 0
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ -f /usr/lib/opa/tools/ff_funcs ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
. /usr/lib/opa/tools/ff_funcs
|
|
Packit |
857059 |
ff_available=y
|
|
Packit |
857059 |
else
|
|
Packit |
857059 |
ff_available=n
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
if [ $ff_available = "y" ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
if [ -f $CONFIG_DIR/opa/opafastfabric.conf ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
. $CONFIG_DIR/opa/opafastfabric.conf
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
. /usr/lib/opa/tools/opafastfabric.conf.def
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# Check if is the master FM
|
|
Packit |
857059 |
# For nodes with FM running as master, BaseLID and SMLId will be same
|
|
Packit |
857059 |
# In Multi-rail the SM could be linked to any one of the HFI, PORT combinations
|
|
Packit |
857059 |
# In Multi-plane master SM for each fabric could be linked to any of the HFI, PORT combinations
|
|
Packit |
857059 |
if [ "$ff_available" = y ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
check_ports_args opacablehealthcron
|
|
Packit |
857059 |
else
|
|
Packit |
857059 |
PORTS='0:0'
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
for hfi_port in $PORTS
|
|
Packit |
857059 |
do
|
|
Packit |
857059 |
hfi=$(expr $hfi_port : '\([0-9]*\):[0-9]*')
|
|
Packit |
857059 |
port=$(expr $hfi_port : '[0-9]*:\([0-9]*\)')
|
|
Packit |
857059 |
if [ "$hfi" = "" -o "$port" = "" ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "opacablehealthcron: Error: Invalid port specification: $hfi_port" >&2
|
|
Packit |
857059 |
continue
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
## fixup name so winzip won't complain
|
|
Packit |
857059 |
hfi_port_dir=${hfi}_${port}
|
|
Packit |
857059 |
|
|
Packit |
857059 |
# For nodes with FM running as master, LID and MasterSMLID will be same
|
|
Packit |
857059 |
baseLid=`/usr/sbin/opasmaquery -h $hfi -p $port -o portinfo -g 2>/dev/null| sed -ne '/\bLID\b/ s/.*: *//p'`
|
|
Packit |
857059 |
smLid=`/usr/sbin/opasmaquery -h $hfi -p $port -o portinfo -g 2>/dev/null| sed -ne '/\bMasterSMLID\b/ s/.*: *//p'`
|
|
Packit |
857059 |
#Store HFI of device connected to SM
|
|
Packit |
857059 |
if [ "$baseLid" != "$smLid" ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
continue;
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
|
|
Packit |
857059 |
echo "Periodic generation of Cable Health Report"
|
|
Packit |
857059 |
# create cable health report directory and generate report
|
|
Packit |
857059 |
if [ $ff_available = "y" ] && [ -n "${FF_CABLE_HEALTH_REPORT_DIR}" ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
echo "Gathering Cable Health Report ..."
|
|
Packit |
857059 |
# Directory name with HFI and PORT
|
|
Packit |
857059 |
FF_CABLE_HEALTH_REPORT_DIR_WITH_HFI_PORT="${FF_CABLE_HEALTH_REPORT_DIR}/${hfi_port_dir}/"
|
|
Packit |
857059 |
mkdir -p ${FF_CABLE_HEALTH_REPORT_DIR_WITH_HFI_PORT}
|
|
Packit |
857059 |
# Maintain the number of cable health report files at FF_CABLE_HEALTH_MAX_FILES
|
|
Packit |
857059 |
if [ -n "${FF_CABLE_HEALTH_MAX_FILES}" ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
files_in_dir=`ls ${FF_CABLE_HEALTH_REPORT_DIR_WITH_HFI_PORT} | wc -l `
|
|
Packit |
857059 |
files_to_delete=`expr $files_in_dir - ${FF_CABLE_HEALTH_MAX_FILES}`
|
|
Packit |
857059 |
if [ $files_to_delete -gt 0 ]
|
|
Packit |
857059 |
then
|
|
Packit |
857059 |
find ${FF_CABLE_HEALTH_REPORT_DIR_WITH_HFI_PORT} -name "cablehealth*" -maxdepth 1 -type f 2>/dev/null | xargs -r ls -1tr | head -n $files_to_delete | xargs -r rm
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
/usr/sbin/opareport -h $hfi -p $port -o cablehealth 2>/dev/null >${FF_CABLE_HEALTH_REPORT_DIR_WITH_HFI_PORT}/cablehealth$(date "+%Y%m%d%H%M%S").csv
|
|
Packit |
857059 |
fi
|
|
Packit |
857059 |
done
|
|
Packit |
857059 |
|
|
Packit |
857059 |
echo "Done."
|
|
Packit |
857059 |
|
|
Packit |
857059 |
exit 0
|