Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!sample.eng.ohio-state.edu!icarus!kaul From: kaul@icarus.eng.ohio-state.edu (Rich Kaul) Newsgroups: news.software.nntp Subject: Re: NNTP news monitor Summary: NNTP has some built in, but this perl script can clean it up, too Message-ID: Date: 22 Feb 91 15:56:45 GMT References: <1991Feb22.063725.26321@qualcomm.com> Sender: kaul@ee.eng.ohio-state.edu (Rich Kaul) Organization: Ohio State University Electrical Engineering Lines: 108 In-Reply-To: jbeckley@qualcomm.com's message of 22 Feb 91 06:37:25 GMT In article <1991Feb22.063725.26321@qualcomm.com> jbeckley@qualcomm.com (Gumby) writes: I'm looking for a program that monitors news usage via NNTP. If you compiled your nntpd with the LOG option you can do it. For example, I have NNTP logging directed to its own file, which I then run the perl script at the end of this posting on. Doing this daily, I get reports mailed to me daily which look like: Summary of News Usage for Fri Feb 22 06:06:08 EST 1991 Time By Machine Machine Name Conn. User System Wall akela 8 34.18 42.18 19269.36 [list of many other machines and times deleted] ------------------------------------------------------------------------------- total (without feeds) 110 344.90 358.48 87456.86 total 298 673.20 887.74 171513.72 Refused Connections Groups Read Group name Conn. alt.activism 5 alt.aquaria 1 [list of groups deleted] The perl script to do this is pretty simple. I know it's not pretty and not very efficient, but it still runs in well under a minute on my Sun 3/160 so I have little incentive to fix it. Perl is available for anonymous ftp from tut.cis.ohio-state.edu, jpl-devvax.jpl.nasa.gov and anonymous uucp from osu-cis. -rich #!/usr/bin/perl # # A perl script to summarize nntp usage for our reading hosts # (our feeds, are handled differently in this summary). # The report generated lists the number of connections and times of # the news reading sessions. # # Author: Rich Kaul (kaul@icarus.eng.ohio-state.edu) # Date: Nov. 2, 1990 # Modified: Jan. 13, 1991 - Cleaned up the format for very long # group names and broke out feeder stats. # NNTP feed sites. Change here. Two given as an example. $FEEDA="foobaz.edu"; $FEEDB="foobar.edu"; $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\t\tSummary of News Usage for $date\n"; print "\t\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}; $total_connect += $machine_connect{$key}; $total_usrtime += $machine_usrtime{$key}; $total_systime += $machine_systime{$key}; $total_etime += $machine_etime{$key}; } print"-------------------------------------------------------------------------------\n"; # Adjust this line based on the number of feeds you have printf "%27s %5d %10.2f %14.2f %14.2f\n", "total (without feeds)", $total_connect-$machine_connect{$FEEDA}-$machine_connect{$FEEDB}, $total_usrtime-$machine_usrtime{$FEEDA}-$machine_usrtime{$FEEDB}, $total_systime-$machine_systime{$FEEDA}-$machine_systime{$FEEDB}, $total_etime-$machine_etime{$FEEDA}-$machine_etime{$FEEDB}; printf "%27s %5d %10.2f %14.2f %14.2f\n", total, $total_connect, $total_usrtime, $total_systime, $total_etime; print "\n\t\t\t\tRefused Connections\n"; foreach $key (sort(keys refused)) { printf "%27s %5d\n", $key, $refused{$key}; } print"\n\t\t\t\t\tGroups Read\n"; print "\t\t\t Group name\t Conn.\n"; foreach $key (sort(keys group_count)) { printf "%41s\t%5d\n", $key, $group_count{$key}; } Brought to you by Super Global Mega Corp .com