Add postingstats to tools.
postingstats.pl will parse groupstats output and create a posting ready to post to de.admin.news.misc. Signed-off-by: Thomas Hochstein <thh@inter.net>
This commit is contained in:
		
							parent
							
								
									c6346470f9
								
							
						
					
					
						commit
						53c2032850
					
				
					 1 changed files with 99 additions and 0 deletions
				
			
		
							
								
								
									
										99
									
								
								tools/postingstats.pl
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								tools/postingstats.pl
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,99 @@
 | 
			
		|||
#!/usr/bin/perl
 | 
			
		||||
#
 | 
			
		||||
# postingstats.pl
 | 
			
		||||
#
 | 
			
		||||
# This script will create a posting statistic for de.admin.lists
 | 
			
		||||
# from NewsStats output.
 | 
			
		||||
#
 | 
			
		||||
# It is part of the NewsStats package.
 | 
			
		||||
#
 | 
			
		||||
# Copyright (c) 2010-2012 Thomas Hochstein <thh@inter.net>
 | 
			
		||||
#
 | 
			
		||||
# It can be redistributed and/or modified under the same terms under
 | 
			
		||||
# which Perl itself is published.
 | 
			
		||||
#
 | 
			
		||||
# $~ groupstats.pl --nocomments --sums --format dump | postingstats.pl xxxx-xx
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
use strict;
 | 
			
		||||
use constant TABLEWIDTH => 28; # width of table without newsgroup name
 | 
			
		||||
 | 
			
		||||
our $VERSION = '0.01';
 | 
			
		||||
 | 
			
		||||
##### ----- subroutines -----
 | 
			
		||||
 | 
			
		||||
sub percentage {
 | 
			
		||||
# calculate percentage rate from base value and percentage
 | 
			
		||||
    my ($base,$percentage) = @_;
 | 
			
		||||
    return ($percentage * 100 / $base);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub divider {
 | 
			
		||||
# build a divider line of $symbol as wide as the table is
 | 
			
		||||
    my ($symbol,$maxlength) = @_;
 | 
			
		||||
    return ':' . $symbol x ($maxlength+TABLEWIDTH) . ":\n";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
##### ----- main loop -----
 | 
			
		||||
 | 
			
		||||
# get $month from ARGV
 | 
			
		||||
my $month = shift;
 | 
			
		||||
 | 
			
		||||
# read from STDIN
 | 
			
		||||
my (%postings, $hierarchy, $maxlength);
 | 
			
		||||
 | 
			
		||||
while(<>) {
 | 
			
		||||
    my ($group, $postings) = split;
 | 
			
		||||
    $hierarchy = $postings if $group eq 'de.ALL';
 | 
			
		||||
    next if $group =~ /ALL$/;
 | 
			
		||||
    $postings{$group} = $postings;
 | 
			
		||||
    $maxlength = length($group) if length($group) > $maxlength;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# print to STDOUT
 | 
			
		||||
my $heading = ' Postingstatistik fuer de.* im Monat '.$month;
 | 
			
		||||
my $padding = ' ' x (($maxlength+TABLEWIDTH-2-length($heading))/2);
 | 
			
		||||
my $timestamp = time;
 | 
			
		||||
my $counter = 0;
 | 
			
		||||
 | 
			
		||||
print <<HEADER;
 | 
			
		||||
From: Thomas Hochstein <thh\@inter.net>
 | 
			
		||||
Newsgroups: de.admin.news.misc
 | 
			
		||||
Subject: Postingstatistik fuer de.* im Monat $month
 | 
			
		||||
Message-ID: <destat-postings-$month.$timestamp\@mid.news.szaf.org>
 | 
			
		||||
Mime-Version: 1.0
 | 
			
		||||
Content-Type: text/plain; charset=ISO-8859-1
 | 
			
		||||
Content-Transfer-Encoding: 7bit
 | 
			
		||||
User-Agent: postingstats.pl/$VERSION (NewsStats)
 | 
			
		||||
 | 
			
		||||
HEADER
 | 
			
		||||
 | 
			
		||||
print ÷r('=',$maxlength);
 | 
			
		||||
printf(": %s%s%s :\n",$padding,$heading,$padding);
 | 
			
		||||
print ÷r('=',$maxlength);
 | 
			
		||||
printf(": Nr.  : Anzahl : Prozent : %-*s :\n",$maxlength,'Newsgroup');
 | 
			
		||||
print ÷r('-',$maxlength);
 | 
			
		||||
 | 
			
		||||
foreach my $group (sort { $postings{$b} <=> $postings {$a}} keys %postings) {
 | 
			
		||||
    $counter++;
 | 
			
		||||
    printf(": %3u. : %6u : %6.2f%% : %-*s :\n",$counter,$postings{$group},&percentage($hierarchy,$postings{$group}),$maxlength,$group);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
print ÷r('-',$maxlength);
 | 
			
		||||
printf(":      : %6u : %s : %-*s :\n",$hierarchy,'100.00%',$maxlength,'de.*');
 | 
			
		||||
print ÷r('=',$maxlength);
 | 
			
		||||
 | 
			
		||||
print <<LEADOUT;
 | 
			
		||||
 | 
			
		||||
Alle Zahlen wurden ermittelt auf einem Newsserver mit redundanter Anbin-
 | 
			
		||||
dung fuer de.*  unter Anwendung ueblicher  Filtermassnahmen. Steuernach-
 | 
			
		||||
richten werden  nicht erfasst; Postings, die  supersedet  oder gecancelt
 | 
			
		||||
wurden, bleiben  erfasst, sofern sie das System  ueberhaupt (und vor der
 | 
			
		||||
Loeschnachricht) erreicht  haben.  Crosspostings werden in jeder Gruppe,
 | 
			
		||||
in die sie  gerichtet sind, gezaehlt, aber bei  Ermittlung der Summe be-
 | 
			
		||||
reinigt; daher ist  die Postinganzahl fuer de.* gesamt niedriger als die
 | 
			
		||||
Summe der Postinganzahlen der Einzelgruppen.
 | 
			
		||||
 | 
			
		||||
Die Daten stehen graphisch aufbereitet unter <http://usenet.dex.de/> zur
 | 
			
		||||
Verfuegung.
 | 
			
		||||
LEADOUT
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue