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

hotlips Internet admin hostmaster at GTS.NET
Sat Jan 28 23:30:07 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: kris at obsecurity.org (Kris Kennaway)
Cc: bug-followup at FreeBSD.org
Subject: Re: amd64/92412: rcp.rstatd reports bogus packets/per/second info
Date: Sun, 29 Jan 2006 02:25:33 -0500 (EST)

 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...
 
 -- 
 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
 ***************
 *** 136,143 ****
   rstatproc_stats_2_svc(void *argp, struct svc_req *rqstp)
   {
       if (! stat_is_init)
 !         stat_init();
       sincelastreq = 0;
       return(&stats_all.s2);
   }
   
 --- 136,144 ----
   rstatproc_stats_2_svc(void *argp, struct svc_req *rqstp)
   {
       if (! stat_is_init)
 ! 	stat_init();
       sincelastreq = 0;
 +     stats_all.s2.if_opackets = stats_all.s3.if_opackets;
       return(&stats_all.s2);
   }
   
 ***************
 *** 145,152 ****
   rstatproc_stats_1_svc(void *argp, struct svc_req *rqstp)
   {
       if (! stat_is_init)
 !         stat_init();
       sincelastreq = 0;
       return(&stats_all.s1);
   }
   
 --- 146,154 ----
   rstatproc_stats_1_svc(void *argp, struct svc_req *rqstp)
   {
       if (! stat_is_init)
 ! 	stat_init();
       sincelastreq = 0;
 +     stats_all.s1.if_opackets = stats_all.s3.if_opackets;
       return(&stats_all.s1);
   }
   
 ***************
 *** 219,231 ****
   		exit(1);
   	}
   	for(i = 0; i < RSTAT_CPUSTATES ; i++)
 ! 		stats_all.s1.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;
   
   	mib[0] = CTL_KERN;
   	mib[1] = KERN_BOOTTIME;
 --- 221,233 ----
   		exit(1);
   	}
   	for(i = 0; i < RSTAT_CPUSTATES ; i++)
 ! 		stats_all.s3.cp_time[i] = bsd_cp_time[cp_time_xlat[i]];
   
 ! 	(void)getloadavg(avrun, sizeof(avrun) / sizeof(avrun[0]));
   
 ! 	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,247 ****
   		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;
   
   
   #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]);
   #endif
   
   	/* XXX - should use sysctl */
 --- 236,248 ----
   		syslog(LOG_ERR, "sysctl(kern.boottime): %m");
   		exit(1);
   	}
 ! 	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.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,266 ****
   		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;
   	gettimeofday(&tm, (struct timezone *) 0);
 ! 	stats_all.s1.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;
   
   	/* update disk transfers */
 ! 	updatexfers(RSTAT_DK_NDRIVE, stats_all.s1.dk_xfer);
   
   	mib[0] = CTL_NET;
   	mib[1] = PF_LINK;
 --- 250,267 ----
   		syslog(LOG_ERR, "rstat: can't read cnt from kmem");
   		exit(1);
   	}
 ! 	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.s3.v_intr -= hz*(tm.tv_sec - btm.tv_sec) +
   	    hz*(tm.tv_usec - btm.tv_usec)/1000000;
 ! 	stats_all.s3.v_swtch = cnt.v_swtch;
   
   	/* update disk transfers */
 ! 	updatexfers(RSTAT_DK_NDRIVE, stats_all.s3.dk_xfer);
   
   	mib[0] = CTL_NET;
   	mib[1] = PF_LINK;
 ***************
 *** 272,283 ****
   		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;
   	for (i = 1; i <= ifcount; i++) {
   		len = sizeof ifmd;
   		mib[3] = IFMIB_IFDATA;
 --- 273,283 ----
   		syslog(LOG_ERR, "sysctl(net.link.generic.system.ifcount): %m");
   		exit(1);
   	}
 ! 	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,305 ****
   			if (errno == ENOENT)
   				continue;
   
 ! 			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;
   	}
 ! 	gettimeofday((struct timeval *)&stats_all.s3.curtime,
 ! 		(struct timezone *) 0);
   	alarm(1);
   }
   
 --- 287,305 ----
   			if (errno == ENOENT)
   				continue;
   
 ! 			syslog(LOG_ERR, "sysctl(net.link.ifdata.%d.general): %m", i);
   			exit(1);
   		}
 ! 		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(&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,324 ****
   setup()
   {
   	char errbuf[_POSIX2_LINE_MAX];
 - 
   	int en;
   
 ! 	if ((kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf)) == NULL) {
 ! 		syslog(LOG_ERR, "rpc.rstatd, %s", errbuf);
 ! 		exit(1);
   	}
   
   	if ((en = kvm_nlist(kd, nl)) != 0) {
   		syslog(LOG_ERR, "rstatd: Can't get namelist. %d", en);
   		exit (1);
 !         }
   }
   
   /*
 --- 307,333 ----
   setup()
   {
   	char errbuf[_POSIX2_LINE_MAX];
   	int en;
 + 	static int is_kd_setup = 0;
   
 ! 	/*  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) {
   		syslog(LOG_ERR, "rstatd: Can't get namelist. %d", en);
   		exit (1);
 ! 	}
   }
   
   /*
 


More information about the freebsd-amd64 mailing list