amd64/92412: rcp.rstatd reports bogus packets/per/second info

hotlips Internet admin hostmaster at GTS.NET
Sun Jan 29 12:20:09 PST 2006


The following reply was made to PR amd64/92412; it has been noted by GNATS.

From: hotlips Internet admin <hostmaster at GTS.NET>
To: sean at mcneil.com (Sean McNeil)
Cc: bug-followup at FreeBSD.org, freebsd-amd64 at FreeBSD.org
Subject: Re: amd64/92412: rcp.rstatd reports bogus packets/per/second info
Date: Sun, 29 Jan 2006 15:19:04 -0500 (EST)

 Thus saith Sean McNeil:
 | On Sun, 2006-01-29 at 07:30 +0000, hotlips Internet admin wrote:
 | > The following reply was made to PR amd64/92412; it has been noted by GNATS.
 | > From: hotlips Internet admin <hostmaster at GTS.NET>
 | >  Thus saith Kris Kennaway:
 | >  | On Fri, Jan 27, 2006 at 11:59:15AM -0500, hotlips Internet admin wrote:
 | >  | 
 | >  | > | > >Description:
 | >  | > | > packets/second value reported by rpc.rstatd to remote monitor hovers around
 | >  | > | > 8000 or so with odd downward spikes approx every 90 seconds (it's not at
 | >  | > | all related to actual interface traffic)
 | >  | > | >
 | >  | > | > >How-To-Repeat:
 | >  | > | > keep displaying rpc.rstatd data from 6.0 system
 | >  | > |
 | >  | > | How are you using rpc.rstatd and rup?  I don't see a way to make rup
 | >  | > | display "packets/second", it only gives uptime and load average:
 | >  | > |
 | >  | > | # rup
 | >  | > | fbsd-amd64.isc.  10:02am  up   4 days,  14:00,  load average: 2.00 2.00 2.00
 | >  | >
 | >  | > 	Solaris perfmeter, actually.
 | >  | 
 | >  | Do you know how I can query this on FreeBSD?
 | > 
 | >  	oop, wrong (older) diff - use this one below...
 | 
 | The diff would be more readable if you only include useful changes and
 | eliminate difference caused solely from white space.  For instance, with
 | diff -ub.
 
 
 	sorry, I've been trained to use diff -c; "-ub" version
 	included velow.
 
 
 	This fix should work for all 6.x FreeBSD (and probably 5.x too) -
 	4.x & 3.x seem to have issues with opackets systcl mib (always
 	returns 0), so I made a version for them which uses the kmem
 	interface as well as the other fixes shown below....
 
 
 	BTW, the sysutils/xsysstats package works fine for X users...
 
 
 -- 
 Bruce Becker			+1 416 410 0879
 GTS Network Administration	Toronto, Ont.
 Email:	hostmaster at gts.net
 
  --------- 8< --------- 8< --------- 8< --------- 8< --------- 8< ---------
 
 --- rstat_proc.c.orig	Sun Jun  1 22:34:36 2003
 +++ rstat_proc.c	Sun Jan 29 02:17:10 2006
 @@ -138,6 +138,7 @@
      if (! stat_is_init)
          stat_init();
      sincelastreq = 0;
 +    stats_all.s2.if_opackets = stats_all.s3.if_opackets;
      return(&stats_all.s2);
  }
  
 @@ -147,6 +148,7 @@
      if (! stat_is_init)
          stat_init();
      sincelastreq = 0;
 +    stats_all.s1.if_opackets = stats_all.s3.if_opackets;
      return(&stats_all.s1);
  }
  
 @@ -219,13 +221,13 @@
  		exit(1);
  	}
  	for(i = 0; i < RSTAT_CPUSTATES ; i++)
 -		stats_all.s1.cp_time[i] = bsd_cp_time[cp_time_xlat[i]];
 +		stats_all.s3.cp_time[i] = bsd_cp_time[cp_time_xlat[i]];
  
          (void)getloadavg(avrun, sizeof(avrun) / sizeof(avrun[0]));
  
 -	stats_all.s2.avenrun[0] = avrun[0] * FSCALE;
 -	stats_all.s2.avenrun[1] = avrun[1] * FSCALE;
 -	stats_all.s2.avenrun[2] = avrun[2] * FSCALE;
 +	stats_all.s3.avenrun[0] = avrun[0] * FSCALE;
 +	stats_all.s3.avenrun[1] = avrun[1] * FSCALE;
 +	stats_all.s3.avenrun[2] = avrun[2] * FSCALE;
  
  	mib[0] = CTL_KERN;
  	mib[1] = KERN_BOOTTIME;
 @@ -234,14 +236,13 @@
  		syslog(LOG_ERR, "sysctl(kern.boottime): %m");
  		exit(1);
  	}
 -
 -	stats_all.s2.boottime.tv_sec = btm.tv_sec;
 -	stats_all.s2.boottime.tv_usec = btm.tv_usec;
 +	stats_all.s3.boottime.tv_sec = btm.tv_sec;
 +	stats_all.s3.boottime.tv_usec = btm.tv_usec;
  
  
  #ifdef DEBUG
 -	fprintf(stderr, "%d %d %d %d\n", stats_all.s1.cp_time[0],
 -	    stats_all.s1.cp_time[1], stats_all.s1.cp_time[2], stats_all.s1.cp_time[3]);
 +	fprintf(stderr, "%d %d %d %d\n", stats_all.s3.cp_time[0],
 +	    stats_all.s3.cp_time[1], stats_all.s3.cp_time[2], stats_all.s3.cp_time[3]);
  #endif
  
  	/* XXX - should use sysctl */
 @@ -249,18 +250,18 @@
  		syslog(LOG_ERR, "rstat: can't read cnt from kmem");
  		exit(1);
  	}
 -	stats_all.s1.v_pgpgin = cnt.v_vnodepgsin;
 -	stats_all.s1.v_pgpgout = cnt.v_vnodepgsout;
 -	stats_all.s1.v_pswpin = cnt.v_swappgsin;
 -	stats_all.s1.v_pswpout = cnt.v_swappgsout;
 -	stats_all.s1.v_intr = cnt.v_intr;
 +	stats_all.s3.v_pgpgin = cnt.v_vnodepgsin;
 +	stats_all.s3.v_pgpgout = cnt.v_vnodepgsout;
 +	stats_all.s3.v_pswpin = cnt.v_swappgsin;
 +	stats_all.s3.v_pswpout = cnt.v_swappgsout;
 +	stats_all.s3.v_intr = cnt.v_intr;
  	gettimeofday(&tm, (struct timezone *) 0);
 -	stats_all.s1.v_intr -= hz*(tm.tv_sec - btm.tv_sec) +
 +	stats_all.s3.v_intr -= hz*(tm.tv_sec - btm.tv_sec) +
  	    hz*(tm.tv_usec - btm.tv_usec)/1000000;
 -	stats_all.s2.v_swtch = cnt.v_swtch;
 +	stats_all.s3.v_swtch = cnt.v_swtch;
  
  	/* update disk transfers */
 -	updatexfers(RSTAT_DK_NDRIVE, stats_all.s1.dk_xfer);
 +	updatexfers(RSTAT_DK_NDRIVE, stats_all.s3.dk_xfer);
  
  	mib[0] = CTL_NET;
  	mib[1] = PF_LINK;
 @@ -272,12 +273,11 @@
  		syslog(LOG_ERR, "sysctl(net.link.generic.system.ifcount): %m");
  		exit(1);
  	}
 -
 -	stats_all.s1.if_ipackets = 0;
 -	stats_all.s1.if_opackets = 0;
 -	stats_all.s1.if_ierrors = 0;
 -	stats_all.s1.if_oerrors = 0;
 -	stats_all.s1.if_collisions = 0;
 +	stats_all.s3.if_ipackets = 0;
 +	stats_all.s3.if_opackets = 0;
 +	stats_all.s3.if_ierrors = 0;
 +	stats_all.s3.if_oerrors = 0;
 +	stats_all.s3.if_collisions = 0;
  	for (i = 1; i <= ifcount; i++) {
  		len = sizeof ifmd;
  		mib[3] = IFMIB_IFDATA;
 @@ -287,19 +287,19 @@
  			if (errno == ENOENT)
  				continue;
  
 -			syslog(LOG_ERR, "sysctl(net.link.ifdata.%d.general)"
 -			       ": %m", i);
 +			syslog(LOG_ERR, "sysctl(net.link.ifdata.%d.general): %m", i);
  			exit(1);
  		}
 -
 -		stats_all.s1.if_ipackets += ifmd.ifmd_data.ifi_ipackets;
 -		stats_all.s1.if_opackets += ifmd.ifmd_data.ifi_opackets;
 -		stats_all.s1.if_ierrors += ifmd.ifmd_data.ifi_ierrors;
 -		stats_all.s1.if_oerrors += ifmd.ifmd_data.ifi_oerrors;
 -		stats_all.s1.if_collisions += ifmd.ifmd_data.ifi_collisions;
 +		stats_all.s3.if_ipackets += ifmd.ifmd_data.ifi_ipackets;
 +		stats_all.s3.if_opackets += ifmd.ifmd_data.ifi_opackets;
 +		stats_all.s3.if_ierrors += ifmd.ifmd_data.ifi_ierrors;
 +		stats_all.s3.if_oerrors += ifmd.ifmd_data.ifi_oerrors;
 +		stats_all.s3.if_collisions += ifmd.ifmd_data.ifi_collisions;
  	}
 -	gettimeofday((struct timeval *)&stats_all.s3.curtime,
 -		(struct timezone *) 0);
 +
 +	gettimeofday(&tm, (struct timezone *) 0);
 +	stats_all.s3.curtime.tv_sec = tm.tv_sec;
 +	stats_all.s3.curtime.tv_usec = tm.tv_usec;
  	alarm(1);
  }
  
 @@ -307,12 +307,21 @@
  setup()
  {
  	char errbuf[_POSIX2_LINE_MAX];
 -
  	int en;
 +	static int is_kd_setup = 0;
  
 -	if ((kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf)) == NULL) {
 -		syslog(LOG_ERR, "rpc.rstatd, %s", errbuf);
 -		exit(1);
 +	/*  setup() is called after each dormant->active
 +	 *  transition.  Since we never close the kvm files
 +	 *  (there's no reason), make sure we don't open them
 +	 *  each time, as that can lead to exhaustion of all open
 +	 *  files!  */
 +	if (!is_kd_setup) {
 +		kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
 +		if (kd == NULL) {
 +			syslog(LOG_ERR, "%s", errbuf);
 +			exit (1);
 +		}
 +		is_kd_setup = 1;
  	}
  
  	if ((en = kvm_nlist(kd, nl)) != 0) {
 


More information about the freebsd-amd64 mailing list