Article View: news.software.b
Article #6970Re: Wanted: C news log file report generator
From: Ross Ridge
Date: Sat, 17 Feb 1990 23:26
Date: Sat, 17 Feb 1990 23:26
161 lines
4287 bytes
4287 bytes
This is a awk file I wrote for generating a simple report of the C news log
file. You'll probably want to edit this to taste, for instance if you
junk a lot of newsgroups you may want to remove the part that list them.
Also you may want to change the size of some the fields according to
the number of articles yor system processes.
This is an excerpt from our $NEWSBIN/maint/newsdaily file. It mails
generated report daily and appends the table part of the report to
$NEWSCTL/stats.
# keep one generation of log -- it's big
rm -f log.o
mv log log.o && >log
awk -f $NEWSBIN/maint/newsstats.awk log.o > stats.last
mail -s "News statistics" $gurus < stats.last
date >> stats
sed '/^$/,$d' stats.last >> stats
echo "" >> stats
I believe this awk file should work under olds awks, but I don't have
one handy to try it out. Let me know if you find any bugs or campatibility
problems. (We don't do ihave/sendme so it may not report this correctly.)
Ross Ridge
---- cut here ---
#
# newsstats.awk -- by Ross Ridge (ross@contact.uucp) Public Domain
#
$5 == "+" {
accepted[$4]++;
for(i = 7; i <= NF; i++) {
sent[$i]++;
name[$i] = $i;
}
}
$5 == "-" {
rejected[$4]++;
s = ""
for(i = 7; i <= NF; i++)
s = s " " $i
why[s]++
}
$5 == "j" {
junked[$4]++;
badngs[$NF]++;
}
$5 == "i" {
ihave[$8]++;
}
$5 == "s" {
sendme[$8]++;
}
{
if ($5 ~ /[-+j]/) {
total[$4]++;
name[$4] = $4;
} else if ($5 ~ /is/) {
total[$8]++;
name[$8] = $8;
} else
unknown++;
}
END {
# 123456789012345678901234567890123456789012345678901234567890112345678901
print "Sitename Accept Reject Junked I-Have Sendme Total Sent"
print "------------------------------------------------------------------------"
for (s in name) {
printf("%-20s ", s);
if (accepted[s] == "")
printf(" ");
else {
printf("%6d ", accepted[s]);
atotal += accepted[s];
}
if (rejected[s] == "")
printf(" ");
else {
printf("%6d ", rejected[s]);
rtotal += rejected[s];
}
if (junked[s] == "")
printf(" ");
else {
printf("%6d ", junked[s]);
jtotal += junked[s];
}
if (ihave[s] == "")
printf(" ");
else {
printf("%6d ", ihave[s]);
itotal += ihave[s];
}
if (sendme[s] == "")
printf(" ");
else {
printf("%6d ", sendme[s]);
stotal += sendme[s];
}
if (total[s] == "")
printf(" ");
else {
printf(" %6d ", total[s]);
thetotal += total[s];
}
if (sent[s] == "")
printf("\n");
else {
printf(" %6d\n", sent[s]);
senttotal += sent[s];
}
}
printf("%20s ", "Totals:");
if (atotal == "")
printf(" ");
else
printf("%6d ", atotal);
if (rtotal == "")
printf(" ");
else
printf("%6d ", rtotal);
if (jtotal == "")
printf(" ");
else
printf("%6d ", jtotal);
if (itotal == "")
printf(" ");
else
printf("%6d ", itotal);
if (stotal == "")
printf(" ");
else
printf("%6d ", stotal);
if (thetotal == "")
printf(" ");
else
printf(" %6d ", thetotal);
if (senttotal == "")
printf("\n");
else
printf(" %6d\n", senttotal);
print
print "Junked Newsgroups:"
for (s in badngs)
printf("\t%s: %d\n", s, badngs[s]);
print
print "Why aritcles were rejected:"
for (s in why)
printf("\t%s: %d\n", s, why[s]);
print
if (unknown != "")
printf("\nUnknown lines: %d\n", unknown);
}
---- cut here ----
--
Ross Ridge //
"The Great HTMU" [oo]
ross@contact.uucp -()-
ross@watcsc.waterloo.edu //
Technical Details
Message-ID:
<1990Feb17.232600.1586@contact.uucp>Path:
arc1-ca.pugleaf.net!utzoo!dciem!nttor!contact!rossReferences:
<25DBCBAC.5715@deimos.cis.ksu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!dciem!nttor!contact!ross From: ross@contact.uucp (Ross Ridge) Newsgroups: news.software.b Subject: Re: Wanted: C news log file report generator Message-ID: <1990Feb17.232600.1586@contact.uucp> Date: 17 Feb 90 23:26:00 GMT References: <25DBCBAC.5715@deimos.cis.ksu.edu> Reply-To: ross@contact.UUCP (Ross Ridge) Organization: Contact User Supported BBS Lines: 161