lnstat (rtstat replacement)

2 messages, 2 authors, 2004-10-03 · open the first message on its own page

lnstat (rtstat replacement)

From: Harald Welte <laforge@gnumonks.org>
Date: 2004-10-02 16:21:20

Hi!

I've finished my work on 'lnstat'.  The current development version is
available from
	http://svn.gnumonks.org/cgi-bin/viewcvs.cgi/trunk/lnstat/
where you can select the 'download tarball' option.

I've added and tested support for old kernels, where it tries to fall
back to rtstat compatibility mode via /proc/net/rt_cache_stat.

README attached to this email.

Robert: I hope you're fine with the new lnstat tool replacing rtstat.

Stephen:  Feel free to grab the current version and add it to the next
iproute2 release.  Please send any changes you integrate back upstream
to me, so I can merge them into my repository.

Dave:  I've also attached a small patch for Documentation/networking.
Please add this to the same patchset that includes /proc/net/stat
support.

Everyone:  If you have suggestions/comments/feature requests, feel free
to tell me. 

Thanks!

-- 
- Harald Welte [off-list ref]               http://www.gnumonks.org/
============================================================================
Programming is like sex: One mistake and you have to support it your lifetime

lnstat (rtstat replacement)

From: Robert Olsson <hidden>
Date: 2004-10-03 21:07:00

Harald Welte writes:

 > I've finished my work on 'lnstat'.  The current development version is
 > available from
 > 	http://svn.gnumonks.org/cgi-bin/viewcvs.cgi/trunk/lnstat/

 I will get a useful tool...

 > Robert: I hope you're fine with the new lnstat tool replacing rtstat.


 I just tried "compatibility mode". Something like patch below makes it closer 
 to old rtstat. Did the last two fields get switched?

 Cheers.
							--ro


--- lnstat.c.orig	2004-10-03 21:01:50.518607296 +0200
+++ lnstat.c	2004-10-03 22:38:25.846513976 +0200
@@ -54,7 +54,7 @@
 		gettimeofday(&lf->last_read, NULL);
 
 		for (j = 0; j < lf->num_fields; j++)
-			lf->fields[j].values[i] += strtoul(ptr, &ptr, 16);
+			lf->fields[j].values[i] = strtoul(ptr, &ptr, 16);
 	}
 	return num_lines;
 }
@@ -79,6 +79,7 @@
 	struct lnstat_file *lf;
 	char buf[FGETS_BUF_SIZE];
 	struct timeval tv;
+	time_t told;
 
 	gettimeofday(&tv, NULL);
 
@@ -92,15 +93,22 @@
 				/* skip first line */
 				fgets(buf, sizeof(buf)-1, lf->fp);
 			}
+			told = lf->last_read.tv_sec;
 			scan_lines(lf, 1);
 
 			for (i = 0, lfi = &lf->fields[i]; 
 			     i < lf->num_fields; i++, lfi = &lf->fields[i]) {
 				if (i == 0)
 					lfi->result = lfi->values[1];
-				else
+				else {
+
 					lfi->result = (lfi->values[1]-lfi->values[0])
-				    			/ lf->interval.tv_sec;
+
+					  / ( lf->last_read.tv_sec -told);
+					
+					/* Save current to next diff */
+					lfi->values[0] = lfi->values[1];
+				}
 			}
 
 			rewind(lf->fp);
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help