File apache2-check_forensic of Package apache2
1
#!/bin/sh
2
3
# check_forensic <forensic log file>
4
# Author: Peter Poeml <apache@suse.de>
5
6
# check the forensic log for requests that did not complete
7
# output the request log for each one
8
9
# This script is based on Ben Laurie's check_forensic, but is adjusted for GNU
10
# tools (as used on Linux) and it works in a safe tmpdir directory.
11
# todo: rewrite in a form that allows running on more operating systems.
12
13
F=${1:?give filename as argument. cannot read from stdin.}
14
15
tmpprefix=${TMPDIR:-/tmp}/check_forensic.XXXXXX
16
tdir=$(mktemp -d $tmpprefix); test $? = 0 || { echo >&2 Could not create tmpdir. Exiting; exit 1; }
17
18
cut -f 1 -d '|' $F > $tdir/fc-all.$$
19
grep ^+ < $tdir/fc-all.$$ | cut -c2- | sort > $tdir/fc-in.$$
20
grep -- ^- < $tdir/fc-all.$$ | cut -c2- | sort > $tdir/fc-out.$$
21
join -v 1 $tdir/fc-in.$$ $tdir/fc-out.$$ | xargs -ixx egrep "^\\+xx" $F
22
rm $tdir/fc-all.$$ $tdir/fc-in.$$ $tdir/fc-out.$$
23
rmdir $tdir
24