Skip to content

Instantly share code, notes, and snippets.

@skiold
Last active December 14, 2015 14:18
Show Gist options
  • Save skiold/5099932 to your computer and use it in GitHub Desktop.
Save skiold/5099932 to your computer and use it in GitHub Desktop.
#!/bin/sh
REPORT_DATES="2013-02-28 2013-03-01 2013-03-02 2013-03-03 2013-03-04 2013-03-05"
LOGDIR=logs
function total() {
for date in $REPORT_DATES ; do
echo "Report for $date ========================"
awk "/^${date} [0-9:]* .* (==|=>)/ {print \$5}" ${LOGDIR}/* |
sort |
uniq -c | sort -gr
done
}
function success() {
local date=$1
awk "/^$date [0-9:]* .* => / {print \$5}" ${LOGDIR}/* |
sort | uniq -c | sort -gr
}
function failures() {
local date=$1
for failid in $(awk "/^$date [0-9:]* .* == / {print \$3}" ${LOGDIR}/* | uniq)
do
if grep '$failid =>' ${LOGDIR}/* ; then
continue
fi
egrep -m 1 "^${date} [0-9:]* ${failid} == " ${LOGDIR}/* | cut -d " " -f 5
done | sort | uniq -c | sort -gr
}
for date in $REPORT_DATES ; do
echo "Completed deliveries for $date ========================="
success $date
echo "Emails with pending deliveries for $date ========================="
failures $date
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment