I wrote some small helper scripts for parsing logs. Would they be useful enough to include in qpsmtpd?
-- JT Moree
#!/bin/sh usage() { cat << FOO $0 - utility to parse qpsmtpd log messages for a given string and get the whole transaction Usage: $0 <logfile> [grep options] text_to_find We will find the last instance of the given string and show all lines pertaining to that message FOO } LOG=$1 shift 1 if [ "$LOG" = "" ] || [ "$LOG" = "-h" ] ; then usage exit 1 fi if [ ! -f "$LOG" ] ; then echo "Invalid logfile given!" >&2 exit 1 fi if [ $# -eq 0 ] ; then echo "No data given" >&2 exit 1 fi set -x N=`grep -h $@ $LOG | tail -n1 | awk '{print $1;}'` if [ -n "$N" ] ; then grep -h ^$N $LOG fi
#!/bin/sh usage() { cat << FOO $0 - utility to parse qpsmtpd log messages for a given id Usage: $0 <logfile> <number> [<number> . . . .] FOO } LOG=$1 shift 1 if [ "$LOG" = "" ] || [ "$LOG" = "-h" ] ; then usage exit 1 fi if [ ! -f "$LOG" ] ; then echo "Invalid logfile given!" >&2 exit 1 fi for N in $@ ; do grep ^$N $LOG done