Xref: utzoo news.software.b:6337 news.software.nntp:967 comp.lang.perl:3221 Path: utzoo!utstat!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!quanta.eng.ohio-state.edu!icarus!kaul From: kaul@icarus.eng.ohio-state.edu (Rich Kaul) Newsgroups: news.software.b,news.software.nntp,comp.lang.perl Subject: Re: Who's reading mail on my machine? Message-ID: Date: 5 Dec 90 20:49:21 GMT References: <1990Dec5.182742.18081@ssd.kodak.com> Sender: news@quanta.eng.ohio-state.edu Followup-To: news.software.nntp Distribution: na Organization: The Ohio State University Dept of Electrical Engineering Lines: 72 Nntp-Posting-Host: icarus In-reply-to: dcox@ssd.kodak.com's message of 5 Dec 90 18:27:42 GMT Originator: kaul@icarus.eng.ohio-state.edu In article <1990Dec5.182742.18081@ssd.kodak.com> dcox@ssd.kodak.com (Don Cox (253-7121)) writes: Is there any way that I can have nntpd alert me to the fact that another machine is accessing news from my news server? Recompile nntp with LOG defined in common/conf.h. I prefer to use the FAKESYSLOG option to send the nntp output to its own file. I then use the following perl script to reduce the information in the file and print a report on the machines connecting, the number of connections, the amount of CPU, system and wall time consumed by the connections, the machines refused connections and what groups were read. This makes it easier to determine which groups get fast expire times ... A comment on the perl style: there is none. What do you want from a quick hack while I was just beginning to learn perl? At least it runs well enough ;-) #!/usr/bin/perl # # A perl script to summarize nntp usage for our news host. # The report generated lists the number of connections and times of # the news reading sessions, rejected connections and groups. # # Author: Rich Kaul # Date: Nov. 2, 1990 $date=`date`; ($program = $0) =~ s%.*/%%; if ($#ARGV < 0) { die "usage: $program [[nntplogfile]...]\n"; } while (<>) { chop; # avoid \n on last field @tmp=split; $host=$tmp[5]; if ( $tmp[6] eq "times" ) { $machine_usrtime{$tmp[5]} += $tmp[8]; $machine_systime{$tmp[5]} += $tmp[10]; $machine_etime{$tmp[5]} += $tmp[12]; } elsif ( $tmp[6] eq "connect" ) { $machine_connect{$tmp[5]} += 1; } elsif ( $tmp[6] eq "group" ) { $group_count{$tmp[7]} += 1; } elsif ( $tmp[6] eq "refused" ) { $refused{$tmp[5]} += 1; } } print "\n\t\tSummary of News Usage for $date\n"; print "\t\t\tTime By Machine\n"; print "\t Machine Name\t Conn.\t User\t System\t Wall\n"; foreach $key (sort(keys machine_usrtime)) { printf "%27s %5d %10.2f %14.2f %14.2f\n", $key, $machine_connect{$key}, $machine_usrtime{$key}, $machine_systime{$key}, $machine_etime{$key}; } print "\n\t\t\tRefused Connections\n"; foreach $key (sort(keys refused)) { printf "%27s %5d\n", $key, $refused{$key}; } print"\n\t\t\tGroups Read\n"; print "\t\t Group name\t Conn.\n"; foreach $key (sort(keys group_count)) { printf "%27s\t%5d\n", $key, $group_count{$key}; } -- Rich Kaul | It wouldn't be research if we kaul@icarus.eng.ohio-state.edu | knew what we were doing. Brought to you by Super Global Mega Corp .com