home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # this is a simple script for converting the addresses in a server log
- # to internet domain names.
-
- # the argument to this script is the name of the server log file.
-
- if (test $# -eq 0)
- then
- echo "usage: $0 <server-log-file>"
- echo " converts IP addresses in <server-log-file> to IP names."
- exit 1
- fi
-
- addrs=/tmp/addrs.$$
-
- grep -i from: $* | \
- awk '{if ($10 == "from:") {print $11} else {print $10}}' | \
- sort | \
- awk '$1 != last { print $1; last = $1 }' | \
- awk -F. '{print $4"."$3"."$2"."$1".in-addr.arpa"}' >> $addrs
-
- scriptfile=/tmp/script.$$
- echo "set q=ptr" > $scriptfile
- cat $addrs >> $scriptfile
-
- /usr/etc/nslookup < $scriptfile | grep "host name" | \
- awk -F. '{ {printf "%s.%s.%s.%s %s",$4,$3,$2,$1,$6} { for (i = 7; i <= NF;
- i++) { printf ".%s",$i } } {printf "\n"} }' | \
- awk '{printf ("%-16s %s\n", $1,$6)}' | sort -n
-
- wc -l $addrs | awk '{print $1 " different hosts"}'
-
- rm $scriptfile $addrs
-