Article View: news.software.nntp
Article #12016Re: Characterizing feed latency
From: Gordy Thompson
Date: Thu, 31 Oct 1996 00:00
Date: Thu, 31 Oct 1996 00:00
341 lines
11593 bytes
11593 bytes
In article <carr-ya023180002910961850040001@news.svl.trw.com>,
carr@svl.trw.com (John Carr) wrote:
>I'm looking for a method to help characterize the delay in my newsfeed. Is
>anything available that produces some metric that reflects the delay from
>posting to receipt? Something like the median of the difference between
>the time of receipt & the time of posting seems reasonable.
>
>Any suggestions?
This handy utility was posted a year ago. I looked for it with
Archie and AltaVista just now, but evidently nobody took the author up
on the suggestion to make it available on a public site.
Newsgroups: news.software.nntp
Subject: Script for newsfeed statistics
From: sommar@enea.se (Erland Sommarskog)
Date: 22 Oct 1995 11:24:09 +0100
I'd like to share with you a Perl script that I've put together. I
think I've posted it some time before, but there's a new function
in it now - and some more directions on how to use it in the comments
as well.
Anyway, the script reads the history file to find out how old
the news is that you get, and to find out the number of articles
by posting date. I use both this to monitor the function of our
only incoming feed (which is a lousy one). Some sample output:
0942 2413 1.68 0 0 0 2202 188 19 1 1 2
951020 #arts Avg <0 0< <1 1day 2d 3d 4d 5d 6d 7d 8d 9d
10 11 12 13
1542 16653 1.73 0 0 2 15605 776 177 51 13 11 10 3 0
2 0 0 3
1642 2070 2.07 0 0 0 1244 794 17 9 1 3 0 0 1
0 0 0 1
1742 450 2.06 0 0 0 25 422 1 0 0 2
1842 22 2.10 0 0 0 0 22
1942 11 2.19 0 0 0 0 11
2042 61 0.94 6 27 2 0 26
2142 1921 0.09 92 1775 36 12 0 3 1 2
2242 2783 0.23 102 2407 85 106 48 27 2 4 1 0 1
2342 3219 0.13 83 2986 48 78 12 8 0 0 2 0 1 0
1
Here you can see that our feed was behind for more than a day
and a half, until they apparently flushed the queues. (You can
can also see that our machine was sick and didn't run cron for a
while.)
And here is what you see in the file for article per posting date:
951016 43111
951017 56207
951018 54373
951019 2258
951020 19796
951021 43323
951022 14874
951023 24
Did the world take a holiday the 19th? I don't think so.
If anyone feels that this fits in an FTP archive somewhere, please
feel free to add it.
#!/usr/bin/perl
#
# histtime3 -this script provides statistics about your news feed.
Typically
# you run it from your crontab once an hour, although you
may choose
# another frequency if you wish. A typical crontab entry:
#
# 42 * * * * cd News/lists; ../histtime3 histtime.log
datefreq.log
#
# The first log file contains the following columns from
left to
# right: time of run, number of articles arrived since last
run,
# their average age in days, then a histogramme: no of arts
with
# negative age (time warp), no of arts days 0-0.5 days old,
no of
# arts 0.5-1.0 day old, and then 1.0-2.0 days old etc. When
the
# time has passed noon or midnight since the last run,
there is a
# header printed. This first log file is mandatory. The
script
# determines when the last run took place by looking at the
age
# of this script.
#
# The second log file continas number of articles by
posting date.
# The point with this statistics is that you can detect if
your
# feed suddenly just throw a bunch of articles away. This
log
# is optional; if you omit this argument, no such file is
written.
#
# Implementation detail: the file works by reading the
history
# file. It starts from one place near the end, and then
jumps
# around until it finds the first article arrived after the
last
# run. The script may miss a handfull of articles arriving
when
# the script runs. (Did I say it was perfect.)
#
# IMPORTANT NOTICE about HARDCODINGS!
# You most certainly want to change "enea.se" below to
something
# that matches your own site name. Excluding your own site
name
# is good, because your own articles are always 0 days old
or there-
# about. If your feed is far behind, this may be the only
articles
# in that range, fooling you to believe that you are
actually
# getting some new articles from your feed.
# Furthermore there are some numbers hardcoded below that
don't
# affect function, but that you may want to adjust your
site to
# improve performance.
# Also, if you don't have the history file in
/usr/local/news,
# you need to change that.
#
# Eventually the copyright stuff. This script was written by Erland
Sommarskog
# at ENEA Data AB in his spare time, and thus believes he holds all
copyrights
# to this script himself. Copyright and copyright, do want ever you
want with
# it, but if you sell it, don't keep the money but donate them to me
or the
# beggar you see in the streets. Specifically the GNU so-called
copyleft does
# in now way apply to these plain lines of code.
#
# If you have ideas or improvements to share with me, I can be reached
at
# sommar@enea.se.
#
# My special thanks for Larry Wall for inventing Perl.
#
# Enough talk, let's work!
# Formats time in a nice format.
sub format_time {
local($time) = @_;
local($year, $month, $day, $hour, $min, $sec);
$time = time if (! defined $time);
($sec, $min, $hour, $day, $month, $year) = localtime($time);
return sprintf("%2.2d%2.2d%2.2d %2.2d%2.2d",
$year, ++$month, $day, $hour, $min);
}
# This routine extracts the things we want from a history line.
Returns
# 0, if at end of file.
sub get_times{
local($msg_id, $times, $arrival, $expire, $posted, $line);
$line = <H>;
return (0, 0, 0) if ! $line;
($msg_id, $times) = split(" ", $line);
($arrival, $expire, $posted) = split(/\~/, $times);
($msg_id, $arrival, $posted);
}
# Get arguments and starting point.
$file = shift @ARGV;
die "Argument missing\n" unless $file;
$start_time = time - 86400 * -M $file;
$datefile = shift @ARGV if @ARGV;
# Open and read the date file given and if if we have one.
if ($datefile && -e $datefile) {
open(F, "$datefile") || die "Cannot open $datefile: $!\n";
while (<F>) {
chop;
($date, $no_of_arts) = split;
$dates{$date} = $no_of_arts;
}
close F;
}
# Open the history file
open(H, "/usr/local/news/history") || die "Could open history file:
$!\n";
# Normally $start_time is some hour ago, so we better start looking at
# from the end of the history file, but if is too long ago we start
# from the beginning. Four days is just my choice, because we expire
most
# after three days. This is mainly useful when you run the script the
# first time.
if (time - $start_time < 4 * 86400) {
# Position us somewhere near the end. -200000 is a good guess for a
little
# more than an hour of traffic at our site for the moment.
seek(H, -200000, 2);
# Iterate until we are before the starting time.
while (1) {
<H>; # Sync to a new
line
($msg_id, $arrival, $posted) = &get_times(); # Examine the
current line
last if $arrival < $start_time || ! $msg_id; # Break if we are
behind now
seek(H, -100000, 1); # Take another step
back;
}
}
else {
$arrival = 0;
$msg_id = 1;
}
# Now iterate until we're just ahead of the starting time.
while ($arrival < $start_time && $msg_id) {
($msg_id, $arrival, $posted) = &get_times();
}
# Now we can start collecting the data.
$sum = $no_of_art = $neg_travs = $half_days = $#histogramme = 0;
while ($msg_id) {
# Ignore our own articles. Note: this is hardcoded, so you need to
change
# this
next if $msg_id =~ /enea.se\>/;
# Skip cancelled or expired articles.
next if ! $posted;
# Calculate the travel time and increment.
$travel_time = ($arrival - $posted) / 86400.0;
$sum += $travel_time;
$no_of_art++;
# Put it in the right box in the histogramme
if ($travel_time < 0) {
$neg_travs++;
}
elsif ($travel_time > 0.5 && $travel_time < 1.0) {
$half_days++;
}
else {
$histogramme[int($travel_time)]++;
}
# Get the date the article was posted and increment.
($posted_date) = split(' ', &format_time($posted));
$dates{$posted_date}++;
# Pick up the next line.
} continue {
($msg_id, $arrival, $posted) = &get_times();
}
close H;
# Open the output file.
open(F, ">>$file");
$now = &format_time(time);
$then = &format_time($start_time);
# This is the widths for ages for 1 day and more.
@widths = (5, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2);
# Find out if we are to write a header. We do this every the time the
# small hand has passed twelve.
($daynow, $timenow) = split(" ", $now);
($daythen, $timethen) = split(" ", $then);
if ( ($daynow != $daythen) || ($timenow > 1200 && $timethen < 1200) )
{
print F "$daynow #arts Avg <0 0< <1 1day";
foreach $i (2..$#widths) {
$width = ($i <= 9 ? $widths[$i] - 1 : $widths[$i]);
$d = ($i <= 9 ? "d" : "");
printf F " %${width}d${d}", $i;
}
print F "\n";
}
printf F " %s %5d", $timenow, $no_of_art;
if ($no_of_art > 0) {
printf F " %4.2f %3d %4d %4d",
$sum/$no_of_art, $neg_travs, $histogramme[0], $half_days;
foreach $i (1..$#histogramme) {
$width = ($widths[$i] ? $widths[$i] : 1);
printf F " %${width}d", $histogramme[$i];
}
}
else {
$server = `/var/INN/bin/ctlinnd mode`;
$server = (split(' ', $server))[1];
print F " Server mode: $server.";
}
print F "\n";
close F;
# Now write the date file
if ($datefile) {
open(F, ">$datefile.new") || die "Cannot write to $datefile.new:
$!\n";
foreach $date (sort keys %dates) {
printf F "%s %7d\n", $date, $dates{$date};
}
close F;
rename("$datefile.new", $datefile) ||
die "Cannot rename $datefile.new to $datefile: $!\n";
}
==========================================================================
Gordon T. Thompson gordy@nytimes.com
Manager, Internet Services 212 556 1386
The New York Times fax: 212 556 1636
The Times and I have an arrangement: Neither of us speaks for the other.
Technical Details
Message-ID:
<3278482c.20049657@newsgate>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-mailReferences:
<carr-ya023180002910961850040001@news.svl.trw.com>Show Full Headers
Complete Article Headers
Message-ID: <3278482c.20049657@newsgate> Subject: Re: Characterizing feed latency Date: Thu, 31 Oct 1996 00:00:00 +0000 From: gordy@nytimes.com (Gordy Thompson) References: <carr-ya023180002910961850040001@news.svl.trw.com> 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: 193760694 Distribution: inet Content-type: text/plain; charset=us-ascii Organization: The New York Times Mime-version: 1.0 Newsgroups: news.software.nntp