Skip to content

Commit

Permalink
Avoid parsing group name when checking RadMon diagnostic files (#1559)
Browse files Browse the repository at this point in the history
This changes the way the RadMon diagnostic file checker determines if a diagnostic
file is 0-sized.  Instead of attempting to parse the output of `tar -tv`, the script now
extracts the `radstat` file and runs `du -b` on each gzipped diagnostic file.  On S4, the
primary group is `domain users`, which, containing a space, caused issues with the
previous method.

Fixes #1515
  • Loading branch information
DavidHuber-NOAA committed May 10, 2023
1 parent 106e747 commit bd8585b
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions ush/radmon_diag_ck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,50 +105,49 @@ echo "--> radmon_diag_ck.sh"
# the radstat file (which is a tar file) are gzipped.
# I find that 0 sized, gzipped file has a size of ~52
# (I assume that's for header and block size).
#
#
# So for this check we'll assume anything in the radstat
# file with a size of > 1000 bytes is suspect. (That's
# overkill, 100 is probably sufficient, but I'm the
# nervous type.) So we'll extract, uncompress, and check
# the actual file size of those. Anything with an
# uncompressed size of 0 goes on the zero_len_diag list.
#
verbose_contents=`tar -tvf ${radstat_file} | grep '_ges'`


#-------------------------------------------------------
# note: need to reset the IFS to line breaks otherwise
# the $vc value in the for loop below will break
# on all white space, not the line break.
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")

# TODO Rewrite these array parsing commands to avoid using Bash's sloppy word splitting
# File sizes contain only digits and immediately precede the date
# shellcheck disable=SC2207
sizes=($(tar -vtf ${radstat_file} --wildcards '*_ges*' | grep -P -o '(\d)+(?= \d{4}-\d{2}-\d{2})'))
# Filenames are the last group of non-whitespace characters
# shellcheck disable=SC2207
filenames=($(tar -vtf ${radstat_file} --wildcards '*_ges*' | grep -P -o '\S+$'))
# shellcheck disable=

for vc in ${verbose_contents}; do

gzip_len=`echo ${vc} | gawk '{print $3}'`
for file_num in "${!filenames[@]}"; do
file_name="${filenames[${file_num}]}"
file_size="${sizes[${file_num}]}"

if [[ ${gzip_len} -le 1000 ]]; then
test_file=`echo ${vc} | gawk '{print $6}'`
tar -xf ${radstat_file} ${test_file}
if (( file_size <= 1000 )); then
tar -xf "${radstat_file}" "${file_name}"
gunzip "${file_name}"
uz_file_name="${file_name%.*}"
uz_file_size=$(stat -c "%s" "${uz_file_name}")

gunzip ${test_file}
unzipped_file=`echo ${test_file%.*}`

uz_file_size=`ls -la ${unzipped_file} | gawk '{print $5}'`

if [[ ${uz_file_size} -le 0 ]]; then
sat=`echo ${unzipped_file} | gawk -F"diag_" '{print $2}' |
gawk -F"_ges" '{print $1}'`
if (( uz_file_size <= 0 )); then
# Remove leading diag_
sat=${uz_file_name#diag_}
# Remove trailing _ges*
sat=${sat%_ges*}

zero_len_diag="${zero_len_diag} ${sat}"
fi

rm -f ${unzipped_file}
rm -f ${uz_file_name}
fi
done

IFS=${SAVEIFS} # reset IFS to default (white space)
done

echo ""
echo "zero_len_diag = ${zero_len_diag}"
Expand Down

0 comments on commit bd8585b

Please sign in to comment.