Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid parsing group name when checking RadMon diagnostic files #1559

Merged
37 changes: 12 additions & 25 deletions ush/radmon_diag_ck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,51 +105,38 @@ 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")
gz_ges_list=$(tar -xvf ${radstat_file} | grep '_ges')

for gz_ges in ${gz_ges_list}; do

for vc in ${verbose_contents}; do

gzip_len=`echo ${vc} | gawk '{print $3}'`
# Check file sizes
gzip_len=$(du -b "${gz_ges}" | gawk '{print $1}')

if [[ ${gzip_len} -le 1000 ]]; then
test_file=`echo ${vc} | gawk '{print $6}'`
tar -xf ${radstat_file} ${test_file}
gunzip "${gz_ges}"
ges="${gz_ges%.*}"

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

uz_file_size=`ls -la ${unzipped_file} | gawk '{print $5}'`
uz_file_size=$(du -b "${ges}" | gawk '{print $1}')

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} -eq 0 ]]; then
sat=$(echo "${ges}" | gawk -F"diag_" -F"_ges" '{print $1}')

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

rm -f ${unzipped_file}
rm -f "${ges}"
fi
rm -f "${gz_ges}"
Copy link
Contributor

@WalterKolczynski-NOAA WalterKolczynski-NOAA May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for gz_ges in ${gz_ges_list}; do
for vc in ${verbose_contents}; do
gzip_len=`echo ${vc} | gawk '{print $3}'`
# Check file sizes
gzip_len=$(du -b "${gz_ges}" | gawk '{print $1}')
if [[ ${gzip_len} -le 1000 ]]; then
test_file=`echo ${vc} | gawk '{print $6}'`
tar -xf ${radstat_file} ${test_file}
gunzip "${gz_ges}"
ges="${gz_ges%.*}"
gunzip ${test_file}
unzipped_file=`echo ${test_file%.*}`
uz_file_size=`ls -la ${unzipped_file} | gawk '{print $5}'`
uz_file_size=$(du -b "${ges}" | gawk '{print $1}')
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} -eq 0 ]]; then
sat=$(echo "${ges}" | gawk -F"diag_" -F"_ges" '{print $1}')
zero_len_diag="${zero_len_diag} ${sat}"
fi
rm -f ${unzipped_file}
rm -f "${ges}"
fi
rm -f "${gz_ges}"
for file_num in ${!file_names[@]}; do
file_name="${filenames[${file_num}]}"
file_size="${sizes[${file_num}]}"
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}")
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 ${uz_file_name}

done

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

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