Fix linters error and enable linters zuul gate

Fix below linters errors
E010 The "do" should be on same line as for
E010 The "do" should be on same line as while
E011 Then keyword is not on same line as if or elif keyword
E020 Function declaration not in format ^function name {$

Ignore:
E041 Arithmetic expansion using $[ is deprecated for $((
E042 local declaration hides errors
E043 Arithmetic compound has inconsistent return semantics
E044 Use [[ for non-POSIX comparisions

Story: 2003366
Task: 24423

Change-Id: I8b6b72e702d3e89d1813772d6bf16819e28e818c
Signed-off-by: Martin Chen <haochuan.z.chen@intel.com>
This commit is contained in:
Martin Chen 2018-09-05 01:10:16 +08:00
parent cd6ab2c913
commit 4a2f55eed2
25 changed files with 112 additions and 189 deletions

View File

@ -14,8 +14,7 @@ SERVICE="ceph"
LOGFILE="${extradir}/ceph.info" LOGFILE="${extradir}/ceph.info"
echo "${hostname}: Ceph Info .........: ${LOGFILE}" echo "${hostname}: Ceph Info .........: ${LOGFILE}"
function is_service_active() function is_service_active {
{
active=`sm-query service management-ip | grep "enabled-active"` active=`sm-query service management-ip | grep "enabled-active"`
if [ -z "$active" ] ; then if [ -z "$active" ] ; then
return 0 return 0
@ -24,8 +23,7 @@ function is_service_active()
fi fi
} }
function exit_if_timeout() function exit_if_timeout {
{
if [ "$?" = "124" ] ; then if [ "$?" = "124" ] ; then
echo "Exiting due to ceph command timeout" >> ${LOGFILE} echo "Exiting due to ceph command timeout" >> ${LOGFILE}
exit 0 exit 0

View File

@ -10,8 +10,7 @@
source /usr/local/sbin/collect_parms source /usr/local/sbin/collect_parms
source /usr/local/sbin/collect_utils source /usr/local/sbin/collect_utils
function is_extended_profile() function is_extended_profile {
{
if [ ! -n "${security_profile}" ] || [ "${security_profile}" != "extended" ]; then if [ ! -n "${security_profile}" ] || [ "${security_profile}" != "extended" ]; then
return 0 return 0
else else

View File

@ -12,8 +12,7 @@ source /usr/local/sbin/collect_utils
LOGFILE="${extradir}/nfv-vim.info" LOGFILE="${extradir}/nfv-vim.info"
echo "${hostname}: NFV-Vim Info ......: ${LOGFILE}" echo "${hostname}: NFV-Vim Info ......: ${LOGFILE}"
function is_service_active() function is_service_active {
{
active=`sm-query service vim | grep "enabled-active"` active=`sm-query service vim | grep "enabled-active"`
if [ -z "$active" ] ; then if [ -z "$active" ] ; then
return 0 return 0

View File

@ -10,8 +10,7 @@
source /usr/local/sbin/collect_parms source /usr/local/sbin/collect_parms
source /usr/local/sbin/collect_utils source /usr/local/sbin/collect_utils
function is_service_active() function is_service_active {
{
active=`sm-query service rabbit-fs | grep "enabled-active"` active=`sm-query service rabbit-fs | grep "enabled-active"`
if [ -z "$active" ] ; then if [ -z "$active" ] ; then
return 0 return 0

View File

@ -19,8 +19,7 @@ DB_DIR="${extradir}/database"
LOGFILE="${extradir}/database.info" LOGFILE="${extradir}/database.info"
echo "${hostname}: Database Info .....: ${LOGFILE}" echo "${hostname}: Database Info .....: ${LOGFILE}"
function is_service_active() function is_service_active {
{
active=`sm-query service postgres | grep "enabled-active"` active=`sm-query service postgres | grep "enabled-active"`
if [ -z "$active" ] ; then if [ -z "$active" ] ; then
return 0 return 0
@ -34,11 +33,9 @@ function is_service_active()
############################################################################### ###############################################################################
mkdir -p ${DB_DIR} mkdir -p ${DB_DIR}
function log_database() function log_database {
{
db_list=( $(${PSQL_CMD} -t -c "SELECT datname FROM pg_database WHERE datistemplate = false;") ) db_list=( $(${PSQL_CMD} -t -c "SELECT datname FROM pg_database WHERE datistemplate = false;") )
for db in "${db_list[@]}" for db in "${db_list[@]}"; do
do
echo "postgres database: ${db}" echo "postgres database: ${db}"
${PSQL_CMD} -d ${db} -c " ${PSQL_CMD} -d ${db} -c "
SELECT SELECT
@ -75,12 +72,10 @@ function log_database()
DB_EXT=db.sql.txt DB_EXT=db.sql.txt
function database_dump() function database_dump {
{
mkdir -p ${DB_DIR} mkdir -p ${DB_DIR}
db_list=( $(${PSQL_CMD} -t -c "SELECT datname FROM pg_database WHERE datistemplate = false;") ) db_list=( $(${PSQL_CMD} -t -c "SELECT datname FROM pg_database WHERE datistemplate = false;") )
for DB in "${db_list[@]}" for DB in "${db_list[@]}"; do
do
if [ "$DB" != "keystone" -a "$DB" != "ceilometer" ] ; then if [ "$DB" != "keystone" -a "$DB" != "ceilometer" ] ; then
echo "${hostname}: Dumping Database ..: ${DB_DIR}/$DB.$DB_EXT" echo "${hostname}: Dumping Database ..: ${DB_DIR}/$DB.$DB_EXT"
(cd ${DB_DIR} ; sudo -u postgres pg_dump $DB > $DB.$DB_EXT) (cd ${DB_DIR} ; sudo -u postgres pg_dump $DB > $DB.$DB_EXT)

View File

@ -14,8 +14,7 @@ SERVICE="inventory"
LOGFILE="${extradir}/${SERVICE}.info" LOGFILE="${extradir}/${SERVICE}.info"
RPMLOG="${extradir}/rpm.info" RPMLOG="${extradir}/rpm.info"
function is_service_active() function is_service_active {
{
active=`sm-query service management-ip | grep "enabled-active"` active=`sm-query service management-ip | grep "enabled-active"`
if [ -z "$active" ] ; then if [ -z "$active" ] ; then
return 0 return 0

View File

@ -27,8 +27,8 @@ fi
delimiter ${LOGFILE} "ip link" delimiter ${LOGFILE} "ip link"
ip link >> ${LOGFILE} ip link >> ${LOGFILE}
for i in $(ip link | grep mtu | grep eth |awk '{print $2}' | sed 's#:##g'); for i in $(ip link | grep mtu | grep eth |awk '{print $2}' | sed 's#:##g'); do
do
delimiter ${LOGFILE} "ethtool ${i}" delimiter ${LOGFILE} "ethtool ${i}"
ethtool ${i} >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG} ethtool ${i} >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG}
@ -55,8 +55,8 @@ fi
delimiter ${LOGFILE} "tc qdisc show" delimiter ${LOGFILE} "tc qdisc show"
tc qdisc show >> ${LOGFILE} tc qdisc show >> ${LOGFILE}
for i in $(ip link | grep htb | awk '{print $2}' | sed 's#:##g'); for i in $(ip link | grep htb | awk '{print $2}' | sed 's#:##g'); do
do
delimiter ${LOGFILE} "tc class show dev ${i}" delimiter ${LOGFILE} "tc class show dev ${i}"
tc class show dev ${i} >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG} tc class show dev ${i} >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG}
@ -70,8 +70,8 @@ done
delimiter ${LOGFILE} "tc -s qdisc show" delimiter ${LOGFILE} "tc -s qdisc show"
tc -s qdisc show >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG} tc -s qdisc show >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG}
for i in $(ip link | grep htb | awk '{print $2}' | sed 's#:##g'); for i in $(ip link | grep htb | awk '{print $2}' | sed 's#:##g'); do
do
delimiter ${LOGFILE} "tc -s class show dev ${i}" delimiter ${LOGFILE} "tc -s class show dev ${i}"
tc -s class show dev ${i} >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG} tc -s class show dev ${i} >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG}

View File

@ -14,8 +14,7 @@ fi
OPT_USE_INTERVALS=1 OPT_USE_INTERVALS=1
# Print key ceph statistics # Print key ceph statistics
function print_ceph() function print_ceph {
{
print_separator print_separator
TOOL_HIRES_TIME TOOL_HIRES_TIME
@ -47,8 +46,7 @@ tools_header
# Calculate number of sample repeats based on overall interval and sampling interval # Calculate number of sample repeats based on overall interval and sampling interval
((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC)) ((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC))
for ((rep=1; rep <= REPEATS ; rep++)) for ((rep=1; rep <= REPEATS ; rep++)); do
do
print_ceph print_ceph
sleep ${INTERVAL_SEC} sleep ${INTERVAL_SEC}
done done

View File

@ -32,14 +32,12 @@ LOG "Cleanup engtools:"
# ( be sure not to clobber /etc/init.d/collect-engtools.sh ) # ( be sure not to clobber /etc/init.d/collect-engtools.sh )
LOG "kill processes brute force" LOG "kill processes brute force"
pids=( $(pidof -x /usr/local/bin/collect-engtools.sh) ) pids=( $(pidof -x /usr/local/bin/collect-engtools.sh) )
if [ ${#pids[@]} -ne 0 ] if [ ${#pids[@]} -ne 0 ]; then
then
LOG "killing: ${pids[@]}" LOG "killing: ${pids[@]}"
for pid in ${pids[@]} for pid in ${pids[@]}; do
do LOG "kill: [ ${pid} ] "
LOG "kill: [ ${pid} ] " pkill -KILL -P ${pid}
pkill -KILL -P ${pid} kill -9 ${pid}
kill -9 ${pid}
done done
pkill -KILL iostat pkill -KILL iostat
pkill -KILL top pkill -KILL top
@ -48,8 +46,7 @@ else
fi fi
LOG "remove pidfiles" LOG "remove pidfiles"
for TOOL in "${TOOLS[@]}" for TOOL in "${TOOLS[@]}"; do
do
rm -f -v /var/run/${TOOL}.pid rm -f -v /var/run/${TOOL}.pid
done done
LOG "done" LOG "done"

View File

@ -48,11 +48,9 @@ declare tgt_avail_bytes
declare tgt_used_bytes declare tgt_used_bytes
# do_parallel_commands - launch parallel tools with separate output files # do_parallel_commands - launch parallel tools with separate output files
function do_parallel_commands() function do_parallel_commands {
{
parallel_outfiles=() parallel_outfiles=()
for elem in "${tlist[@]}" for elem in "${tlist[@]}"; do
do
tool=""; period=""; repeat=""; interval="" tool=""; period=""; repeat=""; interval=""
my_hash="elem[*]" my_hash="elem[*]"
local ${!my_hash} local ${!my_hash}
@ -75,8 +73,7 @@ function do_parallel_commands()
# get_current_avail_usage() - get output destination file-system usage and # get_current_avail_usage() - get output destination file-system usage and
# availability. # availability.
# - updates: df_size_bytes, df_avail_bytes, du_used_bytes # - updates: df_size_bytes, df_avail_bytes, du_used_bytes
function get_current_avail_usage() function get_current_avail_usage {
{
local -a df_arr_bytes=( $(df -P --block-size=1 ${TOOL_DEST_DIR} | awk 'NR==2 {print $2, $4}') ) local -a df_arr_bytes=( $(df -P --block-size=1 ${TOOL_DEST_DIR} | awk 'NR==2 {print $2, $4}') )
df_size_bytes=${df_arr_bytes[0]} df_size_bytes=${df_arr_bytes[0]}
df_avail_bytes=${df_arr_bytes[1]} df_avail_bytes=${df_arr_bytes[1]}
@ -85,8 +82,7 @@ function get_current_avail_usage()
# purge_oldest_files() - remove oldest files based on file-system available space, # purge_oldest_files() - remove oldest files based on file-system available space,
# and maximum collection size # and maximum collection size
function purge_oldest_files() function purge_oldest_files {
{
# get current file-system usage # get current file-system usage
get_current_avail_usage get_current_avail_usage
msg=$(printf "avail %d MB, headroom %d MB; used %d MB, max %d MB" \ msg=$(printf "avail %d MB, headroom %d MB; used %d MB, max %d MB" \
@ -116,8 +112,7 @@ function purge_oldest_files()
# remove files in oldest time sorted order until we meet usage targets, # remove files in oldest time sorted order until we meet usage targets,
# incrementally updating usage as we remve files # incrementally updating usage as we remve files
for file in $( ls -rt ${TOOL_DEST_DIR}/${HOSTNAME}_* 2>/dev/null ) for file in $( ls -rt ${TOOL_DEST_DIR}/${HOSTNAME}_* 2>/dev/null ); do
do
if [[ $df_avail_bytes -ge $tgt_avail_bytes ]] && \ if [[ $df_avail_bytes -ge $tgt_avail_bytes ]] && \
[[ $du_used_bytes -le $tgt_used_bytes ]]; then [[ $du_used_bytes -le $tgt_used_bytes ]]; then
break break
@ -307,9 +302,7 @@ REP=0
if [ ${#tlist[@]} -ne 0 ]; then if [ ${#tlist[@]} -ne 0 ]; then
# Static stats collection is turned on # Static stats collection is turned on
while [[ ${TOOL_USR1_SIGNAL} -eq 0 ]] && while [[ ${TOOL_USR1_SIGNAL} -eq 0 ]] && [[ ${OPT_FOREVER} -eq 1 || ${REP} -lt ${REPEATS} ]]; do
[[ ${OPT_FOREVER} -eq 1 || ${REP} -lt ${REPEATS} ]]
do
# increment loop counter # increment loop counter
((REP++)) ((REP++))

View File

@ -14,8 +14,7 @@ fi
OPT_USE_INTERVALS=1 OPT_USE_INTERVALS=1
# Print disk summary # Print disk summary
function print_disk() function print_disk {
{
print_separator print_separator
TOOL_HIRES_TIME TOOL_HIRES_TIME
@ -57,8 +56,7 @@ function print_disk()
} }
# Print disk static summary # Print disk static summary
function print_disk_static() function print_disk_static {
{
print_separator print_separator
cmd='cat /proc/scsi/scsi' cmd='cat /proc/scsi/scsi'
${ECHO} "Attached devices: ${cmd}" ${ECHO} "Attached devices: ${cmd}"
@ -109,8 +107,7 @@ print_disk_static
# Calculate number of sample repeats based on overall interval and sampling interval # Calculate number of sample repeats based on overall interval and sampling interval
((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC)) ((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC))
for ((rep=1; rep <= REPEATS ; rep++)) for ((rep=1; rep <= REPEATS ; rep++)); do
do
print_disk print_disk
sleep ${INTERVAL_SEC} sleep ${INTERVAL_SEC}
done done

View File

@ -24,8 +24,7 @@ else
. /etc/init.d/functions . /etc/init.d/functions
fi fi
# Lightweight replacement for pidofproc -p <pid> # Lightweight replacement for pidofproc -p <pid>
function check_pidfile () function check_pidfile {
{
local pidfile pid local pidfile pid
OPTIND=1 OPTIND=1
@ -53,8 +52,7 @@ function check_pidfile ()
} }
# tools_init - initialize tool resources # tools_init - initialize tool resources
function tools_init () function tools_init {
{
local rc=0 local rc=0
local error=0 local error=0
TOOLNAME=$(basename $0) TOOLNAME=$(basename $0)
@ -199,7 +197,7 @@ function tools_init ()
} }
# tools_cleanup() - terminate child processes # tools_cleanup() - terminate child processes
function tools_cleanup() { function tools_cleanup {
# restore signal handling to default behaviour # restore signal handling to default behaviour
trap - INT HUP TERM EXIT trap - INT HUP TERM EXIT
trap - USR1 USR2 trap - USR1 USR2
@ -230,43 +228,47 @@ function tools_cleanup() {
} }
# tools_exit_handler() - exit handler routine # tools_exit_handler() - exit handler routine
function tools_exit_handler() { function tools_exit_handler {
TOOL_EXIT_SIGNAL=1 TOOL_EXIT_SIGNAL=1
tools_cleanup 128 tools_cleanup 128
} }
# tools_usr1_handler() - USR1 handler routine # tools_usr1_handler() - USR1 handler routine
function tools_usr1_handler() { function tools_usr1_handler {
TOOL_USR1_SIGNAL=1 TOOL_USR1_SIGNAL=1
LOG "caught USR1" LOG "caught USR1"
} }
# tools_usr2_handler() - USR2 handler routine # tools_usr2_handler() - USR2 handler routine
function tools_usr2_handler() { function tools_usr2_handler {
TOOL_USR2_SIGNAL=1 TOOL_USR2_SIGNAL=1
LOG "caught USR1" LOG "caught USR1"
} }
# LOG(), WARNLOG(), ERRLOG() - simple print log functions (not logger) # LOG(), WARNLOG(), ERRLOG() - simple print log functions (not logger)
function LOG () function LOG {
{
local tstamp_H=$( date +"%Y-%0m-%0e %H:%M:%S" ) local tstamp_H=$( date +"%Y-%0m-%0e %H:%M:%S" )
echo "${tstamp_H} ${HOSTNAME} $0($$): $@"; echo "${tstamp_H} ${HOSTNAME} $0($$): $@";
} }
function LOG_NOCR ()
{ function LOG_NOCR {
local tstamp_H=$( date +"%Y-%0m-%0e %H:%M:%S" ) local tstamp_H=$( date +"%Y-%0m-%0e %H:%M:%S" )
echo -n "${tstamp_H} ${HOSTNAME} $0($$): $@"; echo -n "${tstamp_H} ${HOSTNAME} $0($$): $@";
} }
function WARNLOG () { LOG "WARN $@"; }
function ERRLOG () { LOG "ERROR $@"; } function WARNLOG {
LOG "WARN $@";
}
function ERRLOG {
LOG "ERROR $@";
}
# TOOL_HIRES_TIME() - easily parsed date/timestamp and hi-resolution uptime # TOOL_HIRES_TIME() - easily parsed date/timestamp and hi-resolution uptime
function TOOL_HIRES_TIME() function TOOL_HIRES_TIME {
{
echo "time: " $( ${DATE} +"%a %F %H:%M:%S.%N %Z %z" ) "uptime: " $( cat /proc/uptime ) echo "time: " $( ${DATE} +"%a %F %H:%M:%S.%N %Z %z" ) "uptime: " $( cat /proc/uptime )
} }
# set_affinity() - set affinity for current script if a a CPULIST is defined # set_affinity() - set affinity for current script if a a CPULIST is defined
function set_affinity() { function set_affinity {
local CPULIST=$1 local CPULIST=$1
if [ -z "${CPULIST}" ]; then if [ -z "${CPULIST}" ]; then
return return
@ -280,7 +282,7 @@ function set_affinity() {
} }
# cmd_idle_priority() - command to set nice + ionice # cmd_idle_priority() - command to set nice + ionice
function cmd_idle_priority() { function cmd_idle_priority {
local NICE="" local NICE=""
local IONICE="" local IONICE=""
@ -301,13 +303,13 @@ function cmd_idle_priority() {
# print_separator() - print a horizontal separation line '\u002d' is '-' # print_separator() - print a horizontal separation line '\u002d' is '-'
function print_separator () { function print_separator {
printf '\u002d%.s' {1..80} printf '\u002d%.s' {1..80}
printf '\n' printf '\n'
} }
# tools_header() - print out common GenWare tools header # tools_header() - print out common GenWare tools header
function tools_header() { function tools_header {
local TOOLNAME=$(basename $0) local TOOLNAME=$(basename $0)
# Get timestamp # Get timestamp
@ -393,7 +395,7 @@ function tools_header() {
# tools_usage() - show generic tools tool usage # tools_usage() - show generic tools tool usage
function tools_usage() { function tools_usage {
if [ ${OPT_USE_INTERVALS} -eq 1 ]; then if [ ${OPT_USE_INTERVALS} -eq 1 ]; then
echo "usage: ${TOOLNAME} [-f] [-p <period_mins>] [-i <interval_seconds>] [-c <cpulist>] [-h]" echo "usage: ${TOOLNAME} [-f] [-p <period_mins>] [-i <interval_seconds>] [-c <cpulist>] [-h]"
else else
@ -402,7 +404,7 @@ function tools_usage() {
} }
# tools_print_help() - print generic tool help # tools_print_help() - print generic tool help
function tools_print_help() { function tools_print_help {
tools_usage tools_usage
echo echo
echo "Options:"; echo "Options:";
@ -423,7 +425,7 @@ function tools_print_help() {
} }
# tools_parse_options() -- parse common options for tools scripts # tools_parse_options() -- parse common options for tools scripts
function tools_parse_options() { function tools_parse_options {
# check for no arguments, print usage # check for no arguments, print usage
if [ $# -eq "0" ]; then if [ $# -eq "0" ]; then
tools_usage tools_usage
@ -432,8 +434,7 @@ function tools_parse_options() {
fi fi
# parse the input arguments # parse the input arguments
while getopts "fp:i:c:h" Option while getopts "fp:i:c:h" Option; do
do
case $Option in case $Option in
f) f)
OPT_FOREVER=1 OPT_FOREVER=1

View File

@ -16,8 +16,7 @@ PAGE_SIZE=$(getconf PAGE_SIZE)
OPT_USE_INTERVALS=1 OPT_USE_INTERVALS=1
function print_files() function print_files {
{
print_separator print_separator
TOOL_HIRES_TIME TOOL_HIRES_TIME
@ -85,8 +84,7 @@ tools_header
# Calculate number of sample repeats based on overall interval and sampling interval # Calculate number of sample repeats based on overall interval and sampling interval
((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC)) ((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC))
for ((rep=1; rep <= REPEATS ; rep++)) for ((rep=1; rep <= REPEATS ; rep++)); do
do
print_files print_files
sleep ${INTERVAL_SEC} sleep ${INTERVAL_SEC}
done done

View File

@ -69,8 +69,7 @@ case $1 in
stop) stop)
if [ -e ${PIDFILE} ]; then if [ -e ${PIDFILE} ]; then
pids=$(pidof -x ${NAME}) pids=$(pidof -x ${NAME})
if [[ ! -z "${pids}" ]] if [[ ! -z "${pids}" ]]; then
then
echo_success "Stopping ${NAME} [$pid]" echo_success "Stopping ${NAME} [$pid]"
start-stop-daemon --stop --quiet --oknodo --pidfile ${PIDFILE} --retry=TERM/3/KILL/5 start-stop-daemon --stop --quiet --oknodo --pidfile ${PIDFILE} --retry=TERM/3/KILL/5
# [ JGAULD: none of the following should be necessary ] # [ JGAULD: none of the following should be necessary ]

View File

@ -29,8 +29,7 @@ compute_ports=(8000 8001 8002)
traffic_types=(storage migration default drbd) traffic_types=(storage migration default drbd)
flow_ids=(1:20 1:30 1:40 1:50) flow_ids=(1:20 1:30 1:40 1:50)
function exec_cmd () function exec_cmd {
{
node="$1" node="$1"
cmd="$2" cmd="$2"
@ -41,8 +40,7 @@ function exec_cmd ()
fi fi
} }
function iperf3_server_start () function iperf3_server_start {
{
local server="$1" local server="$1"
local result="$2" local result="$2"
local port="$3" local port="$3"
@ -55,8 +53,7 @@ function iperf3_server_start ()
$(exec_cmd "${server}" "${cmd}") $(exec_cmd "${server}" "${cmd}")
} }
function iperf3_client_tcp_start () function iperf3_client_tcp_start {
{
local result="${result_dir}/throughput" local result="${result_dir}/throughput"
local cmd="" local cmd=""
local client="$1" local client="$1"
@ -76,8 +73,7 @@ function iperf3_client_tcp_start ()
$(exec_cmd "${client}" "${cmd} > ${result} 2>&1") $(exec_cmd "${client}" "${cmd} > ${result} 2>&1")
} }
function iperf3_client_udp_start () function iperf3_client_udp_start {
{
local result="${result_dir}/throughput_udp" local result="${result_dir}/throughput_udp"
local cmd="" local cmd=""
local client="$1" local client="$1"
@ -102,20 +98,17 @@ function iperf3_client_udp_start ()
$(exec_cmd "${client}" "${cmd} -b ${bw} >> ${result} 2>&1" ) $(exec_cmd "${client}" "${cmd} -b ${bw} >> ${result} 2>&1" )
} }
function iperf3_stop () function iperf3_stop {
{
local node="$1" local node="$1"
local cmd="pkill iperf3" local cmd="pkill iperf3"
$(exec_cmd "${node}" "${cmd}") $(exec_cmd "${node}" "${cmd}")
} }
function get_ip_addr () function get_ip_addr {
{
arp -a | grep -oP "(?<=$1 \()[^)]*" | head -n 1 arp -a | grep -oP "(?<=$1 \()[^)]*" | head -n 1
} }
function throughput_tcp_test() function throughput_tcp_test {
{
for (( i = 0; i < ${#nodes[@]} ; i+=2 )); do for (( i = 0; i < ${#nodes[@]} ; i+=2 )); do
for interface in "${interfaces[@]}"; do for interface in "${interfaces[@]}"; do
local interface_name="management" local interface_name="management"
@ -137,8 +130,7 @@ function throughput_tcp_test()
done done
} }
function throughput_udp_test () function throughput_udp_test {
{
for (( i = 0; i < ${#nodes[@]} ; i+=2 )); do for (( i = 0; i < ${#nodes[@]} ; i+=2 )); do
for interface in "${interfaces[@]}"; do for interface in "${interfaces[@]}"; do
local interface_name="management" local interface_name="management"
@ -229,8 +221,7 @@ function throughput_udp_test ()
done done
} }
function throughput_parallel_test () function throughput_parallel_test {
{
local dev="" local dev=""
local ip_addr="" local ip_addr=""
local interface_name="" local interface_name=""
@ -304,8 +295,7 @@ function throughput_parallel_test ()
done done
} }
function latency_test () function latency_test {
{
for (( i = 0; i < ${#nodes[@]} ; i+=2 )); do for (( i = 0; i < ${#nodes[@]} ; i+=2 )); do
for interface in "${interfaces[@]}"; do for interface in "${interfaces[@]}"; do
local interface_name="management" local interface_name="management"
@ -328,16 +318,14 @@ function latency_test ()
done done
} }
function setup () function setup {
{
for node in ${nodes[@]}; do for node in ${nodes[@]}; do
iperf3_stop "${node}" iperf3_stop "${node}"
$(exec_cmd "${node}" "rm -rf ${result_dir}; mkdir -p ${result_dir}") $(exec_cmd "${node}" "rm -rf ${result_dir}; mkdir -p ${result_dir}")
done done
} }
function get_remote_results () function get_remote_results {
{
for node in ${nodes[@]}; do for node in ${nodes[@]}; do
if [ "${node}" != "${host}" ]; then if [ "${node}" != "${host}" ]; then
mkdir ${result_dir}/${node} mkdir ${result_dir}/${node}
@ -346,8 +334,7 @@ function get_remote_results ()
done done
} }
function get_interface_info () function get_interface_info {
{
local dev="" local dev=""
local ip_addr="" local ip_addr=""
printf "Network interfaces info\n" >> ${summary_file} printf "Network interfaces info\n" >> ${summary_file}
@ -365,8 +352,7 @@ function get_interface_info ()
done done
} }
function generate_summary () function generate_summary {
{
local header="" local header=""
local result="" local result=""
local result_file="" local result_file=""

View File

@ -16,8 +16,7 @@ PAGE_SIZE=$(getconf PAGE_SIZE)
OPT_USE_INTERVALS=1 OPT_USE_INTERVALS=1
# Print key networking device statistics # Print key networking device statistics
function print_memory() function print_memory {
{
# Configuration for netcmds # Configuration for netcmds
MEMINFO=/proc/meminfo MEMINFO=/proc/meminfo
NODEINFO=/sys/devices/system/node/node?/meminfo NODEINFO=/sys/devices/system/node/node?/meminfo
@ -99,8 +98,7 @@ tools_header
# Calculate number of sample repeats based on overall interval and sampling interval # Calculate number of sample repeats based on overall interval and sampling interval
((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC)) ((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC))
for ((rep=1; rep <= REPEATS ; rep++)) for ((rep=1; rep <= REPEATS ; rep++)); do
do
print_memory print_memory
sleep ${INTERVAL_SEC} sleep ${INTERVAL_SEC}
done done

View File

@ -14,8 +14,7 @@ fi
OPT_USE_INTERVALS=1 OPT_USE_INTERVALS=1
# Print key networking device statistics # Print key networking device statistics
function print_netcmds() function print_netcmds {
{
# Configuration for netcmds # Configuration for netcmds
DEV=/proc/net/dev DEV=/proc/net/dev
NETSTAT=/proc/net/netstat NETSTAT=/proc/net/netstat
@ -26,8 +25,7 @@ function print_netcmds()
for net in \ for net in \
${DEV} ${NETSTAT} ${DEV} ${NETSTAT}
do do
if [ -e "${net}" ] if [ -e "${net}" ]; then
then
${ECHO} "# ${net}" ${ECHO} "# ${net}"
${CAT} ${net} ${CAT} ${net}
${ECHO} ${ECHO}
@ -53,8 +51,7 @@ tools_header
# Calculate number of sample repeats based on overall interval and sampling interval # Calculate number of sample repeats based on overall interval and sampling interval
((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC)) ((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC))
for ((rep=1; rep <= REPEATS ; rep++)) for ((rep=1; rep <= REPEATS ; rep++)); do
do
print_netcmds print_netcmds
sleep ${INTERVAL_SEC} sleep ${INTERVAL_SEC}
done done

View File

@ -14,8 +14,7 @@ fi
OPT_USE_INTERVALS=1 OPT_USE_INTERVALS=1
# Print key networking device statistics # Print key networking device statistics
function print_postgres() function print_postgres {
{
print_separator print_separator
TOOL_HIRES_TIME TOOL_HIRES_TIME
@ -40,8 +39,7 @@ ORDER BY pg_database_size DESC;
" "
# For each database, list tables and their sizes (similar to "\dt+") # For each database, list tables and their sizes (similar to "\dt+")
for db in "${db_list[@]}" for db in "${db_list[@]}"; do
do
${ECHO} "# postgres database: ${db}" ${ECHO} "# postgres database: ${db}"
${PSQL} -d ${db} -c " ${PSQL} -d ${db} -c "
SELECT SELECT
@ -128,8 +126,7 @@ tools_header
# Calculate number of sample repeats based on overall interval and sampling interval # Calculate number of sample repeats based on overall interval and sampling interval
((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC)) ((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC))
for ((rep=1; rep <= REPEATS ; rep++)) for ((rep=1; rep <= REPEATS ; rep++)); do
do
print_postgres print_postgres
sleep ${INTERVAL_SEC} sleep ${INTERVAL_SEC}
done done

View File

@ -15,8 +15,7 @@ OPT_USE_INTERVALS=1
#Need this workaround #Need this workaround
MQOPT="-n rabbit@localhost" MQOPT="-n rabbit@localhost"
# Print key networking device statistics # Print key networking device statistics
function print_rabbitmq() function print_rabbitmq {
{
print_separator print_separator
TOOL_HIRES_TIME TOOL_HIRES_TIME
@ -72,8 +71,7 @@ tools_header
# Calculate number of sample repeats based on overall interval and sampling interval # Calculate number of sample repeats based on overall interval and sampling interval
((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC)) ((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC))
for ((rep=1; rep <= REPEATS ; rep++)) for ((rep=1; rep <= REPEATS ; rep++)); do
do
print_rabbitmq print_rabbitmq
sleep ${INTERVAL_SEC} sleep ${INTERVAL_SEC}
done done

View File

@ -41,8 +41,7 @@ LOG "rsync engtools data from all blades:"
# controllers # controllers
SRC=/scratch/syseng_data/ SRC=/scratch/syseng_data/
DEST=/opt/backups/syseng_data/ DEST=/opt/backups/syseng_data/
for HOST in ${CONTROLLER[@]} for HOST in ${CONTROLLER[@]}; do
do
ping -c1 ${HOST} 1>/dev/null 2>/dev/null ping -c1 ${HOST} 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
LOG "rsync ${RSYNC_OPT} ${USER}@${HOST}:${SRC} ${DEST}" LOG "rsync ${RSYNC_OPT} ${USER}@${HOST}:${SRC} ${DEST}"
@ -55,8 +54,7 @@ done
# computes & storage # computes & storage
SRC=/tmp/syseng_data/ SRC=/tmp/syseng_data/
DEST=/opt/backups/syseng_data/ DEST=/opt/backups/syseng_data/
for HOST in ${STORAGE[@]} ${COMPUTE[@]} for HOST in ${STORAGE[@]} ${COMPUTE[@]}; do
do
ping -c1 ${HOST} 1>/dev/null 2>/dev/null ping -c1 ${HOST} 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
LOG "rsync ${RSYNC_OPT} ${USER}@${HOST}:${SRC} ${DEST}" LOG "rsync ${RSYNC_OPT} ${USER}@${HOST}:${SRC} ${DEST}"

View File

@ -29,8 +29,7 @@ set_affinity ${CPULIST}
LOG_NOCR "collecting " LOG_NOCR "collecting "
t=0 t=0
for ((rep=1; rep <= REPEATS ; rep++)) for ((rep=1; rep <= REPEATS ; rep++)); do
do
((t++)) ((t++))
sleep ${INTERVAL_SEC} sleep ${INTERVAL_SEC}
if [ ${t} -ge ${REP_LOG} ]; then if [ ${t} -ge ${REP_LOG} ]; then

View File

@ -14,8 +14,7 @@ fi
OPT_USE_INTERVALS=1 OPT_USE_INTERVALS=1
# Print key networking device statistics # Print key networking device statistics
function print_vswitch() function print_vswitch {
{
print_separator print_separator
TOOL_HIRES_TIME TOOL_HIRES_TIME
@ -55,8 +54,7 @@ tools_header
# Calculate number of sample repeats based on overall interval and sampling interval # Calculate number of sample repeats based on overall interval and sampling interval
((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC)) ((REPEATS = PERIOD_MIN * 60 / INTERVAL_SEC))
for ((rep=1; rep <= REPEATS ; rep++)) for ((rep=1; rep <= REPEATS ; rep++)); do
do
print_vswitch print_vswitch
sleep ${INTERVAL_SEC} sleep ${INTERVAL_SEC}
done done

View File

@ -12,12 +12,10 @@ MOUNT=/opt/platform
previous=1 previous=1
delay=60 delay=60
while : while : ; do
do
# First, check that it's actually an NFS mount # First, check that it's actually an NFS mount
mount | grep -q $MOUNT mount | grep -q $MOUNT
if [ $? -ne 0 ] if [ $? -ne 0 ]; then
then
logger -t NFSCHECK "$MOUNT is not mounted" logger -t NFSCHECK "$MOUNT is not mounted"
previous=1 previous=1
sleep $delay sleep $delay
@ -31,18 +29,15 @@ do
# At this point, jobs will either report no jobs (empty) or Done, # At this point, jobs will either report no jobs (empty) or Done,
# unless the job is still running/hung # unless the job is still running/hung
rc=$(jobs) rc=$(jobs)
if [[ -z "$rc" || $rc =~ "Done" ]] if [[ -z "$rc" || $rc =~ "Done" ]]; then
then
# NFS is successful # NFS is successful
if [ $previous -ne 0 ] if [ $previous -ne 0 ]; then
then
logger -t NFSCHECK "NFS test of $MOUNT is ok" logger -t NFSCHECK "NFS test of $MOUNT is ok"
previous=0 previous=0
fi fi
else else
# Keep waiting until the job is done # Keep waiting until the job is done
while ! [[ -z "$rc" || $rc =~ "Done" ]] while ! [[ -z "$rc" || $rc =~ "Done" ]]; do
do
logger -t NFSCHECK "NFS test of $MOUNT is failed" logger -t NFSCHECK "NFS test of $MOUNT is failed"
previous=1 previous=1
sleep $delay sleep $delay

View File

@ -22,15 +22,13 @@ fi
# network link to autonegotiate link speed. Re-run the script in # network link to autonegotiate link speed. Re-run the script in
# the background so the parent can return right away and init can # the background so the parent can return right away and init can
# continue. # continue.
if [ $# -eq 3 ] if [ $# -eq 3 ]; then
then
$0 $DEV $NETWORKTYPE $NETWORKSPEED dummy & $0 $DEV $NETWORKTYPE $NETWORKSPEED dummy &
disown disown
exit 0 exit 0
fi fi
function test_valid_speed function test_valid_speed {
{
# After the link is enabled but before the autonegotiation is complete # After the link is enabled but before the autonegotiation is complete
# the link speed may be read as either -1 or as 4294967295 (which is # the link speed may be read as either -1 or as 4294967295 (which is
# uint(-1) in twos-complement) depending on the kernel. Neither one is valid. # uint(-1) in twos-complement) depending on the kernel. Neither one is valid.
@ -42,24 +40,20 @@ function test_valid_speed
fi fi
} }
function log function log {
{
# It seems that syslog isn't yet running, so append directly to the syslog file # It seems that syslog isn't yet running, so append directly to the syslog file
echo `date +%FT%T.%3N` `hostname` CGCS_TC_SETUP: $@ >> /var/log/platform.log echo `date +%FT%T.%3N` `hostname` CGCS_TC_SETUP: $@ >> /var/log/platform.log
} }
function infra_exists function infra_exists {
{ if [ -z "$infrastructure_interface" ]; then
if [ -z "$infrastructure_interface" ]
then
return 1 return 1
else else
return 0 return 0
fi fi
} }
function is_consolidated function is_consolidated {
{
if ! infra_exists if ! infra_exists
then then
return 1 return 1
@ -67,26 +61,22 @@ function is_consolidated
# determine whether the management interface is a parent of the # determine whether the management interface is a parent of the
# infrastructure interface based on name. # infrastructure interface based on name.
# eg. this matches enp0s8 to enp0s8.10 but not enp0s88 # eg. this matches enp0s8 to enp0s8.10 but not enp0s88
if [[ $infrastructure_interface =~ $management_interface[\.][0-9]+$ ]] if [[ $infrastructure_interface =~ $management_interface[\.][0-9]+$ ]]; then
then
return 0 return 0
fi fi
return 1 return 1
fi fi
} }
function is_vlan function is_vlan {
{ if [ -f /proc/net/vlan/$DEV ]; then
if [ -f /proc/net/vlan/$DEV ]
then
return 0 return 0
else else
return 1 return 1
fi fi
} }
function is_loopback function is_loopback {
{
# (from include/uapi/linux/if.h) # (from include/uapi/linux/if.h)
IFF_LOOPBACK=$((1<<3)) IFF_LOOPBACK=$((1<<3))
@ -101,8 +91,7 @@ function is_loopback
fi fi
} }
function setup_tc_port_filter function setup_tc_port_filter {
{
local PORT=$1 local PORT=$1
local PORTMASK=$2 local PORTMASK=$2
local FLOWID=$3 local FLOWID=$3

View File

@ -9,8 +9,7 @@
# $1 - listening port of remote log server # $1 - listening port of remote log server
PORT=$1 PORT=$1
function is_loopback function is_loopback {
{
# (from include/uapi/linux/if.h) # (from include/uapi/linux/if.h)
IFF_LOOPBACK=$((1<<3)) IFF_LOOPBACK=$((1<<3))
@ -25,14 +24,12 @@ function is_loopback
fi fi
} }
function log function log {
{
# It seems that syslog isn't yet running, so append directly to the syslog file # It seems that syslog isn't yet running, so append directly to the syslog file
echo `date +%FT%T.%3N` `hostname` CGCS_TC_SETUP: $@ >> /var/log/platform.log echo `date +%FT%T.%3N` `hostname` CGCS_TC_SETUP: $@ >> /var/log/platform.log
} }
function test_valid_speed function test_valid_speed {
{
# After the link is enabled but before the autonegotiation is complete # After the link is enabled but before the autonegotiation is complete
# the link speed may be read as either -1 or as 4294967295 (which is # the link speed may be read as either -1 or as 4294967295 (which is
# uint(-1) in twos-complement) depending on the kernel. Neither one is valid. # uint(-1) in twos-complement) depending on the kernel. Neither one is valid.
@ -44,8 +41,7 @@ function test_valid_speed
fi fi
} }
function get_dev_speed function get_dev_speed {
{
# If the link doesn't come up we won't go enabled, so here we can # If the link doesn't come up we won't go enabled, so here we can
# afford to wait forever for the link. # afford to wait forever for the link.
while true while true