some fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




  This patch to NNTPCache 2.3.2.1 fixes some minor problems:

- Statistics:  Several values are always zero, leading to a bogus
efficiency rating, and then nntpcache seg faults.  This patch fixes the
remote server stats (connects, failed connects, read from, written to),
and disables the LIST: and ARTICLE: sections (mostly all zero or null
so are not too useful right now).  So the efficieny rating now works, and
nntpcache doesn't segfault anymore.  You will need to kill nntpcache,
remove the nntpcache.statistics file and restart nntpcache to get a fair
efficiency rating though.

- Doubled up X-Cache headers:  You will get two X-Cache headers on
articles posted via nntpcache, and then read via nntpcache.  This patch
disables adding X-Cache headers to posted articles.  Just say no to "X-"
headers.


  I want to fix the other statistics and look at another stats patch that
posted previously by Hugo Embrechts that had some format string changes
that are apparently required on some platforms (just Linux?).  I might
also put a patched nntpcache up for FTP.

  I've tested these changes throughly on a FreeBSD 2.2.6 system.  I will
probably test the stats changes on a Redhat Linux system later.  If they
crash your system, it isn't my fault, but let me know, and I might be able
to stop it.

Tom
Systems Support
SDF


*** src/post.c.orig	Wed Jul 22 19:32:59 1998
--- src/post.c	Wed Jul 22 19:33:21 1998
***************
*** 216,222 ****
  				if (addmsgid)
  					Cfemitf (cf, "Message-ID: %s\r\n", messageid);
  				Cfemitf (cf, "Cache-Post-Path: %s!%s\r\n", Host, ClientHost);
- 				Cfemitf (cf, "X-Cache: nntpcache " VERSION " (see http://www.nntpcache.org/)\r\n");
  			}
  			Cfemit (cf, art->data);
  		}
--- 216,221 ----
*** src/sockets.c.orig	Wed Jul 22 19:31:30 1998
--- src/sockets.c	Wed Jul 22 23:05:23 1998
***************
*** 161,166 ****
--- 161,168 ----
  		scfg->fd = -1;
  		server_down(scfg);
  		scfg->share->connect_fail++;
+ 		if (con->statistics)
+ 			Stats->server_connects_failed++;
  		return NULL;
  	}
  	scfg->fh = fdopen (scfg->fd, "r+");
***************
*** 214,219 ****
--- 216,223 ----
  	}
  	server_up(scfg);
  	scfg->share->connect_good++;
+ 	if (con->statistics)
+ 		Stats->server_connects++;
  	return scfg;
  }
  
***************
*** 247,252 ****
--- 251,258 ----
  	buf[cc] = '\0';
  	server_up (scfg);
  	scfg->share->bytes_from += cc;
+ 	if (con->statistics)
+ 		Stats->server_read_bytes += cc;
  	return cc;
  }
  
***************
*** 583,588 ****
--- 589,596 ----
  	i=vfprintf(scfg->fh, fmt, ap);
  	va_end(ap);
  	scfg->share->bytes_to+=i;
+ 	if (con->statistics)
+ 		Stats->server_write_bytes += i;
  	return i;
  }
  
***************
*** 603,608 ****
--- 611,618 ----
  	i=vfprintf(scfg->fh, fmt, ap);
  	va_end(ap);
  	scfg->share->bytes_to+=i;
+ 	if (con->statistics)
+ 		Stats->server_write_bytes += i;
  	return i;
  }
  
***************
*** 630,635 ****
--- 640,647 ----
  	logToServer (cf->host, s);
  	i = strlen(s);
  	cf->share->bytes_to += i;
+ 	if (con->statistics)
+ 		Stats->server_write_bytes += i;
  	return fwrite(s, 1, i, cf->fh);
  }
  
*** src/stats.c.orig	Wed Jul 22 19:43:17 1998
--- src/stats.c	Wed Jul 22 19:44:16 1998
***************
*** 127,161 ****
  	emitf("\tPosts (bytes):                          %24s\r\n", c(s->posts_bytes));
  	emitf("\tIncoming crossposts:                    %24s\r\n", b(s->crossposts));
  	emitf("\tIncoming crossposts (bytes):            %24s\r\n", c(s->crossposts_bytes));
  emitf("\
  \r\n\
  LISTS:\r\n\
  \r\n\
  List-name---- --out-of-cache -----into-cache hits --xfer-per-hour lines -length\r\n");
  emitf("\
! active       %7d %7s %7d %7s %3.0f%% %7.2f %7s %5d %7s\r\n", s->list_active_cache, c(s->list_active_cache_bytes), s->list_active_cached, c(s->list_active_cached_bytes),  100.0*(s->list_active_cache_bytes+1)/(float)(s->list_active_cache_bytes+s->list_act
ive_cached_bytes+1), (s->list_active_cache+s->list_active_cached)/(dif/3600.0), c(((s->list_active_cache_bytes+s->list_active_cached_bytes)*3600.0)/dif), s->active_entries, c(s->active_len));
  emitf("\
! active.times %7d %7s %7d %7s %3.0f%% %7.2f %7s %5d %7s\r\n", s->list_active_times_cache, c(s->list_active_times_cache_bytes), s->list_active_times_cached, c(s->list_active_times_cached_bytes),  100*(s->list_active_times_cache_bytes+1)/(float)(s->list_ac
tive_times_cache_bytes+s->list_active_times_cached_bytes+1), (s->list_active_times_cache+s->list_active_times_cached)/(dif/3600.0), c((s->list_active_times_cache_bytes+s->list_active_times_cached_bytes)/(dif/3600.0)), s->active_times_entries, c(s->active_
times_len));
! emitf("\
! newsgroups   %7d %7s %7d %7s %3.0f%% %7.2f %7s %5d %7s\r\n", s->list_newsgroups_cache, c(s->list_newsgroups_cache_bytes), s->list_newsgroups_cached, c(s->list_newsgroups_cached_bytes),  100.0*(s->list_newsgroups_cache_bytes+1)/(float)(s->list_newsgroups
_cache_bytes+s->list_newsgroups_cached_bytes+1), (s->list_newsgroups_cache+s->list_newsgroups_cached)/(dif/3600.0), c((s->list_newsgroups_cache_bytes+s->list_newsgroups_cached_bytes)/(dif/3600.0)), s->newsgroups_entries, c(s->newsgroups_len));
! emitf("\
! overview_fmt %7d %7s %7d %7s %3.0f%% %7.2f %7s %5d %7s\r\n", s->list_overview_fmt_cache, c(s->list_overview_fmt_cache_bytes), s->list_overview_fmt_cached, c(s->list_overview_fmt_cached_bytes),  100.0*(s->list_overview_fmt_cache_bytes+1)/(float)(s->list_
overview_fmt_cache_bytes+s->list_overview_fmt_cached_bytes+1), (s->list_overview_fmt_cache+s->list_overview_fmt_cached)/(dif/3600.0), c((s->list_overview_fmt_cache_bytes+s->list_overview_fmt_cached_bytes)/(dif/3600.0)), s->overview_fmt_entries, c(s->overv
iew_fmt_len));
  emitf("\r\n\
  MESSAGES:\r\n\
  \r\n\
  Data-type---- --out-of-cache -----into-cache hits ----------proxy xfer-per-hour\r\n");
  emitf("\
! article      %7d %7s %7d %7s %3.0f%% %7d %7s %5.0f %7s\r\n", s->article_cache, c(s->article_cache_bytes), s->article_cached, c(s->article_cached_bytes),  100.0*(s->article_cache_bytes+1)/(float)(s->article_cache_bytes+s->article_cached_bytes+1), s->arti
cle_proxy, c(s->article_proxy_bytes), (s->article_cache+s->article_cached)/(dif/3600.0), c(((s->article_cache_bytes+s->article_cached_bytes)*3600.0)/dif));
  emitf("\
! head         %7d %7s %7d %7s %3.0f%% %7d %7s %5.0f %7s\r\n", s->head_cache, c(s->head_cache_bytes), s->head_cached, c(s->head_cached_bytes),  100.0*(s->head_cache_bytes+1)/(float)(s->head_cache_bytes+s->head_cached_bytes+1), s->head_proxy, c(s->head_pro
xy_bytes), ((s->head_cache+s->head_cached)*3600.0)/dif, c(((s->head_cache_bytes+s->head_cached_bytes)*3600.0)/dif));
  emitf("\
! body         %7d %7s %7d %7s %3.0f%% %7d %7s %5.0f %7s\r\n", s->body_cache, c(s->body_cache_bytes), s->body_cached, c(s->body_cached_bytes),  100.0*(s->body_cache_bytes+1)/(float)(s->body_cache_bytes+s->body_cached_bytes+1), s->body_proxy, c(s->body_pro
xy_bytes), ((s->body_cache+s->body_cached)*3600.0)/dif, c(((s->body_cache_bytes+s->body_cached_bytes)*3600)/dif));
  emitf("\
! xover        %7d %7s %7d %7s %3.0f%% %7d %7s %5.0f %7s\r\n", s->xover_cache, c(s->xover_cache_bytes), s->xover_cached, c(s->xover_cached_bytes),  100.0*(s->xover_cache_bytes+1)/(float)(s->xover_cache_bytes+s->xover_cached_bytes+1), s->xover_proxy, c(s->
xover_proxy_bytes), ((s->xover_cache+s->xover_cached+s->xover_proxy)*3600.0)/dif, c(((s->xover_cache_bytes+s->xover_cached_bytes+s->xover_proxy_bytes)*3600.0)/dif));
  emitf("\
! xhdr         %7d %7s %7d %7s %3.0f%% %7d %7s %5.0f %7s\r\n", s->xhdr_cache, c(s->xhdr_cache_bytes), s->xhdr_cached, c(s->xhdr_cached_bytes),  100.0*(s->xhdr_cache_bytes+1)/(float)(s->xhdr_cache_bytes+s->xhdr_cached_bytes+1), s->xhdr_proxy, c(s->xhdr_pro
xy_bytes), ((s->xhdr_cache+s->xhdr_cached+s->xhdr_proxy)*3600.0)/dif, c(((s->xhdr_cache_bytes+s->xhdr_cached_bytes+s->xhdr_proxy_bytes)*3600.0)/dif));
  emitf("\
! msgid        %7d %7s %7d %7s %3.0f%%                 %5.0f %7s\r\n", s->msgid_cache, c(s->msgid_cache_bytes), s->msgid_cached, c(s->msgid_cached_bytes),  100.0*(s->msgid_cache_bytes+1)/(float)(s->msgid_cache_bytes+s->msgid_cached_bytes+1), ((s->msgid_ca
che+s->msgid_cached)*3600.0)/dif, c(((s->msgid_cache_bytes+s->msgid_cached_bytes)*3600.0)/dif));
  	convFree();
  	return;
  }
--- 127,175 ----
  	emitf("\tPosts (bytes):                          %24s\r\n", c(s->posts_bytes));
  	emitf("\tIncoming crossposts:                    %24s\r\n", b(s->crossposts));
  	emitf("\tIncoming crossposts (bytes):            %24s\r\n", c(s->crossposts_bytes));
+ #ifdef 0
  emitf("\
  \r\n\
  LISTS:\r\n\
  \r\n\
  List-name---- --out-of-cache -----into-cache hits --xfer-per-hour lines -length\r\n");
  emitf("\
! active       %7d %7s %7d %7s %3.0f%% %7.2f %7s %5d %7s\r\n", s->list_active_cache, c(s->list_active_cache_bytes), s->list_active_cached, c(s->list_active_cached_bytes),  100.0*(s->list_active_cache_bytes+1)/(float)(s->list_active_cache_bytes+s->list_act
iv
! e_cached_bytes+1), (s->list_active_cache+s->list_active_cached)/(dif/3600.0), c(((s->list_active_cache_bytes+s->list_active_cached_bytes)*3600.0)/dif), s->active_entries, c(s->active_len));
  emitf("\
! active.times %7d %7s %7d %7s %3.0f%% %7.2f %7s %5d %7s\r\n", s->list_active_times_cache, c(s->list_active_times_cache_bytes), s->list_active_times_cached, c(s->list_active_times_cached_bytes),  100*(s->list_active_times_cache_bytes+1)/(float)(s->list_ac
ti
! ve_times_cache_bytes+s->list_active_times_cached_bytes+1), (s->list_active_times_cache+s->list_active_times_cached)/(dif/3600.0), c((s->list_active_times_cache_bytes+s->list_active_times_cached_bytes)/(dif/3600.0)), s->active_times_entries, c(s->active_
ti
! mes_len));
! emitf("\
! newsgroups   %7d %7s %7d %7s %3.0f%% %7.2f %7s %5d %7s\r\n", s->list_newsgroups_cache, c(s->list_newsgroups_cache_bytes), s->list_newsgroups_cached, c(s->list_newsgroups_cached_bytes),  100.0*(s->list_newsgroups_cache_bytes+1)/(float)(s->list_newsgroups
_c
! ache_bytes+s->list_newsgroups_cached_bytes+1), (s->list_newsgroups_cache+s->list_newsgroups_cached)/(dif/3600.0), c((s->list_newsgroups_cache_bytes+s->list_newsgroups_cached_bytes)/(dif/3600.0)), s->newsgroups_entries, c(s->newsgroups_len));
! emitf("\
! overview_fmt %7d %7s %7d %7s %3.0f%% %7.2f %7s %5d %7s\r\n", s->list_overview_fmt_cache, c(s->list_overview_fmt_cache_bytes), s->list_overview_fmt_cached, c(s->list_overview_fmt_cached_bytes),  100.0*(s->list_overview_fmt_cache_bytes+1)/(float)(s->list_
ov
! erview_fmt_cache_bytes+s->list_overview_fmt_cached_bytes+1), (s->list_overview_fmt_cache+s->list_overview_fmt_cached)/(dif/3600.0), c((s->list_overview_fmt_cache_bytes+s->list_overview_fmt_cached_bytes)/(dif/3600.0)), s->overview_fmt_entries, c(s->overv
ie
! w_fmt_len));
  emitf("\r\n\
  MESSAGES:\r\n\
  \r\n\
  Data-type---- --out-of-cache -----into-cache hits ----------proxy xfer-per-hour\r\n");
  emitf("\
! article      %7d %7s %7d %7s %3.0f%% %7d %7s %5.0f %7s\r\n", s->article_cache, c(s->article_cache_bytes), s->article_cached, c(s->article_cached_bytes),  100.0*(s->article_cache_bytes+1)/(float)(s->article_cache_bytes+s->article_cached_bytes+1), s->arti
cl
! e_proxy, c(s->article_proxy_bytes), (s->article_cache+s->article_cached)/(dif/3600.0), c(((s->article_cache_bytes+s->article_cached_bytes)*3600.0)/dif));
  emitf("\
! head         %7d %7s %7d %7s %3.0f%% %7d %7s %5.0f %7s\r\n", s->head_cache, c(s->head_cache_bytes), s->head_cached, c(s->head_cached_bytes),  100.0*(s->head_cache_bytes+1)/(float)(s->head_cache_bytes+s->head_cached_bytes+1), s->head_proxy, c(s->head_pro
xy
! _bytes), ((s->head_cache+s->head_cached)*3600.0)/dif, c(((s->head_cache_bytes+s->head_cached_bytes)*3600.0)/dif));
  emitf("\
! body         %7d %7s %7d %7s %3.0f%% %7d %7s %5.0f %7s\r\n", s->body_cache, c(s->body_cache_bytes), s->body_cached, c(s->body_cached_bytes),  100.0*(s->body_cache_bytes+1)/(float)(s->body_cache_bytes+s->body_cached_bytes+1), s->body_proxy, c(s->body_pro
xy
! _bytes), ((s->body_cache+s->body_cached)*3600.0)/dif, c(((s->body_cache_bytes+s->body_cached_bytes)*3600)/dif));
  emitf("\
! xover        %7d %7s %7d %7s %3.0f%% %7d %7s %5.0f %7s\r\n", s->xover_cache, c(s->xover_cache_bytes), s->xover_cached, c(s->xover_cached_bytes),  100.0*(s->xover_cache_bytes+1)/(float)(s->xover_cache_bytes+s->xover_cached_bytes+1), s->xover_proxy, c(s->
xo
! ver_proxy_bytes), ((s->xover_cache+s->xover_cached+s->xover_proxy)*3600.0)/dif, c(((s->xover_cache_bytes+s->xover_cached_bytes+s->xover_proxy_bytes)*3600.0)/dif));
  emitf("\
! xhdr         %7d %7s %7d %7s %3.0f%% %7d %7s %5.0f %7s\r\n", s->xhdr_cache, c(s->xhdr_cache_bytes), s->xhdr_cached, c(s->xhdr_cached_bytes),  100.0*(s->xhdr_cache_bytes+1)/(float)(s->xhdr_cache_bytes+s->xhdr_cached_bytes+1), s->xhdr_proxy, c(s->xhdr_pro
xy
! _bytes), ((s->xhdr_cache+s->xhdr_cached+s->xhdr_proxy)*3600.0)/dif, c(((s->xhdr_cache_bytes+s->xhdr_cached_bytes+s->xhdr_proxy_bytes)*3600.0)/dif));
  emitf("\
! msgid        %7d %7s %7d %7s %3.0f%%                 %5.0f %7s\r\n", s->msgid_cache, c(s->msgid_cache_bytes), s->msgid_cached, c(s->msgid_cached_bytes),  100.0*(s->msgid_cache_bytes+1)/(float)(s->msgid_cache_bytes+s->msgid_cached_bytes+1), ((s->msgid_ca
ch
! e+s->msgid_cached)*3600.0)/dif, c(((s->msgid_cache_bytes+s->msgid_cached_bytes)*3600.0)/dif));
! #endif
  	convFree();
  	return;
  }


[Index of Archives]     [Yosemite]     [Yosemite Campsites]     [Bugtraq]     [Linux]     [Trn]

Powered by Linux