brendan@cs.widener.edu (Brendan Kehoe) (06/25/91)
I just set this up, and thought it might be of interest to others. (Well, there's a chance, right? :-) ) If not, you can ignore it. The program uunewslog below will make syslog generate stats for UUCP-based news, by logging how many articles are batched on each run by CNews. (Although I suppose this would work in BNews too, by just putting the call to the program in the right place.) It's called as `uunewslog host n-articles'; for example, uunewslog foonix 19 would log: ..date.. laverne uunews[17469]: foonix stats 19 offered 19 accepted 0 rejected 0 failed ..date.. laverne uunews[17469]: foonix xmit user 0.1 system 0.1 elapsed 60 to the NEWS syslog facility. (This is all assuming that you've modified your syslog.conf so that the news stats will go somewhere; mine currently has news.info ifdef(`LOGHOST', /var/log/newslog, @loghost) in it.) [ Before I go any further, let me say that none of this is part of official CNews; it is nothing more than a hack on my part.] To make it actually use the program, you have to add a line to the $NEWSBIN/batch/sendbatches program, as is illustrated in this diff: -- cut -- *** batch/sendbatches.~1~ Mon Mar 25 13:55:53 1991 --- batch/sendbatches Tue Jun 25 08:38:47 1991 *************** *** 174,179 **** --- 174,180 ---- fi done ndone=`echo $them | wc -w` + $NEWSBIN/local/uunewslog $sys $ndone nbatch=`expr $nbatch - $ndone` # Recheck the space -- it can fall for other reasons. -- cut -- And, finally, here's the short program uunewslog to do the logging; I have it spit out the second line (with the user & system time, and total # of seconds, using relatively bogus #'s), just because my perl script that puts together the news reports happens to use that line at one point for other things. You can take it out if yours doesn't need xmit stats. This requires syslog(3) ability; I haven't tried it with the fake syslog that comes with NNTP. Also, this was built and tested on a Sun Sparc-1 running SunOS 4.1.1; your mileage may vary. I'd suggest creating a directory called $NEWSBIN/local, and put this in there. (I also made it owned by news/news, mode 754, just so that occasional passers-by won't screw up your stats.) If you put it somewhere else, make sure to compensate when you change sendbatches above. -- cut -- /* * uunews v1.0 - 06/25/91 - by Brendan Kehoe (brendan@cs.widener.edu) * * Make normal sendbatches put an entry in the syslog so that what was the * "NNTP" logging can become the logging of everything newsy. */ #include <stdio.h> #include <syslog.h> main(argc, argv) int argc; char **argv; { if (argc < 3) { fprintf(stderr, "usage: %s hostname n-articles\n", *argv); exit(1); } openlog("uunews", LOG_PID, LOG_NEWS); syslog(LOG_INFO, "%s stats %s offered %s accepted 0 rejected 0 failed", *(argv + 1), *(argv + 2), *(argv + 2)); /* this line isn't really necessary; you can take it out if your report-maker doesn't have to see the xmit stats */ syslog(LOG_INFO, "%s xmit user 0.1 system 0.1 elapsed 60"); closelog(); } -- cut -- -- Brendan Kehoe - Widener Sun Network Manager - brendan@cs.widener.edu Widener University in Chester, PA A Bloody Sun-Dec War Zone