Here is a script. Provide the log file name as the first argument. This checks for any time over 350ms. If such a time is found, it sends email.
#!/bin/sh
logfile="$1"
flag="$(awk -v RS=" " '$1 == "ms" && last > 350 {flag=1} {last=$1} END{print flag}' "$logfile")"
[ "$flag" ] && mail you@host -s "Over 350ms Report for $logfile" <"$logfile"
This does require that your system has mail properly installed and configured.
Combined Script
The above can be combined with the script in Script won't loop through files like planned as follows:
#!/bin/sh
n=
while true
do
fname=~/"Scripts/logs/trace$n.log"
[ -f "$fname" ] || break
n=$(($n+1))
done
traceroute google.com >"$fname"
flag="$(awk -v RS=" " '$1 == "ms" && last > 350 {flag=1} {last=$1} END{print flag}' "$fname")"
[ "$flag" ] && mail you@host -s "Over 350ms Report for $fname" <"$fname"
Cooperative Form
Suppose that the script in Script won't loop through files like planned is running separately. Then, a possible script to inspect the files created by it for >350ms delays would be:
#!/bin/sh
for logfile in ~/Scripts/logs/trace*.log
do
flag="$(awk -v RS=" " '$1 == "ms" && last > 350 {flag=1} {last=$1} END{print flag}' "$logfile")"
[ "$flag" ] && mail you@host -s "Over 350ms Report for $logfile" <"$logfile"
done
Cooperative form with move and delete
#!/bin/sh
otherdir=~/"Scripts/logs-with-long-delays/"
for logfile in ~/Scripts/logs/trace*.log
do
flag="$(awk -v RS=" " '$1 == "ms" && last > 350 {flag=1} {last=$1} END{print flag}' "$logfile")"
if [ "$flag" ]
then
mail you@host -s "Over 350ms Report for $logfile" <"$logfile"
mv "$logfile" "$otherdir"
else
rm "$logfile"
fi
done