🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #6250

Re: How can I log the groups my users are reading on my Usenet server...

#6250
From: Jack Bryans
Date: Wed, 03 Apr 1996 00:00
65 lines
2391 bytes
In article <4jsf3h$oec@athena.ulaval.ca> Dominique Berube
<Dominique.Berube@sit.ulaval.ca> writes:

>      I'm looking to accumulate statistics about the groups my users
> are reading on my server.

The following perl script is driven by normal mail delivery using the alias
for usenet.  It accumulates news group readership and maintains a frequency
sorted list in the groups.read file among your news logs.

If news is read via nfs on your system, you're SOL.

#!/usr/local/bin/perl

$cume = "/var/log/news/groups.read";

while(<>) {
    next until /^Subject:/;
    last if /Daily Usenet report/;
    seek(STDIN,0,2);
    exit;}

exit if eof;

while(<>) { last if /\(by newsgroup\)/; }

exit if eof;

if (open(CUME,"$cume")) {
    while(<CUME>) {
	($grp,$cnt) = split;
	$stats{$grp} = $cnt;}}

while(<>) {
    last if /^\s$/;
    ($grp,$cnt) = split;
    $stats{$grp} += $cnt;}

open(CUME,"> $cume")  ||
    exec( "/usr/sbin/Mail -s \"failed to create $cume\" usenet < /dev/null" );

foreach $key (sort by_value keys %stats) { write(CUME); }
close(CUME);

format CUME =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< @######
$key,$stats{$key}
..

sub by_value { $stats{$b} <=> $stats{$a}; }

The path to perl and the news log path at the top, as well we the way you
call mail towards the bottom are the areas that may need change for your
system.

Suppose the perl script is /usr/local/etc/cumegrps.pl.  Just add
|"/usr/local/etc/cumegrps.pl"
to your usenet alias and, as user news, touch the groups.read file.

If your sendmail is using smrsh, you'll need to put it in /usr/adm/sm.bin,
or however you've got your smrsh config'd.

Jack

Technical Details
Message-ID: <2h20m6uhi0.fsf@wren.acs.csulb.edu>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <4jsf3h$oec@athena.ulaval.ca>

Show Full Headers
Complete Article Headers
Message-ID: <2h20m6uhi0.fsf@wren.acs.csulb.edu>
Subject: Re: How can I log the groups my users are reading on my Usenet server...
Date: Wed, 03 Apr 1996 00:00:00 +0000
From: jbryans@csulb.edu (Jack Bryans)
References: <4jsf3h$oec@athena.ulaval.ca>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 145531609
Distribution: inet
Sender: jbryans@wren.acs.csulb.edu
To: Dominique Berube <Dominique.Berube@sit.ulaval.ca>
Organization: Cal State Long Beach
Newsgroups: news.software.nntp