LSTSRV-L Archives

LISTSERV Site Administrators' Forum

LSTSRV-L

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Jeffrey Boulier <[log in to unmask]>
Mon, 13 Oct 1997 22:47:55 -0400
TEXT/PLAIN (121 lines)
Hi y'all!

Fans of my previous useless programs ("WHEREFROM.SAS", which counted up
who is subscribed on a particular list by domain, and another which
did some stats on what type of computers were making up the LISTSERV
backbone) have no doubt been waiting with baited breath for more of the
same. (More strictly speaking, "fan". Thanks Mom!)

As for all the rest of you, tough luck! I'm posting this one anyways.

The following Unix shell program will go through a Unix LISTSERV log file
and tally up where mail is being sent. It will probably work for those
lucky enough to be running POSIX-compliant VM, and will maybe even work
(with a slight modification) for those who have to run NT.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
cat ~listserv/listserv.log | grep posted |  \
        cut -f2 -d"@"  |grep -v ":" | sort | \
        uniq -c | sort -nr| more
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Note that this program actually can be written as just one line -- the
"\"s are allowing me to hit the return key without the computer
prematurely trying to run the commands.

IMPORTANT: This isn't measuring traffic through the LISTSERV backbone;
just ordinary mail deliveries. This is why when you run the program,
you're not going to see, say, AOL. It will display mail sent to your
server to distribute within your domain.


EXPLANATION: If you know how the above program works, then don't bother
reading this. Otherwise, take a look and see how it does its thing!

I) Use the "cat" command to start printing out the log file, which resides
in the listserv id's home directory:

cat ~listserv/listserv.log

II) The output from that command is 'piped' ("|") into the 'grep' command,
which matches all lines containing the word "posted", and throws out
everyting else:

         | grep posted

So this matches all lines like...

9 Oct 1997 23:05:59 Mail posted via SMTP to [log in to unmask]
                         ^^^^^^
III) We take these, and pipe them through the 'cut' command. We're telling
it we want the 2nd field, using the '@' character as a divider,

So this gives us output like...

        UTXVMS.CC.UTEXAS.EDU.
        VMS.CIS.PITT.EDU.
        WORLDNET.ATT.NET.
        GWIS2.CIRC.GWU.EDU.


III) Then we use grep with the '-v' switch, which says 'reVerse the usual;
throw out lines which have the ":" character in them. This is so I can get
rid of addresses like:

         @GWUVM.GWU.EDU:[log in to unmask]
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
which are just a bit too wierd for me to understand, not to mention
not valid on my system.

IV) This big long listing of hosts is then sorted so it is in alphabetical
order:

        | sort


V) We needed the host listing sorted so we can use the 'uniq' command,
which ('-c') counts up all unique lines.

        | uniq -c

This gives us output like:

        197 ANG.AF.MIL
        1104 SEAS.GWU.EDU
        89 WELL.COM

and so forth.

VI) Wouldn't it be nicer to have that output 'sort'ed again, treating '-n'
that first field as a number, and '-r' reversing the usual order so that
the bigger numbers come on top? Thought so!

        | sort -nr

Giving output like:

        49829 GWIS2.CIRC.GWU.EDU.
        1104 SEAS.GWU.EDU.
         796 EROLS.COM.
         457 IX.NETCOM.COM.
                ...

VII) And finally, so this doesn't scroll to fast off the screen, we can
use the "more" command to display that output a page at a time.

        | more


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Other things you can do, that might be useful (hah!).

1) use "grep" and look to see where mail is going within your domain (eg |
grep GWU.EDU). Wave the numbers in front of your director to have him
provide your poor suffering listserv machine with more power.

2) use the program as an example of how people can string together a few
Unix commands and do some flashy things with the data stream. :-)

                --Jeff "can anyone tell I'm from a .edu?" B.

ATOM RSS1 RSS2