Fix linters issue E002 and E003 and linters check (none-voting)

E002 Tab indents
E003 Indent not multiple of 4

Story: 2003366
Task: 24424

Change-Id: Ie063ccfe346489f08c4752adaa344f5919db0378
Signed-off-by: Sun Austin <austin.sun@intel.com>
This commit is contained in:
Sun Austin 2018-08-30 14:50:33 +08:00 committed by Austin Sun
parent 1fdf94bedb
commit 847cf1e92f
51 changed files with 988 additions and 986 deletions

View File

@ -4,3 +4,5 @@
jobs: jobs:
- openstack-tox-pep8: - openstack-tox-pep8:
voting: false voting: false
- openstack-tox-linters:
voting: false

View File

@ -22,12 +22,12 @@ RETVAL=0
# This is only needed till TPM In-Kernel # This is only needed till TPM In-Kernel
# ResourceMgr comes in # ResourceMgr comes in
remove_TPM_transients () { remove_TPM_transients () {
_HANDLES=`find $TPM_DATA_DIR -type f -name "hp*.bin" -printf "%f "` _HANDLES=`find $TPM_DATA_DIR -type f -name "hp*.bin" -printf "%f "`
for handle in $_HANDLES; do for handle in $_HANDLES; do
handle_addr=`echo $handle | sed 's/hp\([0-9]*\)\.bin/\1/g'` handle_addr=`echo $handle | sed 's/hp\([0-9]*\)\.bin/\1/g'`
tss2_flushcontext -ha $handle_addr &> /dev/null tss2_flushcontext -ha $handle_addr &> /dev/null
done done
rm -f $TPM_DATA_DIR/* rm -f $TPM_DATA_DIR/*
} }
start() { start() {
@ -90,7 +90,7 @@ status()
} }
check() { check() {
/usr/sbin/$NAME -c -q -V -f /etc/$NAME/$NAME.cfg /usr/sbin/$NAME -c -q -V -f /etc/$NAME/$NAME.cfg
} }
# See how we were called. # See how we were called.

View File

@ -15,14 +15,14 @@ if [ "$1" = "stop" ]; then
fi fi
# #
# Run in a subshell because of I/O redirection. # Run in a subshell because of I/O redirection.
# #
test -f /etc/fstab && ( test -f /etc/fstab && (
# #
# Read through fstab line by line. If it is NFS, set the flag # Read through fstab line by line. If it is NFS, set the flag
# for mounting NFS filesystems. If any NFS partition is found and it # for mounting NFS filesystems. If any NFS partition is found and it
# not mounted with the nolock option, we start the rpcbind. # not mounted with the nolock option, we start the rpcbind.
# #
rpcbind=no rpcbind=no
mount_nfs=no mount_nfs=no
@ -31,41 +31,41 @@ mount_ncp=no
mount_cifs=no mount_cifs=no
while read device mountpt fstype options while read device mountpt fstype options
do do
case "$device" in case "$device" in
""|\#*) ""|\#*)
continue continue
;; ;;
esac esac
case "$options" in case "$options" in
*noauto*) *noauto*)
continue continue
;; ;;
esac esac
if test "$fstype" = nfs if test "$fstype" = nfs
then then
mount_nfs=yes mount_nfs=yes
case "$options" in case "$options" in
*nolock*) *nolock*)
;; ;;
*) *)
rpcbind=yes rpcbind=yes
;; ;;
esac esac
fi fi
if test "$fstype" = smbfs if test "$fstype" = smbfs
then then
mount_smb=yes mount_smb=yes
fi fi
if test "$fstype" = ncpfs if test "$fstype" = ncpfs
then then
mount_ncp=yes mount_ncp=yes
fi fi
if test "$fstype" = cifs if test "$fstype" = cifs
then then
mount_cifs=yes mount_cifs=yes
fi fi
done done
exec 0>&1 exec 0>&1
@ -78,11 +78,11 @@ then
then then
if test -x /usr/sbin/rpcbind if test -x /usr/sbin/rpcbind
then then
service rpcbind status > /dev/null service rpcbind status > /dev/null
if [ $? != 0 ]; then if [ $? != 0 ]; then
echo -n "Starting rpcbind..." echo -n "Starting rpcbind..."
start-stop-daemon --start --quiet --exec /usr/sbin/rpcbind start-stop-daemon --start --quiet --exec /usr/sbin/rpcbind
sleep 2 sleep 2
fi fi
fi fi
fi fi
@ -90,11 +90,11 @@ fi
if test "$mount_nfs" = yes || test "$mount_smb" = yes || test "$mount_ncp" = yes || test "$mount_cifs" = yes if test "$mount_nfs" = yes || test "$mount_smb" = yes || test "$mount_ncp" = yes || test "$mount_cifs" = yes
then then
echo "Mounting remote filesystems..." echo "Mounting remote filesystems..."
test "$mount_nfs" = yes && mount -a -t nfs test "$mount_nfs" = yes && mount -a -t nfs
test "$mount_smb" = yes && mount -a -t smbfs test "$mount_smb" = yes && mount -a -t smbfs
test "$mount_ncp" = yes && mount -a -t ncpfs test "$mount_ncp" = yes && mount -a -t ncpfs
test "$mount_cifs" = yes && mount -a -t cifs test "$mount_cifs" = yes && mount -a -t cifs
fi fi
) < /etc/fstab ) < /etc/fstab

View File

@ -27,9 +27,9 @@ if [ $version -ne $thisversion ] ; then
cat <<EOF >&2 cat <<EOF >&2
The datadir located at $datadir needs to be upgraded using 'mysql_upgrade' tool. This can be done using the following steps: The datadir located at $datadir needs to be upgraded using 'mysql_upgrade' tool. This can be done using the following steps:
1. Back-up your data before with 'mysql_upgrade' 1. Back-up your data before with 'mysql_upgrade'
2. Start the database daemon using 'service @DAEMON_NAME@ start' 2. Start the database daemon using 'service @DAEMON_NAME@ start'
3. Run 'mysql_upgrade' with a database user that has sufficient privileges 3. Run 'mysql_upgrade' with a database user that has sufficient privileges
Read more about 'mysql_upgrade' usage at: Read more about 'mysql_upgrade' usage at:
https://mariadb.com/kb/en/mariadb/documentation/sql-commands/table-commands/mysql_upgrade/ https://mariadb.com/kb/en/mariadb/documentation/sql-commands/table-commands/mysql_upgrade/

View File

@ -41,14 +41,14 @@ else
fi fi
myuser=`systemctl show -p User "${SERVICE_NAME}" | myuser=`systemctl show -p User "${SERVICE_NAME}" |
sed 's/^User=//'` sed 's/^User=//'`
if [ x"$myuser" = x ] if [ x"$myuser" = x ]
then then
myuser=mysql myuser=mysql
fi fi
mygroup=`systemctl show -p Group "${SERVICE_NAME}" | mygroup=`systemctl show -p Group "${SERVICE_NAME}" |
sed 's/^Group=//'` sed 's/^Group=//'`
if [ x"$mygroup" = x ] if [ x"$mygroup" = x ]
then then
mygroup=mysql mygroup=mysql

View File

@ -11,18 +11,18 @@ export LC_ALL=C
# We use my_print_defaults which prints all options from multiple files, # We use my_print_defaults which prints all options from multiple files,
# with the more specific ones later; hence take the last match. # with the more specific ones later; hence take the last match.
get_mysql_option(){ get_mysql_option(){
if [ $# -ne 3 ] ; then if [ $# -ne 3 ] ; then
echo "get_mysql_option requires 3 arguments: section option default_value" echo "get_mysql_option requires 3 arguments: section option default_value"
return return
fi fi
sections="$1" sections="$1"
option_name="$2" option_name="$2"
default_value="$3" default_value="$3"
result=`@bindir@/my_print_defaults $sections | sed -n "s/^--${option_name}=//p" | tail -n 1` result=`@bindir@/my_print_defaults $sections | sed -n "s/^--${option_name}=//p" | tail -n 1`
if [ -z "$result" ]; then if [ -z "$result" ]; then
# not found, use default # not found, use default
result="${default_value}" result="${default_value}"
fi fi
} }
# Defaults here had better match what mysqld_safe will default to # Defaults here had better match what mysqld_safe will default to

View File

@ -9,8 +9,8 @@ source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
# "After mysqld" won't be started until the database is really ready. # "After mysqld" won't be started until the database is really ready.
if [ $# -ne 1 ] ; then if [ $# -ne 1 ] ; then
echo "You need to pass daemon pid as an argument for this script." echo "You need to pass daemon pid as an argument for this script."
exit 20 exit 20
fi fi
# Service file passes us the daemon's PID (actually, mysqld_safe's PID) # Service file passes us the daemon's PID (actually, mysqld_safe's PID)
@ -19,27 +19,27 @@ daemon_pid="$1"
# Wait for the server to come up or for the mysqld process to disappear # Wait for the server to come up or for the mysqld process to disappear
ret=0 ret=0
while /bin/true; do while /bin/true; do
# Check process still exists # Check process still exists
if ! [ -d "/proc/${daemon_pid}" ] ; then if ! [ -d "/proc/${daemon_pid}" ] ; then
ret=1 ret=1
break break
fi fi
RESPONSE=`@bindir@/mysqladmin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1` RESPONSE=`@bindir@/mysqladmin --no-defaults --socket="$socketfile" --user=UNKNOWN_MYSQL_USER ping 2>&1`
mret=$? mret=$?
if [ $mret -eq 0 ] ; then if [ $mret -eq 0 ] ; then
break break
fi fi
# exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected, # exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
# anything else suggests a configuration error # anything else suggests a configuration error
if [ $mret -ne 1 -a $mret -ne 11 ]; then if [ $mret -ne 1 -a $mret -ne 11 ]; then
echo "Cannot check for @NICE_PROJECT_NAME@ Daemon startup because of mysqladmin failure." >&2 echo "Cannot check for @NICE_PROJECT_NAME@ Daemon startup because of mysqladmin failure." >&2
ret=$mret ret=$mret
break break
fi fi
# "Access denied" also means the server is alive # "Access denied" also means the server is alive
echo "$RESPONSE" | grep -q "Access denied for user" && break echo "$RESPONSE" | grep -q "Access denied for user" && break
sleep 1 sleep 1
done done
exit $ret exit $ret

View File

@ -13,24 +13,24 @@ TIMEOUT=60
SECONDS=0 SECONDS=0
if ! [ -f "$pidfile" ]; then if ! [ -f "$pidfile" ]; then
exit 0 exit 0
fi fi
MYSQLPID=`cat "$pidfile" 2>/dev/null` MYSQLPID=`cat "$pidfile" 2>/dev/null`
if [ -z "$MYSQLPID" ] ; then if [ -z "$MYSQLPID" ] ; then
exit 2 exit 2
fi fi
while /bin/true; do while /bin/true; do
# Check process still exists # Check process still exists
if ! [ -d "/proc/${MYSQLPID}" ] ; then if ! [ -d "/proc/${MYSQLPID}" ] ; then
break break
fi fi
if [ $SECONDS -gt $TIMEOUT ] ; then if [ $SECONDS -gt $TIMEOUT ] ; then
ret=3 ret=3
break break
fi fi
sleep 1 sleep 1
done done
exit $ret exit $ret

View File

@ -60,10 +60,10 @@ function configure_device()
} }
function is_debugfs_mounted() { function is_debugfs_mounted() {
if grep -qs "${DEBUGFS_PATH}" /proc/mounts; then if grep -qs "${DEBUGFS_PATH}" /proc/mounts; then
return 0 return 0
fi fi
return 1 return 1
} }
function mount_debugfs() { function mount_debugfs() {
@ -129,20 +129,20 @@ function status()
} }
case "$1" in case "$1" in
start) start)
start start
;; ;;
stop) stop)
stop stop
;; ;;
restart) restart)
stop stop
start start
;; ;;
status) status)
status status
;; ;;
*) *)
echo "Usage: $0 {start|stop|restart|status}" echo "Usage: $0 {start|stop|restart|status}"
exit 1 exit 1
esac esac

View File

@ -19,7 +19,7 @@ function log()
{ {
local MSG="${PROGNAME}: $1" local MSG="${PROGNAME}: $1"
if [ ${DEBUG} -ne 0 ]; then if [ ${DEBUG} -ne 0 ]; then
echo "${MSG}" echo "${MSG}"
fi fi
echo "${MSG}" >> /var/log/mlx4-configure.log echo "${MSG}" >> /var/log/mlx4-configure.log
} }
@ -100,20 +100,20 @@ function status()
} }
case "$1" in case "$1" in
start) start)
start start
;; ;;
stop) stop)
stop stop
;; ;;
restart) restart)
stop stop
start start
;; ;;
status) status)
status status
;; ;;
*) *)
echo "Usage: $0 {start|stop|restart|status}" echo "Usage: $0 {start|stop|restart|status}"
exit 1 exit 1
esac esac

View File

@ -51,7 +51,7 @@ num_exchanges=$(rabbitmqctl list_exchanges | wc -l); ((num_exchanges-=2))
num_connections=$(rabbitmqctl list_connections | wc -l); ((num_connections-=2)) num_connections=$(rabbitmqctl list_connections | wc -l); ((num_connections-=2))
num_channels=$(rabbitmqctl list_channels | wc -l); ((num_channels-=2)) num_channels=$(rabbitmqctl list_channels | wc -l); ((num_channels-=2))
arr=($(rabbitmqctl list_queues messages consumers memory | \ arr=($(rabbitmqctl list_queues messages consumers memory | \
awk '/^[0-9]/ {a+=$1; b+=$2; c+=$3} END {print a, b, c}')) awk '/^[0-9]/ {a+=$1; b+=$2; c+=$3} END {print a, b, c}'))
messages=${arr[0]}; consumers=${arr[1]}; memory=${arr[2]} messages=${arr[0]}; consumers=${arr[1]}; memory=${arr[2]}
printf "%6s %8s %9s %11s %8s %8s %9s %10s\n" "queues" "bindings" "exchanges" "connections" "channels" "messages" "consumers" "memory" >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG} printf "%6s %8s %9s %11s %8s %8s %9s %10s\n" "queues" "bindings" "exchanges" "connections" "channels" "messages" "consumers" "memory" >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG}
printf "%6d %8d %9d %11d %8d %8d %9d %10d\n" $num_queues $num_bindings $num_exchanges $num_connections $num_channels $messages $consumers $memory >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG} printf "%6d %8d %9d %11d %8d %8d %9d %10d\n" $num_queues $num_bindings $num_exchanges $num_connections $num_channels $messages $consumers $memory >> ${LOGFILE} 2>>${COLLECT_ERROR_LOG}

View File

@ -107,7 +107,7 @@ if [ "$nodetype" = "controller" ] ; then
pg_size_pretty(pg_database_size(pg_database.datname)) pg_size_pretty(pg_database_size(pg_database.datname))
FROM pg_database FROM pg_database
ORDER BY pg_database_size DESC; ORDER BY pg_database_size DESC;
" >> ${LOGFILE} " >> ${LOGFILE}
# Number of postgres connections # Number of postgres connections
delimiter ${LOGFILE} "ps -C postgres -o cmd=" delimiter ${LOGFILE} "ps -C postgres -o cmd="

View File

@ -3,15 +3,15 @@
# http://twiki.wrs.com/PBUeng/Patching # http://twiki.wrs.com/PBUeng/Patching
if [ -z $MY_WORKSPACE ] || [ -z $MY_REPO ]; then if [ -z $MY_WORKSPACE ] || [ -z $MY_REPO ]; then
echo "Some dev environment variables are not set." echo "Some dev environment variables are not set."
echo "Refer to http://wiki.wrs.com/PBUeng/CentOSBuildProcess for instructions." echo "Refer to http://wiki.wrs.com/PBUeng/CentOSBuildProcess for instructions."
exit 1 exit 1
fi fi
ENGTOOLS=$(ls ${MY_WORKSPACE}/std/rpmbuild/RPMS/engtools*noarch.rpm 2>/dev/null) ENGTOOLS=$(ls ${MY_WORKSPACE}/std/rpmbuild/RPMS/engtools*noarch.rpm 2>/dev/null)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Engtools RPM has not been built. Please run \"build-pkgs engtools\" first." echo "Engtools RPM has not been built. Please run \"build-pkgs engtools\" first."
exit 1 exit 1
fi fi
source ${MY_REPO}/stx/middleware/recipes-common/build-info/release-info.inc source ${MY_REPO}/stx/middleware/recipes-common/build-info/release-info.inc

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
# Enable use of INTERVAL_SEC sample interval # Enable use of INTERVAL_SEC sample interval
@ -16,17 +16,17 @@ 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
cmd='ceph -s' cmd='ceph -s'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
cmd='ceph osd tree' cmd='ceph osd tree'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
cmd='ceph df detail' cmd='ceph df detail'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -49,8 +49,8 @@ tools_header
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
print_ceph print_ceph
LOG "done" LOG "done"

View File

@ -6,8 +6,8 @@
TOOLBIN=$(dirname $0) TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
if [ $UID -ne 0 ]; then if [ $UID -ne 0 ]; then
ERRLOG "Require sudo/root access." ERRLOG "Require sudo/root access."
exit 1 exit 1
fi fi
declare -a TOOLS declare -a TOOLS
@ -34,23 +34,23 @@ 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
else else
LOG "no pids found" LOG "no pids found"
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

@ -50,26 +50,26 @@ 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}
if [ ! -z "${name}" ]; then if [ ! -z "${name}" ]; then
fname="${TOOL_DEST_DIR}/${HOSTNAME}_${timestamp}_${name}" fname="${TOOL_DEST_DIR}/${HOSTNAME}_${timestamp}_${name}"
parallel_outfiles+=( $fname ) parallel_outfiles+=( $fname )
LOG "collecting ${tool}, ${interval} second intervals, to: ${fname}" LOG "collecting ${tool}, ${interval} second intervals, to: ${fname}"
if [ ! -z "${period}" ]; then if [ ! -z "${period}" ]; then
${STDBUF} ${tool} -p ${period} -i ${interval} > ${fname} 2>/dev/null & ${STDBUF} ${tool} -p ${period} -i ${interval} > ${fname} 2>/dev/null &
elif [ ! -z "${repeat}" ]; then elif [ ! -z "${repeat}" ]; then
${STDBUF} ${tool} --repeat=${repeat} --delay=${interval} > ${fname} 2>/dev/null & ${STDBUF} ${tool} --repeat=${repeat} --delay=${interval} > ${fname} 2>/dev/null &
fi fi
else else
# run without file output (eg., ticker) # run without file output (eg., ticker)
${STDBUF} ${tool} -p ${period} -i ${interval} 2>/dev/null & ${STDBUF} ${tool} -p ${period} -i ${interval} 2>/dev/null &
fi fi
done done
} }
# get_current_avail_usage() - get output destination file-system usage and # get_current_avail_usage() - get output destination file-system usage and
@ -77,10 +77,10 @@ function do_parallel_commands()
# - 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]}
du_used_bytes=$(du --block-size=1 ${TOOL_DEST_DIR} | awk 'NR==1 {print $1}') du_used_bytes=$(du --block-size=1 ${TOOL_DEST_DIR} | awk 'NR==1 {print $1}')
} }
# purge_oldest_files() - remove oldest files based on file-system available space, # purge_oldest_files() - remove oldest files based on file-system available space,
@ -88,57 +88,57 @@ function get_current_avail_usage()
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" \
$[$df_avail_bytes/1024/1024] $[$tgt_avail_bytes/1024/1024] \ $[$df_avail_bytes/1024/1024] $[$tgt_avail_bytes/1024/1024] \
$[$du_used_bytes/1024/1024] $[$tgt_used_bytes/1024/1024]) $[$du_used_bytes/1024/1024] $[$tgt_used_bytes/1024/1024])
LOG "usage: ${msg}" LOG "usage: ${msg}"
if [[ $df_avail_bytes -lt $tgt_avail_bytes ]] || \ if [[ $df_avail_bytes -lt $tgt_avail_bytes ]] || \
[[ $du_used_bytes -gt $tgt_used_bytes ]]; then [[ $du_used_bytes -gt $tgt_used_bytes ]]; then
# wait for compression to complete # wait for compression to complete
wait wait
get_current_avail_usage get_current_avail_usage
if [[ $df_avail_bytes -lt $tgt_avail_bytes ]]; then if [[ $df_avail_bytes -lt $tgt_avail_bytes ]]; then
msg=$(printf "purge: avail %d MB < target %d MB" \ msg=$(printf "purge: avail %d MB < target %d MB" \
$[$df_avail_bytes/1024/1024] $[$tgt_avail_bytes/1024/1024] ) $[$df_avail_bytes/1024/1024] $[$tgt_avail_bytes/1024/1024] )
LOG "purge: ${msg}" LOG "purge: ${msg}"
fi
if [[ $du_used_bytes -gt $tgt_used_bytes ]]; then
msg=$(printf "purge: used %d MB > target %d MB" \
$[$du_used_bytes/1024/1024] $[$tgt_used_bytes/1024/1024] )
LOG "purge: ${msg}"
fi
else
return
fi fi
if [[ $du_used_bytes -gt $tgt_used_bytes ]]; then
msg=$(printf "purge: used %d MB > target %d MB" \
$[$du_used_bytes/1024/1024] $[$tgt_used_bytes/1024/1024] )
LOG "purge: ${msg}"
fi
else
return
fi
# 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
fi fi
if [ ${OPT_DEBUG} -eq 1 ]; then if [ ${OPT_DEBUG} -eq 1 ]; then
msg="purge: file=$file" msg="purge: file=$file"
if [[ $df_avail_bytes -lt $tgt_avail_bytes ]]; then if [[ $df_avail_bytes -lt $tgt_avail_bytes ]]; then
msg="${msg}, < AVAIL" msg="${msg}, < AVAIL"
fi fi
if [[ $du_used_bytes -gt $tgt_used_bytes ]]; then if [[ $du_used_bytes -gt $tgt_used_bytes ]]; then
msg="${msg}, > MAXUSAGE" msg="${msg}, > MAXUSAGE"
fi fi
LOG "${msg}" LOG "${msg}"
fi fi
sz_bytes=$(stat --printf="%s" $file) sz_bytes=$(stat --printf="%s" $file)
((df_avail_bytes += sz_bytes)) ((df_avail_bytes += sz_bytes))
((du_used_bytes -= sz_bytes)) ((du_used_bytes -= sz_bytes))
rm -fv ${file} rm -fv ${file}
done done
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -160,23 +160,23 @@ CPULIST=""
# Affine tools to NOVA pinned cores (i.e., non-cpu 0) # Affine tools to NOVA pinned cores (i.e., non-cpu 0)
# - remove interference with cpu 0 # - remove interference with cpu 0
if [ "${AFFINE_PINNED}" -eq 1 ]; then if [ "${AFFINE_PINNED}" -eq 1 ]; then
NOVA_CONF=/etc/nova/compute_extend.conf NOVA_CONF=/etc/nova/compute_extend.conf
if [ -f "${NOVA_CONF}" ]; then if [ -f "${NOVA_CONF}" ]; then
source "${NOVA_CONF}" source "${NOVA_CONF}"
CPULIST=${compute_pinned_cpulist} CPULIST=${compute_pinned_cpulist}
else else
CPULIST="" CPULIST=""
fi fi
fi fi
set_affinity ${CPULIST} set_affinity ${CPULIST}
# Define output directory # Define output directory
if [[ "${HOSTNAME}" =~ "controller-" ]]; then if [[ "${HOSTNAME}" =~ "controller-" ]]; then
TOOL_DEST_DIR=/scratch/syseng_data/${HOSTNAME} TOOL_DEST_DIR=/scratch/syseng_data/${HOSTNAME}
elif [[ "${HOSTNAME}" =~ "compute-" ]]; then elif [[ "${HOSTNAME}" =~ "compute-" ]]; then
TOOL_DEST_DIR=/tmp/syseng_data/${HOSTNAME} TOOL_DEST_DIR=/tmp/syseng_data/${HOSTNAME}
else else
TOOL_DEST_DIR=/tmp/syseng_data/${HOSTNAME} TOOL_DEST_DIR=/tmp/syseng_data/${HOSTNAME}
fi fi
mkdir -p ${TOOL_DEST_DIR} mkdir -p ${TOOL_DEST_DIR}
@ -186,7 +186,7 @@ DAEMON_OUT="${TOOL_DEST_DIR}/${HOSTNAME}_${timestamp}_${TOOLNAME}.log"
# Redirect stdout and append to log if not connected to TTY # Redirect stdout and append to log if not connected to TTY
if test ! -t 1 ; then if test ! -t 1 ; then
exec 1>> ${DAEMON_OUT} exec 1>> ${DAEMON_OUT}
fi fi
# Get current availability and usage # Get current availability and usage
@ -199,9 +199,9 @@ tgt_used_bytes=$[$PURGE_MAXUSAGE_MB*1024*1024]
# Set granularity based on duration # Set granularity based on duration
if [ $PERIOD_MIN -le 30 ]; then if [ $PERIOD_MIN -le 30 ]; then
GRAN_MIN=5 GRAN_MIN=5
else else
GRAN_MIN=60 GRAN_MIN=60
fi fi
# Adjust repeats and intervals based on GRAN_MIN granularity # Adjust repeats and intervals based on GRAN_MIN granularity
@ -209,7 +209,7 @@ PERIOD_MIN=$[($PERIOD_MIN+(GRAN_MIN-1))/GRAN_MIN*GRAN_MIN]
((REPEATS = PERIOD_MIN/GRAN_MIN)) ((REPEATS = PERIOD_MIN/GRAN_MIN))
GRAN_MIN_IN_SEC=$[$GRAN_MIN*60] GRAN_MIN_IN_SEC=$[$GRAN_MIN*60]
if [ ${INTERVAL_SEC} -gt ${GRAN_MIN_IN_SEC} ]; then if [ ${INTERVAL_SEC} -gt ${GRAN_MIN_IN_SEC} ]; then
INTERVAL_SEC=${GRAN_MIN_IN_SEC} INTERVAL_SEC=${GRAN_MIN_IN_SEC}
fi fi
# Define tools and options # Define tools and options
@ -231,7 +231,7 @@ if [ ${OPT_SOAK} -eq 1 ]; then
ceph_interval=${DUR_15MIN_IN_SEC} ceph_interval=${DUR_15MIN_IN_SEC}
diskstats_interval=${DUR_15MIN_IN_SEC} diskstats_interval=${DUR_15MIN_IN_SEC}
memstats_interval=${DUR_15MIN_IN_SEC} memstats_interval=${DUR_15MIN_IN_SEC}
filestats_interval=${DUR_15MIN_IN_SEC} filestats_interval=${DUR_15MIN_IN_SEC}
elif [ ${OPT_SOAK} -eq 2 ]; then elif [ ${OPT_SOAK} -eq 2 ]; then
# Assume much shorter collection (eg, < hours) # Assume much shorter collection (eg, < hours)
schedtop_interval=2 # i.e., 2 second interval schedtop_interval=2 # i.e., 2 second interval
@ -243,7 +243,7 @@ elif [ ${OPT_SOAK} -eq 2 ]; then
ceph_interval=${DUR_5MIN_IN_SEC} ceph_interval=${DUR_5MIN_IN_SEC}
diskstats_interval=${DUR_5MIN_IN_SEC} diskstats_interval=${DUR_5MIN_IN_SEC}
memstats_interval=${DUR_5MIN_IN_SEC} memstats_interval=${DUR_5MIN_IN_SEC}
filestats_interval=${DUR_5MIN_IN_SEC} filestats_interval=${DUR_5MIN_IN_SEC}
else else
# Assume shorter collection (eg, < a few hours) # Assume shorter collection (eg, < a few hours)
schedtop_interval=5 # i.e., 5 second interval schedtop_interval=5 # i.e., 5 second interval
@ -255,7 +255,7 @@ else
ceph_interval=${DUR_5MIN_IN_SEC} ceph_interval=${DUR_5MIN_IN_SEC}
diskstats_interval=${DUR_5MIN_IN_SEC} diskstats_interval=${DUR_5MIN_IN_SEC}
memstats_interval=${DUR_5MIN_IN_SEC} memstats_interval=${DUR_5MIN_IN_SEC}
filestats_interval=${DUR_5MIN_IN_SEC} filestats_interval=${DUR_5MIN_IN_SEC}
fi fi
schedtop_repeat=$[ $PERIOD_MIN * 60 / $schedtop_interval ] schedtop_repeat=$[ $PERIOD_MIN * 60 / $schedtop_interval ]
occtop_repeat=$[ $PERIOD_MIN * 60 / $occtop_interval ] occtop_repeat=$[ $PERIOD_MIN * 60 / $occtop_interval ]
@ -274,29 +274,29 @@ LBINDIR=/usr/local/bin
declare -a tlist declare -a tlist
if [[ ${ENABLE_STATIC_COLLECTION} == "Y" ]] || [[ ${ENABLE_STATIC_COLLECTION} == "y" ]]; then if [[ ${ENABLE_STATIC_COLLECTION} == "Y" ]] || [[ ${ENABLE_STATIC_COLLECTION} == "y" ]]; then
tlist+=( "tool=${LBINDIR}/top.sh name=top period=${PERIOD_MIN} interval=${DUR_1MIN_IN_SEC}" ) tlist+=( "tool=${LBINDIR}/top.sh name=top period=${PERIOD_MIN} interval=${DUR_1MIN_IN_SEC}" )
tlist+=( "tool=${LBINDIR}/iostat.sh name=iostat period=${PERIOD_MIN} interval=${DUR_1MIN_IN_SEC}" ) tlist+=( "tool=${LBINDIR}/iostat.sh name=iostat period=${PERIOD_MIN} interval=${DUR_1MIN_IN_SEC}" )
tlist+=( "tool=${LBINDIR}/netstats.sh name=netstats period=${PERIOD_MIN} interval=${netstats_interval}" ) tlist+=( "tool=${LBINDIR}/netstats.sh name=netstats period=${PERIOD_MIN} interval=${netstats_interval}" )
tlist+=( "tool=${BINDIR}/occtop name=occtop repeat=${occtop_repeat} interval=${occtop_interval}" ) tlist+=( "tool=${BINDIR}/occtop name=occtop repeat=${occtop_repeat} interval=${occtop_interval}" )
tlist+=( "tool=${BINDIR}/memtop name=memtop repeat=${memtop_repeat} interval=${memtop_interval}" ) tlist+=( "tool=${BINDIR}/memtop name=memtop repeat=${memtop_repeat} interval=${memtop_interval}" )
tlist+=( "tool=${BINDIR}/schedtop name=schedtop repeat=${schedtop_repeat} interval=${schedtop_interval}" ) tlist+=( "tool=${BINDIR}/schedtop name=schedtop repeat=${schedtop_repeat} interval=${schedtop_interval}" )
tlist+=( "tool=${LBINDIR}/diskstats.sh name=diskstats period=${PERIOD_MIN} interval=${diskstats_interval}" ) tlist+=( "tool=${LBINDIR}/diskstats.sh name=diskstats period=${PERIOD_MIN} interval=${diskstats_interval}" )
tlist+=( "tool=${LBINDIR}/memstats.sh name=memstats period=${PERIOD_MIN} interval=${memstats_interval}" ) tlist+=( "tool=${LBINDIR}/memstats.sh name=memstats period=${PERIOD_MIN} interval=${memstats_interval}" )
tlist+=( "tool=${LBINDIR}/filestats.sh name=filestats period=${PERIOD_MIN} interval=${filestats_interval}" ) tlist+=( "tool=${LBINDIR}/filestats.sh name=filestats period=${PERIOD_MIN} interval=${filestats_interval}" )
if [[ "${HOSTNAME}" =~ "controller-" ]]; then if [[ "${HOSTNAME}" =~ "controller-" ]]; then
tlist+=( "tool=${LBINDIR}/ceph.sh name=ceph period=${PERIOD_MIN} interval=${ceph_interval}" ) tlist+=( "tool=${LBINDIR}/ceph.sh name=ceph period=${PERIOD_MIN} interval=${ceph_interval}" )
tlist+=( "tool=${LBINDIR}/postgres.sh name=postgres period=${PERIOD_MIN} interval=${postgres_interval}" ) tlist+=( "tool=${LBINDIR}/postgres.sh name=postgres period=${PERIOD_MIN} interval=${postgres_interval}" )
tlist+=( "tool=${LBINDIR}/rabbitmq.sh name=rabbitmq period=${PERIOD_MIN} interval=${rabbitmq_interval}" ) tlist+=( "tool=${LBINDIR}/rabbitmq.sh name=rabbitmq period=${PERIOD_MIN} interval=${rabbitmq_interval}" )
elif [[ "${HOSTNAME}" =~ "compute-" ]]; then elif [[ "${HOSTNAME}" =~ "compute-" ]]; then
tlist+=( "tool=${LBINDIR}/vswitch.sh name=vswitch period=${PERIOD_MIN} interval=${DUR_1MIN_IN_SEC}" ) tlist+=( "tool=${LBINDIR}/vswitch.sh name=vswitch period=${PERIOD_MIN} interval=${DUR_1MIN_IN_SEC}" )
fi fi
# ticker - shows progress on the screen # ticker - shows progress on the screen
tlist+=( "tool=${LBINDIR}/ticker.sh name= period=${PERIOD_MIN} interval=${DUR_1MIN_IN_SEC}" ) tlist+=( "tool=${LBINDIR}/ticker.sh name= period=${PERIOD_MIN} interval=${DUR_1MIN_IN_SEC}" )
fi fi
if [[ ${ENABLE_LIVE_STREAM} == "Y" ]] || [[ ${ENABLE_LIVE_STREAM} == "y" ]]; then if [[ ${ENABLE_LIVE_STREAM} == "Y" ]] || [[ ${ENABLE_LIVE_STREAM} == "y" ]]; then
${TOOLBIN}/live_stream.py & ${TOOLBIN}/live_stream.py &
fi fi
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -307,31 +307,31 @@ 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} ]] [[ ${OPT_FOREVER} -eq 1 || ${REP} -lt ${REPEATS} ]]
do do
# increment loop counter # increment loop counter
((REP++)) ((REP++))
# purge oldest files # purge oldest files
purge_oldest_files purge_oldest_files
# define filename timestamp # define filename timestamp
timestamp=$( date +"%Y-%0m-%0e_%H%M" ) timestamp=$( date +"%Y-%0m-%0e_%H%M" )
# collect tools in parallel to separate output files # collect tools in parallel to separate output files
LOG "collecting ${TOOLNAME} at ${timestamp} for ${PERIOD_MIN} mins, repeat=${REP}" LOG "collecting ${TOOLNAME} at ${timestamp} for ${PERIOD_MIN} mins, repeat=${REP}"
do_parallel_commands do_parallel_commands
wait wait
# Compress latest increment # Compress latest increment
LOG "compressing: ${parallel_outfiles[@]}" LOG "compressing: ${parallel_outfiles[@]}"
${CMD_IDLE} bzip2 -q -f ${parallel_outfiles[@]} 2>/dev/null & ${CMD_IDLE} bzip2 -q -f ${parallel_outfiles[@]} 2>/dev/null &
done done
# Wait for the compression to complete # Wait for the compression to complete
wait wait
tools_cleanup 0 tools_cleanup 0
fi fi
# Should wait here in case live stats streaming is turned on. # Should wait here in case live stats streaming is turned on.

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
# Enable use of INTERVAL_SEC sample interval # Enable use of INTERVAL_SEC sample interval
@ -16,8 +16,8 @@ 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
# NOTES: # NOTES:
# --total (grand-total) is a new option, but don't necessarily want to add tmpfs # --total (grand-total) is a new option, but don't necessarily want to add tmpfs
@ -25,67 +25,67 @@ function print_disk()
# - use -H to print in SI (eg, GB, vs GiB) # - use -H to print in SI (eg, GB, vs GiB)
# - can use -a to print all filesystems including dummy filesystems, but then # - can use -a to print all filesystems including dummy filesystems, but then
# there can be double-counting: # there can be double-counting:
print_separator print_separator
cmd='df -h -H -T --local -t ext2 -t ext3 -t ext4 -t xfs --total' cmd='df -h -H -T --local -t ext2 -t ext3 -t ext4 -t xfs --total'
${ECHO} "Disk space usage ext2,ext3,ext4,xfs,tmpfs (SI):" ${ECHO} "Disk space usage ext2,ext3,ext4,xfs,tmpfs (SI):"
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
print_separator print_separator
cmd='df -h -H -T --local -i -t ext2 -t ext3 -t ext4 -t xfs --total' cmd='df -h -H -T --local -i -t ext2 -t ext3 -t ext4 -t xfs --total'
${ECHO} "Disk inodes usage ext2,ext3,ext4,xfs,tmpfs (SI):" ${ECHO} "Disk inodes usage ext2,ext3,ext4,xfs,tmpfs (SI):"
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
print_separator print_separator
cmd='drbd-overview' cmd='drbd-overview'
${ECHO} "drbd disk usage and status:" ${ECHO} "drbd disk usage and status:"
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
print_separator print_separator
cmd='lvs' cmd='lvs'
${ECHO} "logical volumes usage and status:" ${ECHO} "logical volumes usage and status:"
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
print_separator print_separator
cmd='pvs' cmd='pvs'
${ECHO} "physical volumes usage and status:" ${ECHO} "physical volumes usage and status:"
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
print_separator print_separator
cmd='vgs' cmd='vgs'
${ECHO} "volume groups usage and status:" ${ECHO} "volume groups usage and status:"
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
} }
# 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}"
${cmd} ${cmd}
${ECHO} ${ECHO}
# fdisk - requires sudo/root # fdisk - requires sudo/root
print_separator print_separator
cmd='fdisk -l' cmd='fdisk -l'
if [ $UID -eq 0 ]; then if [ $UID -eq 0 ]; then
${ECHO} "List disk devices: ${cmd}" ${ECHO} "List disk devices: ${cmd}"
${cmd} ${cmd}
else else
WARNLOG "Skipping cmd=${cmd}, root/sudo passwd required" WARNLOG "Skipping cmd=${cmd}, root/sudo passwd required"
fi fi
${ECHO} ${ECHO}
# parted - requires sudo/root # parted - requires sudo/root
print_separator print_separator
cmd='parted -l' cmd='parted -l'
if [ $UID -eq 0 ]; then if [ $UID -eq 0 ]; then
${ECHO} "List disk devices: ${cmd}" ${ECHO} "List disk devices: ${cmd}"
${cmd} ${cmd}
else else
WARNLOG "Skipping cmd=${cmd}, root/sudo passwd required" WARNLOG "Skipping cmd=${cmd}, root/sudo passwd required"
fi fi
${ECHO} ${ECHO}
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -111,8 +111,8 @@ print_disk_static
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
print_disk print_disk
LOG "done" LOG "done"

View File

@ -7,7 +7,7 @@ TOOL_USR1_SIGNAL=0
TOOL_USR2_SIGNAL=0 TOOL_USR2_SIGNAL=0
TOOL_TTY=0 TOOL_TTY=0
if tty 1>/dev/null ; then if tty 1>/dev/null ; then
TOOL_TTY=1 TOOL_TTY=1
fi fi
# [ JGAULD : SHOULD RENAME TO TOOL_X ] # [ JGAULD : SHOULD RENAME TO TOOL_X ]
@ -19,145 +19,145 @@ CPULIST=0
# Include lsb functions # Include lsb functions
if [ -d /lib/lsb ]; then if [ -d /lib/lsb ]; then
. /lib/lsb/init-functions . /lib/lsb/init-functions
else 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
while getopts p: opt ; do while getopts p: opt ; do
case "$opt" in case "$opt" in
p) p)
pidfile="$OPTARG" pidfile="$OPTARG"
;; ;;
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
read pid < "${pidfile}" read pid < "${pidfile}"
if [ -n "${pid:-}" ]; then if [ -n "${pid:-}" ]; then
if $(kill -0 "${pid:-}" 2> /dev/null); then if $(kill -0 "${pid:-}" 2> /dev/null); then
echo "$pid" echo "$pid"
return 0 return 0
elif ps "${pid:-}" >/dev/null 2>&1; then elif ps "${pid:-}" >/dev/null 2>&1; then
echo "$pid" echo "$pid"
return 0 # program is running, but not owned by this user return 0 # program is running, but not owned by this user
else else
return 1 # program is dead and /var/run pid file exists return 1 # program is dead and /var/run pid file exists
fi
fi fi
fi
} }
# 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)
# Check for sufficient priviledges # Check for sufficient priviledges
if [ $UID -ne 0 ]; then if [ $UID -ne 0 ]; then
ERRLOG "${NAME} requires sudo/root access." ERRLOG "${NAME} requires sudo/root access."
return 1 return 1
fi fi
# Check for essential binaries # Check for essential binaries
ECHO=$(which echo 2>/dev/null) ECHO=$(which echo 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ECHO=echo # use bash built-in echo ECHO=echo # use bash built-in echo
${ECHO} "FATAL, 'echo' not found, rc=$rc"; ${ECHO} "FATAL, 'echo' not found, rc=$rc";
error=$rc error=$rc
fi fi
DATE=$(which date 2>/dev/null) DATE=$(which date 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
${ECHO} "FATAL, 'date' not found, rc=$rc"; ${ECHO} "FATAL, 'date' not found, rc=$rc";
error=$rc error=$rc
fi fi
# Check for standard linux binaries, at least can use LOG functions now # Check for standard linux binaries, at least can use LOG functions now
# - these are used in tools_header # - these are used in tools_header
CAT=$(which cat 2>/dev/null) CAT=$(which cat 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'cat' not found, rc=$rc"; ERRLOG "'cat' not found, rc=$rc";
error=$rc error=$rc
fi fi
ARCH=$(which arch 2>/dev/null) ARCH=$(which arch 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'arch' not found, rc=$rc"; ERRLOG "'arch' not found, rc=$rc";
error=$rc error=$rc
fi fi
SED=$(which sed 2>/dev/null) SED=$(which sed 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'sed' not found, rc=$rc"; ERRLOG "'sed' not found, rc=$rc";
error=$rc error=$rc
fi fi
GREP=$(which grep 2>/dev/null) GREP=$(which grep 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'grep' not found, rc=$rc"; ERRLOG "'grep' not found, rc=$rc";
error=$rc error=$rc
fi fi
WC=$(which wc 2>/dev/null) WC=$(which wc 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'wc' not found, rc=$rc"; ERRLOG "'wc' not found, rc=$rc";
error=$rc error=$rc
fi fi
UNAME=$(which uname 2>/dev/null) UNAME=$(which uname 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'uname' not found, rc=$rc"; ERRLOG "'uname' not found, rc=$rc";
error=$rc error=$rc
fi fi
SORT=$(which sort 2>/dev/null) SORT=$(which sort 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'sort' not found, rc=$rc"; ERRLOG "'sort' not found, rc=$rc";
error=$rc error=$rc
fi fi
TR=$(which tr 2>/dev/null) TR=$(which tr 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'tr' not found, rc=$rc"; ERRLOG "'tr' not found, rc=$rc";
error=$rc error=$rc
fi fi
AWK=$(which awk 2>/dev/null) AWK=$(which awk 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'awk' not found, rc=$rc"; ERRLOG "'awk' not found, rc=$rc";
error=$rc error=$rc
fi fi
PKILL=$(which pkill 2>/dev/null) PKILL=$(which pkill 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'pkill' not found, rc=$rc"; ERRLOG "'pkill' not found, rc=$rc";
error=$rc error=$rc
fi fi
LS=$(which ls 2>/dev/null) LS=$(which ls 2>/dev/null)
rc=$? rc=$?
if [ $rc -ne 0 ]; then if [ $rc -ne 0 ]; then
ERRLOG "'ls' not found, rc=$rc"; ERRLOG "'ls' not found, rc=$rc";
error=$rc error=$rc
fi fi
# The following block is needed for LSB systems such as Windriver Linux. # The following block is needed for LSB systems such as Windriver Linux.
# The utility is not available on CentOS so comment it out. # The utility is not available on CentOS so comment it out.
@ -170,91 +170,91 @@ function tools_init ()
# Let parent program decide what to do with the errors, # Let parent program decide what to do with the errors,
# give ominous warning # give ominous warning
if [ $error -eq 1 ]; then if [ $error -eq 1 ]; then
WARNLOG "possibly cannot continue, missing linux binaries" WARNLOG "possibly cannot continue, missing linux binaries"
fi fi
# Check if tool was previously running # Check if tool was previously running
if [ -e ${PIDFILE} ]; then if [ -e ${PIDFILE} ]; then
# [ JGAULD - remove pidofproc() / LSB compatibility issue ] # [ JGAULD - remove pidofproc() / LSB compatibility issue ]
if check_pidfile -p "${PIDFILE}" >/dev/null; then if check_pidfile -p "${PIDFILE}" >/dev/null; then
ERRLOG "${PIDFILE} exists and ${TOOLNAME} is running" ERRLOG "${PIDFILE} exists and ${TOOLNAME} is running"
return 1 return 1
else else
# remove pid file # remove pid file
WARNLOG "${PIDFILE} exists but ${TOOLNAME} is not running; cleaning up" WARNLOG "${PIDFILE} exists but ${TOOLNAME} is not running; cleaning up"
rm -f ${PIDFILE} rm -f ${PIDFILE}
fi
fi fi
fi
# Create pid file # Create pid file
echo $$ > ${PIDFILE} echo $$ > ${PIDFILE}
# Setup trap handler - these signals trigger child shutdown and cleanup # Setup trap handler - these signals trigger child shutdown and cleanup
trap tools_exit_handler INT HUP TERM EXIT trap tools_exit_handler INT HUP TERM EXIT
trap tools_usr1_handler USR1 trap tools_usr1_handler USR1
trap tools_usr2_handler USR2 trap tools_usr2_handler USR2
return ${rc} return ${rc}
} }
# 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
local VERBOSE_OPT='' local VERBOSE_OPT=''
if [ "$1" -ne "0" ]; then if [ "$1" -ne "0" ]; then
LOG "cleanup invoked with code: $1" LOG "cleanup invoked with code: $1"
if [ ${TOOL_DEBUG} -ne 0 ]; then if [ ${TOOL_DEBUG} -ne 0 ]; then
VERBOSE_OPT='-v' VERBOSE_OPT='-v'
fi
fi fi
fi
# stop all processes launched from this process # stop all processes launched from this process
pkill -TERM -P $$ pkill -TERM -P $$
if [ "$1" -ne "0" ]; then if [ "$1" -ne "0" ]; then
sleep 1 sleep 1
fi fi
# OK, if the above didn't work, use force # OK, if the above didn't work, use force
pkill -KILL -P $$ pkill -KILL -P $$
# remove pid file # remove pid file
if [ -e ${PIDFILE} ]; then if [ -e ${PIDFILE} ]; then
rm -f ${VERBOSE_OPT} ${PIDFILE} rm -f ${VERBOSE_OPT} ${PIDFILE}
fi fi
exit $1 exit $1
} }
# 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 WARNLOG () { LOG "WARN $@"; }
function ERRLOG () { LOG "ERROR $@"; } function ERRLOG () { LOG "ERROR $@"; }
@ -262,76 +262,76 @@ 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
fi fi
# Set cpu affinity for current program # Set cpu affinity for current program
local TASKSET=$(which taskset 2>/dev/null) local TASKSET=$(which taskset 2>/dev/null)
if [ -x "${TASKSET}" ]; then if [ -x "${TASKSET}" ]; then
${TASKSET} -pc ${CPULIST} $$ 2>/dev/null ${TASKSET} -pc ${CPULIST} $$ 2>/dev/null
fi fi
} }
# 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=""
NICE=$( which nice 2>/dev/null ) NICE=$( which nice 2>/dev/null )
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
NICE="${NICE} -n 19" NICE="${NICE} -n 19"
else else
NICE="" NICE=""
fi fi
IONICE=$( which ionice 2>/dev/null ) IONICE=$( which ionice 2>/dev/null )
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
IONICE="${IONICE} -c 3" IONICE="${IONICE} -c 3"
else else
IONICE="" IONICE=""
fi fi
echo "${NICE} ${IONICE}" echo "${NICE} ${IONICE}"
} }
# 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
#local tstamp=$( date +"%Y-%0m-%0e %H:%M:%S" 2>/dev/null ) #local tstamp=$( date +"%Y-%0m-%0e %H:%M:%S" 2>/dev/null )
local tstamp=$( date --rfc-3339=ns | cut -c1-23 2>/dev/null ) local tstamp=$( date --rfc-3339=ns | cut -c1-23 2>/dev/null )
# Linux Generic # Linux Generic
local UPTIME=/proc/uptime local UPTIME=/proc/uptime
# Get number of online cpus # Get number of online cpus
local CPUINFO=/proc/cpuinfo local CPUINFO=/proc/cpuinfo
local online_cpus=$( cat ${CPUINFO} | grep -i ^processor | wc -l 2>/dev/null ) local online_cpus=$( cat ${CPUINFO} | grep -i ^processor | wc -l 2>/dev/null )
# Get load average, run-queue size, and number of threads # Get load average, run-queue size, and number of threads
local LOADAVG=/proc/loadavg local LOADAVG=/proc/loadavg
local LDAVG=( `cat ${LOADAVG} | sed -e 's#[/]# #g' 2>/dev/null` ) local LDAVG=( `cat ${LOADAVG} | sed -e 's#[/]# #g' 2>/dev/null` )
# Get current architecture # Get current architecture
local arch=$( uname -m ) local arch=$( uname -m )
# Determine processor name (there are many different formats... *sigh* ) # Determine processor name (there are many different formats... *sigh* )
# - build up info from multiple lines # - build up info from multiple lines
local processor='unk' local processor='unk'
local NAME=$( cat ${CPUINFO} | grep \ local NAME=$( cat ${CPUINFO} | grep \
-e '^cpu\W\W:' \ -e '^cpu\W\W:' \
-e ^'cpu model' \ -e ^'cpu model' \
-e ^'model name' \ -e ^'model name' \
@ -340,53 +340,53 @@ function tools_header() {
-e ^[Mm]achine | \ -e ^[Mm]achine | \
sort -u | awk 'BEGIN{FS=":";} {print $2;}' | \ sort -u | awk 'BEGIN{FS=":";} {print $2;}' | \
tr '\n' ' ' | tr -s [:blank:] 2>/dev/null ) tr '\n' ' ' | tr -s [:blank:] 2>/dev/null )
if [ ! -z "${NAME}" ]; then if [ ! -z "${NAME}" ]; then
processor=${NAME} processor=${NAME}
fi fi
# Determine processor speed (abort grep after first match) # Determine processor speed (abort grep after first match)
local speed='unk' local speed='unk'
local BOGO=$( cat ${CPUINFO} | grep -m1 -e ^BogoMIPS -e ^bogomips | \ local BOGO=$( cat ${CPUINFO} | grep -m1 -e ^BogoMIPS -e ^bogomips | \
awk 'BEGIN{FS=":";} {printf "%.1f", $2;}' 2>/dev/null ) awk 'BEGIN{FS=":";} {printf "%.1f", $2;}' 2>/dev/null )
local MHZ=$( cat ${CPUINFO} | grep -m1 -e ^'cpu MHz' -e ^clock | \ local MHZ=$( cat ${CPUINFO} | grep -m1 -e ^'cpu MHz' -e ^clock | \
awk 'BEGIN{FS=":";} {printf "%.1f", $2;}' 2>/dev/null ) awk 'BEGIN{FS=":";} {printf "%.1f", $2;}' 2>/dev/null )
local MHZ2=$( cat ${CPUINFO} | grep -m1 -e ^Cpu0ClkTck -e ^'cycle frequency' | \ local MHZ2=$( cat ${CPUINFO} | grep -m1 -e ^Cpu0ClkTck -e ^'cycle frequency' | \
awk 'BEGIN{FS=":";} {printf "%.1f", $2/1.0E6;}' 2>/dev/null ) awk 'BEGIN{FS=":";} {printf "%.1f", $2/1.0E6;}' 2>/dev/null )
if [ ! -z "${MHZ}" ]; then if [ ! -z "${MHZ}" ]; then
speed=${MHZ} speed=${MHZ}
elif [ ! -z "${MHZ2}" ]; then elif [ ! -z "${MHZ2}" ]; then
speed=${MHZ2} speed=${MHZ2}
elif [ ! -z ${BOGO} ]; then elif [ ! -z ${BOGO} ]; then
speed=${BOGO} speed=${BOGO}
fi fi
# Determine OS and kernel version # Determine OS and kernel version
local os_name=$( uname -s 2>/dev/null ) local os_name=$( uname -s 2>/dev/null )
local os_release=$( uname -r 2>/dev/null ) local os_release=$( uname -r 2>/dev/null )
declare -a arr declare -a arr
local dist_id="" local dist_id=""
# Determine OS distribution ID # Determine OS distribution ID
if [ lsb_pres == "yes" ]; then if [ lsb_pres == "yes" ]; then
arr=( $( lsb_release -i 2>/dev/null ) ) arr=( $( lsb_release -i 2>/dev/null ) )
dist_id=${arr[2]} dist_id=${arr[2]}
else else
local dist_id=$(cat /etc/centos-release | awk '{print $1}' 2>/dev/null) local dist_id=$(cat /etc/centos-release | awk '{print $1}' 2>/dev/null)
fi fi
local dist_rel="" local dist_rel=""
if [ lsb_pres == "yes" ]; then if [ lsb_pres == "yes" ]; then
# Determine OS distribution release # Determine OS distribution release
arr=( $( cat /proc/version | awk '{print $3}' 2>/dev/null ) ) arr=( $( cat /proc/version | awk '{print $3}' 2>/dev/null ) )
local dist_rel=${arr[1]} local dist_rel=${arr[1]}
else else
local dist_rel=$(cat /etc/centos-release | awk '{print $4}' 2>/dev/null) local dist_rel=$(cat /etc/centos-release | awk '{print $4}' 2>/dev/null)
fi fi
# Print generic header # Print generic header
echo "${TOOLNAME} -- ${tstamp} load average:${LDAVG[0]}, ${LDAVG[1]}, ${LDAVG[2]} runq:${LDAVG[3]} nproc:${LDAVG[4]}" echo "${TOOLNAME} -- ${tstamp} load average:${LDAVG[0]}, ${LDAVG[1]}, ${LDAVG[2]} runq:${LDAVG[3]} nproc:${LDAVG[4]}"
echo " host:${HOSTNAME} Distribution:${dist_id} ${dist_rel} ${os_name} ${os_release}" echo " host:${HOSTNAME} Distribution:${dist_id} ${dist_rel} ${os_name} ${os_release}"
echo " arch:${arch} processor:${processor} speed:${speed} MHz CPUs:${online_cpus}" echo " arch:${arch} processor:${processor} speed:${speed} MHz CPUs:${online_cpus}"
} }
@ -394,85 +394,85 @@ 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
echo "Usage: ${TOOLNAME} [-f] [-p <period_mins>] [-c <cpulist>] [-h]" echo "Usage: ${TOOLNAME} [-f] [-p <period_mins>] [-c <cpulist>] [-h]"
fi fi
} }
# 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:";
echo " -f : collect forever : default: none" echo " -f : collect forever : default: none"
echo " -p <period_minutes> : overall collection period (minutes) : default: ${DEFAULT_PERIOD_MIN}" echo " -p <period_minutes> : overall collection period (minutes) : default: ${DEFAULT_PERIOD_MIN}"
if [ ${OPT_USE_INTERVALS} -eq 1 ]; then if [ ${OPT_USE_INTERVALS} -eq 1 ]; then
echo " -i <interval_seconds> : sample interval (seconds) : default: ${DEFAULT_INTERVAL_SEC}" echo " -i <interval_seconds> : sample interval (seconds) : default: ${DEFAULT_INTERVAL_SEC}"
fi fi
echo " -c <cpulist> : cpu list where tool runs (e.g., 0-1,8) : default: none" echo " -c <cpulist> : cpu list where tool runs (e.g., 0-1,8) : default: none"
echo echo
if [ ${OPT_USE_INTERVALS} -eq 1 ]; then if [ ${OPT_USE_INTERVALS} -eq 1 ]; then
echo "Example: collect 5 minute period, sample every 30 seconds interval" echo "Example: collect 5 minute period, sample every 30 seconds interval"
echo " ${TOOLNAME} -p 5 -i 30" echo " ${TOOLNAME} -p 5 -i 30"
else else
echo "Example: collect 5 minute period" echo "Example: collect 5 minute period"
echo " ${TOOLNAME} -p 5" echo " ${TOOLNAME} -p 5"
fi fi
} }
# 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
tools_cleanup 0 tools_cleanup 0
exit 0 exit 0
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
PERIOD_MIN=60 PERIOD_MIN=60
;; ;;
p) PERIOD_MIN=$OPTARG ;; p) PERIOD_MIN=$OPTARG ;;
i) i)
OPT_USE_INTERVALS=1 OPT_USE_INTERVALS=1
INTERVAL_SEC=$OPTARG INTERVAL_SEC=$OPTARG
;; ;;
c) CPULIST=$OPTARG ;; c) CPULIST=$OPTARG ;;
h) h)
tools_print_help tools_print_help
tools_cleanup 0 tools_cleanup 0
exit 0 exit 0
;; ;;
*) *)
tools_usage tools_usage
tools_cleanup 0 tools_cleanup 0
exit 0 exit 0
;; ;;
esac esac
done done
# validate input arguments # validate input arguments
PERIOD_MAX=$[4*24*60] PERIOD_MAX=$[4*24*60]
INTERVAL_MAX=$[60*60] INTERVAL_MAX=$[60*60]
error=0 error=0
if [[ ${PERIOD_MIN} -lt 1 || ${PERIOD_MIN} -gt ${PERIOD_MAX} ]]; then if [[ ${PERIOD_MIN} -lt 1 || ${PERIOD_MIN} -gt ${PERIOD_MAX} ]]; then
echo "-p <period_mid> must be > 0 and <= ${PERIOD_MAX}." echo "-p <period_mid> must be > 0 and <= ${PERIOD_MAX}."
error=1 error=1
fi fi
if [[ ${INTERVAL_SEC} -lt 1 || ${INTERVAL_SEC} -gt ${INTERVAL_MAX} ]]; then if [[ ${INTERVAL_SEC} -lt 1 || ${INTERVAL_SEC} -gt ${INTERVAL_MAX} ]]; then
echo "-i <interval> must be > 0 and <= ${INTERVAL_MAX}." echo "-i <interval> must be > 0 and <= ${INTERVAL_MAX}."
error=1 error=1
fi fi
if [ ${error} -eq 1 ]; then if [ ${error} -eq 1 ]; then
tools_cleanup 0 tools_cleanup 0
exit 1 exit 1
fi fi
} }

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
PAGE_SIZE=$(getconf PAGE_SIZE) PAGE_SIZE=$(getconf PAGE_SIZE)
@ -18,19 +18,19 @@ OPT_USE_INTERVALS=1
function print_files() function print_files()
{ {
print_separator print_separator
TOOL_HIRES_TIME TOOL_HIRES_TIME
${ECHO} "# ls -l /proc/*/fd" ${ECHO} "# ls -l /proc/*/fd"
sudo ls -l /proc/*/fd 2>/dev/null | awk \ sudo ls -l /proc/*/fd 2>/dev/null | awk \
'$11 ~ /socket/ {a += 1} ; \ '$11 ~ /socket/ {a += 1} ; \
$11 ~ /null/ {b += 1} ; \ $11 ~ /null/ {b += 1} ; \
{c += 1} \ {c += 1} \
END {\ END {\
{printf "%-10s %-10s %-10s %-10s\n", "TOTAL", "FILES", "SOCKETS", "NULL PIPES"} \ {printf "%-10s %-10s %-10s %-10s\n", "TOTAL", "FILES", "SOCKETS", "NULL PIPES"} \
{printf "%-10s %-10s %-10s %-10s\n", c, c-(a+b) , a, b}}' {printf "%-10s %-10s %-10s %-10s\n", c, c-(a+b) , a, b}}'
${ECHO} ${ECHO}
${ECHO} "# lsof" ${ECHO} "# lsof"
printf "%-7s %-7s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %s\n" "PID" "TOTAL" "FD" "U" "W" "R" "CWD" "RTD" "TXT" "MEM" "DEL" "TCP" "CMD" printf "%-7s %-7s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %s\n" "PID" "TOTAL" "FD" "U" "W" "R" "CWD" "RTD" "TXT" "MEM" "DEL" "TCP" "CMD"
@ -46,7 +46,7 @@ function print_files()
{printf "%-7s %-7s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %s\n", \ {printf "%-7s %-7s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %-6s %s\n", \
pids[i]["PID"], \ pids[i]["PID"], \
pids[i]["TOTAL"],\ pids[i]["TOTAL"],\
((pids[i]["u"]!="")? pids[i]["u"] : 0) + ((pids[i]["w"]!="")? pids[i]["w"] : 0 )+ ((pids[i]["r"]!="")? pids[i]["r"] : 0),\ ((pids[i]["u"]!="")? pids[i]["u"] : 0) + ((pids[i]["w"]!="")? pids[i]["w"] : 0 )+ ((pids[i]["r"]!="")? pids[i]["r"] : 0),\
(pids[i]["u"]!="")? pids[i]["u"] : 0,\ (pids[i]["u"]!="")? pids[i]["u"] : 0,\
(pids[i]["w"]!="")? pids[i]["w"] : 0,\ (pids[i]["w"]!="")? pids[i]["w"] : 0,\
(pids[i]["r"]!="")? pids[i]["r"] : 0,\ (pids[i]["r"]!="")? pids[i]["r"] : 0,\
@ -56,13 +56,13 @@ function print_files()
(pids[i]["mem"]!="")? pids[i]["mem"] : 0,\ (pids[i]["mem"]!="")? pids[i]["mem"] : 0,\
(pids[i]["DEL"]!="")? pids[i]["DEL"] : 0,\ (pids[i]["DEL"]!="")? pids[i]["DEL"] : 0,\
(pids[i]["TCP"]!="")? pids[i]["TCP"] : 0,\ (pids[i]["TCP"]!="")? pids[i]["TCP"] : 0,\
pids[i]["COMMAND"]} }}}' | sort -n -r -k3 pids[i]["COMMAND"]} }}}' | sort -n -r -k3
${ECHO} ${ECHO}
${ECHO} "# lsof -nP +L1" ${ECHO} "# lsof -nP +L1"
sudo lsof -nP +L1 sudo lsof -nP +L1
${ECHO} ${ECHO}
} }
@ -87,8 +87,8 @@ tools_header
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
print_files print_files
LOG "done" LOG "done"

View File

@ -41,76 +41,76 @@ fi
# Check for sufficient priviledges # Check for sufficient priviledges
# [ JGAULD : possibly provide user = 'operator' option instead... ] # [ JGAULD : possibly provide user = 'operator' option instead... ]
if [ $UID -ne 0 ]; then if [ $UID -ne 0 ]; then
log_daemon_msg "Starting ${NAME} requires sudo/root access." log_daemon_msg "Starting ${NAME} requires sudo/root access."
exit 1 exit 1
fi fi
case $1 in case $1 in
start) start)
if [ -e ${PIDFILE} ]; then if [ -e ${PIDFILE} ]; then
pid=$(pidof -x ${NAME}) pid=$(pidof -x ${NAME})
if test "${pid}" != "" if test "${pid}" != ""
then then
echo_success "${NAME} already running" echo_success "${NAME} already running"
exit exit
fi fi
fi fi
log_daemon_msg "Starting ${NAME}" log_daemon_msg "Starting ${NAME}"
if start-stop-daemon --start --background --quiet --oknodo --pidfile ${PIDFILE} \ if start-stop-daemon --start --background --quiet --oknodo --pidfile ${PIDFILE} \
--exec ${DAEMON} -- ${DAEMON_ARGS} ; then --exec ${DAEMON} -- ${DAEMON_ARGS} ; then
log_end_msg 0 log_end_msg 0
else else
log_end_msg 1 log_end_msg 1
fi fi
;; ;;
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 ]
/usr/local/bin/cleanup-engtools.sh /usr/local/bin/cleanup-engtools.sh
else else
echo_failure "${NAME} is not running" echo_failure "${NAME} is not running"
fi fi
else else
echo_failure "${PIDFILE} does not exist" echo_failure "${PIDFILE} does not exist"
fi fi
;; ;;
restart) restart)
$0 stop && sleep 2 && $0 start $0 stop && sleep 2 && $0 start
;; ;;
status) status)
if [ -e ${PIDFILE} ]; then if [ -e ${PIDFILE} ]; then
pid=$(pidof -x ${NAME}) pid=$(pidof -x ${NAME})
if test "${pid}" != "" if test "${pid}" != ""
then then
echo_success "${NAME} is running" echo_success "${NAME} is running"
else else
echo_success "${NAME} is not running"
fi
else
echo_success "${NAME} is not running" echo_success "${NAME} is not running"
fi
else
echo_success "${NAME} is not running"
fi fi
;; ;;
reload) reload)
if [ -e ${PIDFILE} ]; then if [ -e ${PIDFILE} ]; then
start-stop-daemon --stop --signal USR1 --quiet --pidfile ${PIDFILE} --name ${NAME} start-stop-daemon --stop --signal USR1 --quiet --pidfile ${PIDFILE} --name ${NAME}
echo_success "${NAME} reloaded successfully" echo_success "${NAME} reloaded successfully"
else else
echo_success "${PIDFILE} does not exist" echo_success "${PIDFILE} does not exist"
fi fi
;; ;;
*) *)
echo "Usage: $0 {start|stop|restart|reload|status}" echo "Usage: $0 {start|stop|restart|reload|status}"
exit 2 exit 2
;; ;;

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
# Enable use of INTERVAL_SEC sample interval # Enable use of INTERVAL_SEC sample interval
@ -15,9 +15,9 @@ OPT_USE_INTERVALS=1
IOSTAT=$( which iostat 2>/dev/null ) IOSTAT=$( which iostat 2>/dev/null )
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
print_separator print_separator
WARNLOG "iostat not available" WARNLOG "iostat not available"
tools_cleanup 0 tools_cleanup 0
fi fi
# MAIN Program: # MAIN Program:

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
PAGE_SIZE=$(getconf PAGE_SIZE) PAGE_SIZE=$(getconf PAGE_SIZE)
@ -19,66 +19,66 @@ OPT_USE_INTERVALS=1
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
BUDDYINFO=/proc/buddyinfo BUDDYINFO=/proc/buddyinfo
SLABINFO=/proc/slabinfo SLABINFO=/proc/slabinfo
print_separator print_separator
TOOL_HIRES_TIME TOOL_HIRES_TIME
${ECHO} "# ${MEMINFO}" ${ECHO} "# ${MEMINFO}"
${CAT} ${MEMINFO} ${CAT} ${MEMINFO}
${ECHO} ${ECHO}
${ECHO} "# ${NODEINFO}" ${ECHO} "# ${NODEINFO}"
${CAT} ${NODEINFO} ${CAT} ${NODEINFO}
${ECHO} ${ECHO}
${ECHO} "# ${BUDDYINFO}" ${ECHO} "# ${BUDDYINFO}"
${CAT} ${BUDDYINFO} ${CAT} ${BUDDYINFO}
${ECHO} ${ECHO}
${ECHO} "# PSS" ${ECHO} "# PSS"
cat /proc/*/smaps 2>/dev/null | \ cat /proc/*/smaps 2>/dev/null | \
awk '/^Pss:/ {a += $2;} END {printf "%d MiB\n", a/1024.0;}' awk '/^Pss:/ {a += $2;} END {printf "%d MiB\n", a/1024.0;}'
${ECHO} ${ECHO}
# use old slabinfo format (i.e. slub not enabled in kernel) # use old slabinfo format (i.e. slub not enabled in kernel)
${ECHO} "# ${SLABINFO}" ${ECHO} "# ${SLABINFO}"
${CAT} ${SLABINFO} | \ ${CAT} ${SLABINFO} | \
awk -v page_size_B=${PAGE_SIZE} ' awk -v page_size_B=${PAGE_SIZE} '
BEGIN {page_KiB = page_size_B/1024; TOT_KiB = 0;} BEGIN {page_KiB = page_size_B/1024; TOT_KiB = 0;}
(NF == 17) { (NF == 17) {
gsub(/[<>]/, ""); gsub(/[<>]/, "");
printf("%-22s %11s %8s %8s %10s %12s %1s %5s %10s %12s %1s %12s %9s %11s %8s\n", printf("%-22s %11s %8s %8s %10s %12s %1s %5s %10s %12s %1s %12s %9s %11s %8s\n",
$2, $3, $4, $5, $6, $7, $8, $10, $11, $12, $13, $15, $16, $17, "KiB"); $2, $3, $4, $5, $6, $7, $8, $10, $11, $12, $13, $15, $16, $17, "KiB");
} }
(NF == 16) { (NF == 16) {
num_objs=$3; obj_per_slab=$5; pages_per_slab=$6; num_objs=$3; obj_per_slab=$5; pages_per_slab=$6;
KiB = (obj_per_slab > 0) ? page_KiB*num_objs/obj_per_slab*pages_per_slab : 0; KiB = (obj_per_slab > 0) ? page_KiB*num_objs/obj_per_slab*pages_per_slab : 0;
TOT_KiB += KiB; TOT_KiB += KiB;
printf("%-22s %11d %8d %8d %10d %12d %1s %5d %10d %12d %1s %12d %9d %11d %8d\n", printf("%-22s %11d %8d %8d %10d %12d %1s %5d %10d %12d %1s %12d %9d %11d %8d\n",
$1, $2, $3, $4, $5, $6, $7, $9, $10, $11, $12, $14, $15, $16, KiB); $1, $2, $3, $4, $5, $6, $7, $9, $10, $11, $12, $14, $15, $16, KiB);
} }
END { END {
printf("%-22s %11s %8s %8s %10s %12s %1s %5s %10s %12s %1s %12s %9s %11s %8d\n", printf("%-22s %11s %8s %8s %10s %12s %1s %5s %10s %12s %1s %12s %9s %11s %8d\n",
"TOTAL", "-", "-", "-", "-", "-", ":", "-", "-", "-", ":", "-", "-", "-", TOT_KiB); "TOTAL", "-", "-", "-", "-", "-", ":", "-", "-", "-", ":", "-", "-", "-", TOT_KiB);
} }
' 2>/dev/null ' 2>/dev/null
${ECHO} ${ECHO}
${ECHO} "# disk usage: rootfs, tmpfs" ${ECHO} "# disk usage: rootfs, tmpfs"
cmd='df -h -H -T --local -t rootfs -t tmpfs' cmd='df -h -H -T --local -t rootfs -t tmpfs'
${ECHO} "Disk space usage rootfs,tmpfs (SI):" ${ECHO} "Disk space usage rootfs,tmpfs (SI):"
${ECHO} "${cmd}" ${ECHO} "${cmd}"
${cmd} ${cmd}
${ECHO} ${ECHO}
CMD='ps -e -o ppid,pid,nlwp,rss:10,vsz:10,cmd --sort=-rss' CMD='ps -e -o ppid,pid,nlwp,rss:10,vsz:10,cmd --sort=-rss'
${ECHO} "# ${CMD}" ${ECHO} "# ${CMD}"
${CMD} ${CMD}
${ECHO} ${ECHO}
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -101,8 +101,8 @@ tools_header
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
print_memory print_memory
LOG "done" LOG "done"

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
# Enable use of INTERVAL_SEC sample interval # Enable use of INTERVAL_SEC sample interval
@ -17,22 +17,22 @@ OPT_USE_INTERVALS=1
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
print_separator print_separator
TOOL_HIRES_TIME TOOL_HIRES_TIME
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}
fi fi
done done
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -55,8 +55,8 @@ tools_header
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
print_netcmds print_netcmds
LOG "done" LOG "done"

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
# Enable use of INTERVAL_SEC sample interval # Enable use of INTERVAL_SEC sample interval
@ -16,32 +16,32 @@ 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
# postgressql command: set user, disable pagination, and be quiet # postgressql command: set user, disable pagination, and be quiet
PSQL="sudo -u postgres psql --pset pager=off -q" PSQL="sudo -u postgres psql --pset pager=off -q"
# List postgres databases # List postgres databases
db_list=( $(${PSQL} -t -c "SELECT datname FROM pg_database WHERE datistemplate = false;") ) db_list=( $(${PSQL} -t -c "SELECT datname FROM pg_database WHERE datistemplate = false;") )
${ECHO} "# postgres databases" ${ECHO} "# postgres databases"
echo "db_list = ${db_list[@]}" echo "db_list = ${db_list[@]}"
${ECHO} ${ECHO}
# List sizes of all postgres databases (similar to "\l+") # List sizes of all postgres databases (similar to "\l+")
${ECHO} "# postgres database sizes" ${ECHO} "# postgres database sizes"
${PSQL} -c " ${PSQL} -c "
SELECT SELECT
pg_database.datname, pg_database.datname,
pg_database_size(pg_database.datname), pg_database_size(pg_database.datname),
pg_size_pretty(pg_database_size(pg_database.datname)) pg_size_pretty(pg_database_size(pg_database.datname))
FROM pg_database FROM pg_database
ORDER BY pg_database_size DESC; 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
@ -85,29 +85,29 @@ SELECT
last_autoanalyze last_autoanalyze
FROM pg_stat_user_tables; FROM pg_stat_user_tables;
" "
done done
# Specific table counts (This is very SLOW, look at "live tuples" instead) # Specific table counts (This is very SLOW, look at "live tuples" instead)
# Number of keystone tokens # Number of keystone tokens
#${ECHO} "# keystone token count" #${ECHO} "# keystone token count"
# Number of postgres connections # Number of postgres connections
${ECHO} "# postgres database connections" ${ECHO} "# postgres database connections"
CONN=$(ps -C postgres -o cmd= | wc -l) CONN=$(ps -C postgres -o cmd= | wc -l)
CONN_T=$(ps -C postgres -o cmd= | awk '/postgres: / {print $3}' | awk '{for(i=1;i<=NF;i++) a[$i]++} END {for(k in a) print k, a[k]}' | sort -k 2 -nr ) CONN_T=$(ps -C postgres -o cmd= | awk '/postgres: / {print $3}' | awk '{for(i=1;i<=NF;i++) a[$i]++} END {for(k in a) print k, a[k]}' | sort -k 2 -nr )
${ECHO} "connections total = ${CONN}" ${ECHO} "connections total = ${CONN}"
${ECHO} ${ECHO}
${ECHO} "connections breakdown:" ${ECHO} "connections breakdown:"
${ECHO} "${CONN_T}" ${ECHO} "${CONN_T}"
${ECHO} ${ECHO}
${ECHO} "connections breakdown (query):" ${ECHO} "connections breakdown (query):"
${PSQL} -c "SELECT datname,state,count(*) from pg_stat_activity group by datname,state;" ${PSQL} -c "SELECT datname,state,count(*) from pg_stat_activity group by datname,state;"
${ECHO} ${ECHO}
${ECHO} "connections idle age:" ${ECHO} "connections idle age:"
${PSQL} -c "SELECT datname,age(now(),state_change) from pg_stat_activity where state='idle';" ${PSQL} -c "SELECT datname,age(now(),state_change) from pg_stat_activity where state='idle';"
${ECHO} ${ECHO}
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -130,8 +130,8 @@ tools_header
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
print_postgres print_postgres
LOG "done" LOG "done"

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
# Enable use of INTERVAL_SEC sample interval # Enable use of INTERVAL_SEC sample interval
@ -17,8 +17,8 @@ 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
# IMPORTANT: # IMPORTANT:
# - Difficulty getting rabbitmqctl to work from init.d script; # - Difficulty getting rabbitmqctl to work from init.d script;
@ -27,31 +27,31 @@ function print_rabbitmq()
# - WORKAROUND: run command using 'sudo', even if you are 'root' # - WORKAROUND: run command using 'sudo', even if you are 'root'
# Dump various rabbitmq related stats # Dump various rabbitmq related stats
MQ_STATUS="rabbitmqctl ${MQOPT} status" MQ_STATUS="rabbitmqctl ${MQOPT} status"
${ECHO} "# ${MQ_STATUS}" ${ECHO} "# ${MQ_STATUS}"
sudo ${MQ_STATUS} | grep -e '{memory' -A30 sudo ${MQ_STATUS} | grep -e '{memory' -A30
${ECHO} ${ECHO}
# THe following is useful in diagnosing rabbit memory leaks # THe following is useful in diagnosing rabbit memory leaks
# when end-users do not drain their queues (eg, due to RPC timeout issues, etc) # when end-users do not drain their queues (eg, due to RPC timeout issues, etc)
MQ_QUEUES="rabbitmqctl ${MQOPT} list_queues messages name pid messages_ready messages_unacknowledged memory consumers" MQ_QUEUES="rabbitmqctl ${MQOPT} list_queues messages name pid messages_ready messages_unacknowledged memory consumers"
${ECHO} "# ${MQ_QUEUES}" ${ECHO} "# ${MQ_QUEUES}"
sudo ${MQ_QUEUES} sudo ${MQ_QUEUES}
${ECHO} ${ECHO}
num_queues=$(sudo rabbitmqctl ${MQOPT} list_queues | wc -l); ((num_queues-=2)) num_queues=$(sudo rabbitmqctl ${MQOPT} list_queues | wc -l); ((num_queues-=2))
num_bindings=$(sudo rabbitmqctl ${MQOPT} list_bindings | wc -l); ((num_bindings-=2)) num_bindings=$(sudo rabbitmqctl ${MQOPT} list_bindings | wc -l); ((num_bindings-=2))
num_exchanges=$(sudo rabbitmqctl ${MQOPT} list_exchanges | wc -l); ((num_exchanges-=2)) num_exchanges=$(sudo rabbitmqctl ${MQOPT} list_exchanges | wc -l); ((num_exchanges-=2))
num_connections=$(sudo rabbitmqctl ${MQOPT} list_connections | wc -l); ((num_connections-=2)) num_connections=$(sudo rabbitmqctl ${MQOPT} list_connections | wc -l); ((num_connections-=2))
num_channels=$(sudo rabbitmqctl ${MQOPT} list_channels | wc -l); ((num_channels-=2)) num_channels=$(sudo rabbitmqctl ${MQOPT} list_channels | wc -l); ((num_channels-=2))
arr=($(sudo rabbitmqctl ${MQOPT} list_queues messages consumers memory | \ arr=($(sudo rabbitmqctl ${MQOPT} list_queues messages consumers memory | \
awk '/^[0-9]/ {a+=$1; b+=$2; c+=$3} END {print a, b, c}')) awk '/^[0-9]/ {a+=$1; b+=$2; c+=$3} END {print a, b, c}'))
messages=${arr[0]}; consumers=${arr[1]}; memory=${arr[2]} messages=${arr[0]}; consumers=${arr[1]}; memory=${arr[2]}
printf "%6s %8s %9s %11s %8s %8s %9s %10s\n" \ printf "%6s %8s %9s %11s %8s %8s %9s %10s\n" \
"queues" "bindings" "exchanges" "connections" "channels" "messages" "consumers" "memory" "queues" "bindings" "exchanges" "connections" "channels" "messages" "consumers" "memory"
printf "%6d %8d %9d %11d %8d %8d %9d %10d\n" \ printf "%6d %8d %9d %11d %8d %8d %9d %10d\n" \
$num_queues $num_bindings $num_exchanges $num_connections $num_channels $messages $consumers $memory $num_queues $num_bindings $num_exchanges $num_connections $num_channels $messages $consumers $memory
${ECHO} ${ECHO}
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -74,8 +74,8 @@ tools_header
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
print_rabbitmq print_rabbitmq
LOG "done" LOG "done"

View File

@ -6,8 +6,8 @@
TOOLBIN=$(dirname $0) TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
if [ $UID -eq 0 ]; then if [ $UID -eq 0 ]; then
ERRLOG "Do not start $0 using sudo/root access." ERRLOG "Do not start $0 using sudo/root access."
exit 1 exit 1
fi fi
# environment for system commands # environment for system commands
@ -22,24 +22,24 @@ STORAGE=( $(system host-list | awk '(/storage/) {print $4;}') )
LOG "Remote bzip2 engtools data on all blades:" LOG "Remote bzip2 engtools data on all blades:"
for blade in ${CONTROLLER[@]}; do for blade in ${CONTROLLER[@]}; do
ping -c1 ${blade} 1>/dev/null 2>/dev/null ping -c1 ${blade} 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
LOG "bzip2 on $blade:" LOG "bzip2 on $blade:"
ssh -q -t -o StrictHostKeyChecking=no \ ssh -q -t -o StrictHostKeyChecking=no \
${blade} sudo bzip2 /scratch/syseng_data/${blade}/* ${blade} sudo bzip2 /scratch/syseng_data/${blade}/*
else else
WARNLOG "cannot ping: ${blade}" WARNLOG "cannot ping: ${blade}"
fi fi
done done
for blade in ${STORAGE[@]} ${COMPUTE[@]} ; do for blade in ${STORAGE[@]} ${COMPUTE[@]} ; do
ping -c1 ${blade} 1>/dev/null 2>/dev/null ping -c1 ${blade} 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
LOG "bzip2 on $blade:" LOG "bzip2 on $blade:"
ssh -q -t -o StrictHostKeyChecking=no \ ssh -q -t -o StrictHostKeyChecking=no \
${blade} sudo bzip2 /tmp/syseng_data/${blade}/* ${blade} sudo bzip2 /tmp/syseng_data/${blade}/*
else else
WARNLOG "cannot ping: ${blade}" WARNLOG "cannot ping: ${blade}"
fi fi
done done
LOG "done" LOG "done"

View File

@ -6,8 +6,8 @@
TOOLBIN=$(dirname $0) TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
if [ $UID -eq 0 ]; then if [ $UID -eq 0 ]; then
ERRLOG "Do not start $0 using sudo/root access." ERRLOG "Do not start $0 using sudo/root access."
exit 1 exit 1
fi fi
# environment for system commands # environment for system commands
@ -18,19 +18,19 @@ BLADES=( $(system host-list | awk '(/compute|controller|storage/) {print $4;}')
LOG "Remote start engtools on all blades:" LOG "Remote start engtools on all blades:"
for blade in ${BLADES[@]}; do for blade in ${BLADES[@]}; do
if [ "${blade}" == "${HOSTNAME}" ]; then if [ "${blade}" == "${HOSTNAME}" ]; then
LOG "start on $blade:" LOG "start on $blade:"
sudo service collect-engtools.sh start sudo service collect-engtools.sh start
else
ping -c1 ${blade} 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
LOG "start on $blade:"
ssh -q -t -o StrictHostKeyChecking=no \
${blade} sudo service collect-engtools.sh start
else else
WARNLOG "cannot ping: ${blade}" ping -c1 ${blade} 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
LOG "start on $blade:"
ssh -q -t -o StrictHostKeyChecking=no \
${blade} sudo service collect-engtools.sh start
else
WARNLOG "cannot ping: ${blade}"
fi
fi fi
fi
done done
LOG "done" LOG "done"

View File

@ -6,8 +6,8 @@
TOOLBIN=$(dirname $0) TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
if [ $UID -eq 0 ]; then if [ $UID -eq 0 ]; then
ERRLOG "Do not start $0 using sudo/root access." ERRLOG "Do not start $0 using sudo/root access."
exit 1 exit 1
fi fi
# environment for system commands # environment for system commands
@ -18,19 +18,19 @@ BLADES=( $(system host-list | awk '(/compute|controller|storage/) {print $4;}')
LOG "Remote stop engtools on all blades:" LOG "Remote stop engtools on all blades:"
for blade in ${BLADES[@]}; do for blade in ${BLADES[@]}; do
if [ "${blade}" == "${HOSTNAME}" ]; then if [ "${blade}" == "${HOSTNAME}" ]; then
LOG "stop on $blade:" LOG "stop on $blade:"
sudo service collect-engtools.sh stop sudo service collect-engtools.sh stop
else
ping -c1 ${blade} 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
LOG "stop on $blade:"
ssh -q -t -o StrictHostKeyChecking=no \
${blade} sudo service collect-engtools.sh stop
else else
WARNLOG "cannot ping: ${blade}" ping -c1 ${blade} 1>/dev/null 2>/dev/null
if [ $? -eq 0 ]; then
LOG "stop on $blade:"
ssh -q -t -o StrictHostKeyChecking=no \
${blade} sudo service collect-engtools.sh stop
else
WARNLOG "cannot ping: ${blade}"
fi
fi fi
fi
done done
LOG "done" LOG "done"

View File

@ -6,8 +6,8 @@
TOOLBIN=$(dirname $0) TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
if [ $UID -eq 0 ]; then if [ $UID -eq 0 ]; then
ERRLOG "Do not start $0 using sudo/root access." ERRLOG "Do not start $0 using sudo/root access."
exit 1 exit 1
fi fi
# environment for system commands # environment for system commands
@ -24,10 +24,10 @@ STORAGE=( $(system host-list | awk '(/storage/) {print $4;}') )
DEST=/opt/backups/syseng_data/ DEST=/opt/backups/syseng_data/
if [[ "${HOSTNAME}" =~ "controller-" ]]; then if [[ "${HOSTNAME}" =~ "controller-" ]]; then
LOG "rsync DEST=${DEST}" LOG "rsync DEST=${DEST}"
else else
LOG "*ERROR* only run this on controller" LOG "*ERROR* only run this on controller"
exit 1 exit 1
fi fi
sudo mkdir -p ${DEST} sudo mkdir -p ${DEST}
@ -43,13 +43,13 @@ 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}"
sudo rsync ${RSYNC_OPT} ${USER}@${HOST}:${SRC} ${DEST} sudo rsync ${RSYNC_OPT} ${USER}@${HOST}:${SRC} ${DEST}
else else
WARNLOG "cannot ping: ${HOST}" WARNLOG "cannot ping: ${HOST}"
fi fi
done done
# computes & storage # computes & storage
@ -57,13 +57,13 @@ 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}"
sudo rsync ${RSYNC_OPT} ${USER}@${HOST}:${SRC} ${DEST} sudo rsync ${RSYNC_OPT} ${USER}@${HOST}:${SRC} ${DEST}
else else
WARNLOG "cannot ping: ${HOST}" WARNLOG "cannot ping: ${HOST}"
fi fi
done done
LOG 'done' LOG 'done'

View File

@ -3,19 +3,19 @@ PAGE_SIZE=$(getconf PAGE_SIZE)
cat /proc/slabinfo | awk -v page_size_B=${PAGE_SIZE} ' cat /proc/slabinfo | awk -v page_size_B=${PAGE_SIZE} '
BEGIN {page_KiB = page_size_B/1024; TOT_KiB = 0;} BEGIN {page_KiB = page_size_B/1024; TOT_KiB = 0;}
(NF == 17) { (NF == 17) {
gsub(/[<>]/, ""); gsub(/[<>]/, "");
printf("%-22s %11s %8s %8s %10s %12s %1s %5s %10s %12s %1s %12s %9s %11s %8s\n", printf("%-22s %11s %8s %8s %10s %12s %1s %5s %10s %12s %1s %12s %9s %11s %8s\n",
$2, $3, $4, $5, $6, $7, $8, $10, $11, $12, $13, $15, $16, $17, "KiB"); $2, $3, $4, $5, $6, $7, $8, $10, $11, $12, $13, $15, $16, $17, "KiB");
} }
(NF == 16) { (NF == 16) {
num_objs=$3; obj_per_slab=$5; pages_per_slab=$6; num_objs=$3; obj_per_slab=$5; pages_per_slab=$6;
KiB = (obj_per_slab > 0) ? page_KiB*num_objs/obj_per_slab*pages_per_slab : 0; KiB = (obj_per_slab > 0) ? page_KiB*num_objs/obj_per_slab*pages_per_slab : 0;
TOT_KiB += KiB; TOT_KiB += KiB;
printf("%-22s %11d %8d %8d %10d %12d %1s %5d %10d %12d %1s %12d %9d %11d %8d\n", printf("%-22s %11d %8d %8d %10d %12d %1s %5d %10d %12d %1s %12d %9d %11d %8d\n",
$1, $2, $3, $4, $5, $6, $7, $9, $10, $11, $12, $14, $15, $16, KiB); $1, $2, $3, $4, $5, $6, $7, $9, $10, $11, $12, $14, $15, $16, KiB);
} }
END { END {
printf("%-22s %11s %8s %8s %10s %12s %1s %5s %10s %12s %1s %12s %9s %11s %8d\n", printf("%-22s %11s %8s %8s %10s %12s %1s %5s %10s %12s %1s %12s %9s %11s %8d\n",
"TOTAL", "-", "-", "-", "-", "-", ":", "-", "-", "-", ":", "-", "-", "-", TOT_KiB); "TOTAL", "-", "-", "-", "-", "-", ":", "-", "-", "-", ":", "-", "-", "-", TOT_KiB);
} }
' 2>/dev/null ' 2>/dev/null

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
# Enable use of INTERVAL_SEC sample interval # Enable use of INTERVAL_SEC sample interval
@ -31,15 +31,15 @@ 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
t=0 t=0
echo "." echo "."
LOG_NOCR "collecting " LOG_NOCR "collecting "
else else
echo -n "." echo -n "."
fi fi
done done
echo "." echo "."

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
# Enable use of INTERVAL_SEC sample interval # Enable use of INTERVAL_SEC sample interval

View File

@ -6,8 +6,8 @@ TOOLBIN=$(dirname $0)
. ${TOOLBIN}/engtools_util.sh . ${TOOLBIN}/engtools_util.sh
tools_init tools_init
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FATAL, tools_init - could not setup environment" echo "FATAL, tools_init - could not setup environment"
exit $? exit $?
fi fi
# Enable use of INTERVAL_SEC sample interval # Enable use of INTERVAL_SEC sample interval
@ -16,25 +16,25 @@ 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
cmd='vshell engine-list' cmd='vshell engine-list'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
cmd='vshell engine-stats-list' cmd='vshell engine-stats-list'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
cmd='vshell port-list' cmd='vshell port-list'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
cmd='vshell port-stats-list' cmd='vshell port-stats-list'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
cmd='vshell network-list' cmd='vshell network-list'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
cmd='vshell network-stats-list' cmd='vshell network-stats-list'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
cmd='vshell interface-list' cmd='vshell interface-list'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
cmd='vshell interface-stats-list' cmd='vshell interface-stats-list'
${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO} ${ECHO} "# ${cmd}" ; ${cmd} ; ${ECHO}
} }
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -57,8 +57,8 @@ tools_header
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
print_vswitch print_vswitch
LOG "done" LOG "done"

View File

@ -11,9 +11,9 @@
# uncompressed files again. # uncompressed files again.
if [ ! -f lab.conf ]; then if [ ! -f lab.conf ]; then
echo "Lab configuration file is missing." echo "Lab configuration file is missing."
echo "See http://wiki.wrs.com/PBUeng/TitaniumServerSysengToolsAndDataAnalysis for more info." echo "See http://wiki.wrs.com/PBUeng/TitaniumServerSysengToolsAndDataAnalysis for more info."
exit 1 exit 1
fi fi
source ./lab.conf source ./lab.conf

View File

@ -14,9 +14,9 @@
# This script is to be run after running download-computes.sh on one of the controllers. # This script is to be run after running download-computes.sh on one of the controllers.
if [ ! -f lab.conf ]; then if [ ! -f lab.conf ]; then
echo "Lab configuration file is missing." echo "Lab configuration file is missing."
echo "See http://wiki.wrs.com/PBUeng/TitaniumServerSysengToolsAndDataAnalysis for more info." echo "See http://wiki.wrs.com/PBUeng/TitaniumServerSysengToolsAndDataAnalysis for more info."
exit 1 exit 1
fi fi
source ./lab.conf source ./lab.conf
@ -38,6 +38,6 @@ for HOST in ${ALL_HOSTS}; do
bzip2 ${HOST}* bzip2 ${HOST}*
cd ${CURDIR} cd ${CURDIR}
else else
echo "${HOST} not found" echo "${HOST} not found"
fi fi
done done

View File

@ -24,10 +24,10 @@
# - Generate tarball # - Generate tarball
if [[ $# != 1 ]]; then if [[ $# != 1 ]]; then
echo "ERROR: This script is meant to be called by either parse-controllers.sh or parse-computes.sh script." echo "ERROR: This script is meant to be called by either parse-controllers.sh or parse-computes.sh script."
echo "To run it separately, copy the script to the host directory that contains *.bz2 files." echo "To run it separately, copy the script to the host directory that contains *.bz2 files."
echo "It takes a single argument - the name of the host directory (e.g. ./parse-all.sh controller-0)." echo "It takes a single argument - the name of the host directory (e.g. ./parse-all.sh controller-0)."
exit 1 exit 1
fi fi
source ../lab.conf source ../lab.conf
@ -238,28 +238,28 @@ function parse_iostats_data()
bzcat *iostat.bz2 | grep -E "/2015|/2016|/2017|${DEVICE}" | awk '{print $1","$2","$3","$4","$5","$6","$7","$8","$9","$10","$11","$12","$13","$14}' > tmp.txt bzcat *iostat.bz2 | grep -E "/2015|/2016|/2017|${DEVICE}" | awk '{print $1","$2","$3","$4","$5","$6","$7","$8","$9","$10","$11","$12","$13","$14}' > tmp.txt
while IFS= read -r current while IFS= read -r current
do do
if test "${current#*Linux}" != "$current" if test "${current#*Linux}" != "$current"
then then
# Skip the line that contains the word "Linux" # Skip the line that contains the word "Linux"
continue continue
else else
if test "${current#*$DEVICE}" == "$current" if test "${current#*$DEVICE}" == "$current"
then then
# It's a date entry, look ahead # It's a date entry, look ahead
read -r next read -r next
if test "${next#*$DEVICE}" != "${next}" if test "${next#*$DEVICE}" != "${next}"
then then
# This next line contains the device stats # This next line contains the device stats
# Combine date and time fields # Combine date and time fields
current="${current//2016,/2016 }" current="${current//2016,/2016 }"
current="${current//2017,/2017 }" current="${current//2017,/2017 }"
# Combine time and AM/PM fields # Combine time and AM/PM fields
current="${current//,AM/ AM}" current="${current//,AM/ AM}"
current="${current//,PM/ PM}" current="${current//,PM/ PM}"
# Write both lines to intermediate file # Write both lines to intermediate file
echo "${current}" >> tmp2.txt echo "${current}" >> tmp2.txt
echo "${next}" >> tmp2.txt echo "${next}" >> tmp2.txt
fi fi
fi fi
fi fi
done < tmp.txt done < tmp.txt
@ -272,7 +272,7 @@ function parse_iostats_data()
cut -d, -f2-11 --complement tmp2.txt > tmp.txt cut -d, -f2-11 --complement tmp2.txt > tmp.txt
# Write final content to output csv # Write final content to output csv
cat tmp.txt >> iostat-${NODE}-${DEVICE}.csv cat tmp.txt >> iostat-${NODE}-${DEVICE}.csv
rm tmp.txt tmp2.txt rm tmp.txt tmp2.txt
done done
fi fi
} }

View File

@ -14,9 +14,9 @@ PARSERDIR=$(dirname $0)
. ${PARSERDIR}/parse-util.sh . ${PARSERDIR}/parse-util.sh
if [ ! -f lab.conf ]; then if [ ! -f lab.conf ]; then
echo "Lab configuration file is missing." echo "Lab configuration file is missing."
echo "See http://wiki.wrs.com/PBUeng/TitaniumServerSysengToolsAndDataAnalysis for more info." echo "See http://wiki.wrs.com/PBUeng/TitaniumServerSysengToolsAndDataAnalysis for more info."
exit 1 exit 1
fi fi
source ./lab.conf source ./lab.conf
@ -36,7 +36,7 @@ for HOST in ${CONTROLLER_LIST}; do
sleep 120 sleep 120
cd .. cd ..
else else
ERRLOG "${HOST} does not exist. Parsing skipped." ERRLOG "${HOST} does not exist. Parsing skipped."
fi fi
done done

View File

@ -102,8 +102,8 @@ elif [[ $# -eq 3 ]]; then
cd $1 cd $1
parse_daily_stats $2 $3 parse_daily_stats $2 $3
else else
echo "ERROR: Specified host $1 does not exist." echo "ERROR: Specified host $1 does not exist."
exit 1 exit 1
fi fi
else else
echo "Specified parser $2 is not a valid parser." echo "Specified parser $2 is not a valid parser."

View File

@ -63,7 +63,7 @@ function generate_grep_str()
{ {
local grepstr="time:" local grepstr="time:"
for DB in ${DATABASE_LIST}; do for DB in ${DATABASE_LIST}; do
grepstr="${grepstr}|${DB}" grepstr="${grepstr}|${DB}"
done done
grepstr="${grepstr}|breakdown|connections total|rows" grepstr="${grepstr}|breakdown|connections total|rows"
echo $grepstr echo $grepstr

View File

@ -10,17 +10,17 @@ LOGFILE="parserlog.txt"
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 -e "${tstamp_H} $0($$): $@" >> ${LOGFILE} echo -e "${tstamp_H} $0($$): $@" >> ${LOGFILE}
} }
function ERRLOG () function ERRLOG ()
{ {
LOG "ERROR: $@" LOG "ERROR: $@"
} }
function WARNLOG () function WARNLOG ()
{ {
LOG "WARN: $@" LOG "WARN: $@"
} }

View File

@ -11,9 +11,9 @@
# #
if [ ! -f lab.conf ]; then if [ ! -f lab.conf ]; then
echo "Lab configuration file is missing." echo "Lab configuration file is missing."
echo "See http://wiki.wrs.com/PBUeng/TitaniumServerSysengToolsAndDataAnalysis for more info." echo "See http://wiki.wrs.com/PBUeng/TitaniumServerSysengToolsAndDataAnalysis for more info."
exit 1 exit 1
fi fi
source ./lab.conf source ./lab.conf

View File

@ -14,9 +14,9 @@ PARSERDIR=$(dirname $0)
. ${PARSERDIR}/parse-util.sh . ${PARSERDIR}/parse-util.sh
if [ ! -f lab.conf ]; then if [ ! -f lab.conf ]; then
echo "Lab configuration file is missing." echo "Lab configuration file is missing."
echo "See http://wiki.wrs.com/PBUeng/TitaniumServerSysengToolsAndDataAnalysis for more info." echo "See http://wiki.wrs.com/PBUeng/TitaniumServerSysengToolsAndDataAnalysis for more info."
exit 1 exit 1
fi fi
source ./lab.conf source ./lab.conf
@ -35,7 +35,7 @@ else
../parse-all.sh ${HOST} > /dev/null 2>&1 & ../parse-all.sh ${HOST} > /dev/null 2>&1 &
cd .. cd ..
else else
ERRLOG "${HOST} does not exist. Parsing skipped." ERRLOG "${HOST} does not exist. Parsing skipped."
fi fi
done done
fi fi

View File

@ -24,7 +24,7 @@ if [ ! -e $jenkinsBuildFile ]; then
fi fi
if [ -e $releaseInfoFile ]; then if [ -e $releaseInfoFile ]; then
source $releaseInfoFile source $releaseInfoFile
fi fi
if [ "${REPO}x" == "x" ]; then if [ "${REPO}x" == "x" ]; then
@ -35,12 +35,12 @@ if [ -e $jenkinsBuildFile ]; then
cp $jenkinsBuildFile $destFile cp $jenkinsBuildFile $destFile
source $jenkinsBuildFile source $jenkinsBuildFile
else else
# PLATFORM_RELEASE should be set in release-info.inc # PLATFORM_RELEASE should be set in release-info.inc
if [ "x${PLATFORM_RELEASE}" == "x" ]; then if [ "x${PLATFORM_RELEASE}" == "x" ]; then
SW_VERSION="Unknown" SW_VERSION="Unknown"
else else
SW_VERSION="${PLATFORM_RELEASE}" SW_VERSION="${PLATFORM_RELEASE}"
fi fi
BUILD_TARGET="Unknown" BUILD_TARGET="Unknown"
BUILD_TYPE="Informal" BUILD_TYPE="Informal"

View File

@ -62,16 +62,16 @@ function is_consolidated
{ {
if ! infra_exists if ! infra_exists
then then
return 1 return 1
else else
# 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
} }

View File

@ -41,11 +41,11 @@ shift
if [ "$have_rbd" == "enable" ]; then if [ "$have_rbd" == "enable" ]; then
rbd_driver=rbd, rbd_driver=rbd,
fi fi
if [ "$have_gluster" == "enable" ]; then if [ "$have_gluster" == "enable" ]; then
gluster_driver=gluster, gluster_driver=gluster,
fi fi
./configure \ ./configure \