🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #11058

patch to show INN idle time

#11058
From: nils mccarthy
Date: Sun, 22 Sep 1996 00:00
68 lines
2899 bytes
A couple of my feeds have requested this code after I mentioned its
existance to them, so I thought that perhaps the world in general
would find this of use.  This is a patch that reports to news.notice
every 5 minutes telling how much time INN is spending waiting for
network I/O (and thus has nothing it's working on), as opposed to
processing articles, writing them to disk, and sending their
information to outgoing feeds.

My assessment of the situation is that if the idle time reads near or
at 0, then feeding sites will probably be falling behind.  Here, idle
time usually ranges between 50 and 150 out of 300.  I'm interested in
other sites' experiences.

I mostly use an in-house news log analyser, so I don't have a patch to
get either innlog to recognize and summarize these messages.  Sorry.

Enjoy,

-nils

===================================================================
--- innd/chan.c	1996/09/18 09:38:58	1.1.1.1
+++ innd/chan.c	1996/09/23 05:37:38
@@ -714,6 +714,13 @@
     struct timeval	MyTime;
     long		silence;
     char		*p;
+    static struct timeval total_time_used;
+    static time_t last_checkpoint_time;
+    struct timeval before_select, after_select;
+
+    time(&last_checkpoint_time);
+    total_time_used.tv_sec = 0;
+    total_time_used.tv_usec = 0;
 
     for ( ; ; ) {
 	/* See if any processes died. */
@@ -723,8 +730,27 @@
 	MyRead = RCHANmask;
 	MyWrite = WCHANmask;
 	MyTime = TimeOut;
+	gettimeofday(&before_select, NULL);
 	count = select(CHANlastfd + 1, &MyRead, &MyWrite, (FDSET *)NULL,
 		&MyTime);
+	gettimeofday(&after_select, NULL);
+	
+	total_time_used.tv_sec += after_select.tv_sec - before_select.tv_sec;
+	total_time_used.tv_usec += after_select.tv_usec + 1000000
+	  - before_select.tv_usec;
+	while (total_time_used.tv_usec > 1000000) {
+	  total_time_used.tv_usec -= 1000000;
+	  total_time_used.tv_sec ++;
+	}
+	total_time_used.tv_sec--;
+	
+	if (after_select.tv_sec >= (last_checkpoint_time+300)) {
+	  syslog(L_NOTICE, "ME seconds %d idle %d",
+		 after_select.tv_sec - last_checkpoint_time,
+		 total_time_used.tv_sec);
+	  total_time_used.tv_sec = 0;
+	  last_checkpoint_time = after_select.tv_sec;
+	}
 	if (GotTerminate) {
 	    (void)write(2, EXITING, STRLEN(EXITING));
 	    CleanupAndExit(0, "received signal");

Technical Details
Message-ID: <5259lv$s6n@nnrp1.news.primenet.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

Show Full Headers
Complete Article Headers
Message-ID: <5259lv$s6n@nnrp1.news.primenet.com>
Subject: patch to show INN idle time
Date: Sun, 22 Sep 1996 00:00:00 +0000
From: nils mccarthy <nils@primenet.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: 184723752
Organization: Primenet Services for the Internet
X-posted-by: nils@206.165.5.107 (nils)
Newsgroups: news.software.nntp