[PATCH] add nmeter applet

Rob Landley rob at landley.net
Fri Feb 10 18:10:52 UTC 2006


On Friday 10 February 2006 04:48, Denis Vlasenko wrote:
> Hello busyboxers,
>
> I am submitting a new applet for the review.
>
> # size busybox.orig busybox.nmeter
>    text    data     bss     dec     hex filename
>  973258   12184  198804 1184246  1211f6 busybox.orig
>  979530   12408  202964 1194902  123b96 busybox.nmeter

Having to do math to parse this is kinda distracting.  Could you give us 
either the size of "allnoconfig" plus this app, or the size of the .o file?

> # ./busybox.nmeter nmeter --help
> BusyBox v1.1.1-pre0 (2006.02.10-09:12+0000) multi-call binary
>
> Usage: nmeter c[N] nIFACE m[f/t] s f i[NN] x p[f/n] b t[N] d[N] h[N] lLABEL
> LLABEL r

Um, ick.

> Nmeter allows you to monitor your system in real time

So does top.

> Options:
> c[N]    monitor CPU. N - bar size, default 10
>         (legend: S:system U:user N:niced D:iowait I:irq i:softirq)
> nIFACE  monitor network interface IFACE
> m[f/t]  monitor allocated/free/total memory
> s       monitor allocated swap
> f       monitor number of used filedescriptors
> i[NN]   monitor total/specific IRQ rate
> x       monitor context switch rate
> p[f/n]  monitor forks/# of processes
> b       monitor block io
> t[N]    show time (with N decimal points)
> d[N]    milliseconds between updates. Default 1000
> h[N]    print headers above numbers (each N lines, default once)

That's kinda silly.

> lLABEL  specify label for previous item
> LLABEL  same, but label will be printed without surrounding blanks
> r       print <cr> instead of <lf> at EOL

That's extremely silly.  You might want to look at the man page for strptime.

> # ./busybox.nmeter nmeter
> 12:46:13 cpu [U.........] mem 153M swp  24M proc  183 fork   1 bio    0   
> 0 12:46:14 cpu [..........] mem 153M swp  24M proc  183 fork   0 bio    0  
>  0 12:46:15 cpu [..........] mem 153M swp  24M proc  183 fork   0 bio    0
> 148k 12:46:16 cpu [..........] mem 153M swp  24M proc  183 fork   0 bio   
> 0    0 12:46:17 cpu [..........] mem 153M swp  24M proc  183 fork   1 bio  
>  0    0 12:46:18 cpu [..........] mem 153M swp  24M proc  183 fork   0 bio 
>   0    0 ...

That's an abbreviated top, yet this shares no code with our current top 
implementation.

More to the point, from a command line perspective this should just be some 
kind of "terse" option to top.

> Please comment.

Neat idea, but this implementation should not be merged.

Random example: read_decimal sample() is a one line function that's used in 
exactly one place.  Why the heck is it a function at all?  That function is a 
call to STR2SAMPLE() which is literally just a #define for strtoull...  
That's just wrong, if you want strtoull() then just use strotoull().  The 
fact there's another #define for STR2SAMPLE() commented out a couple lines 
above the active #define is just extra untidyness: why is there commented out 
code still in the patch?)

I get the feeling that a cleaning pass could chop this implementation down to 
about half its current size, but that doing so would be the wrong approach 
because we've already got a "top" and I really don't want two parallel 
implementations of the same functionality that don't share any code.

This isn't to say that our current top is the best possible implementation, 
but I'd start by cleaning up the current top and adding one-line output 
functionality to that instead.  If said cleanup winds up replacing the 
current top code, fine, as long as the end result can do what the current top 
does.

> --
> vda

Rob
-- 
Steve Ballmer: Innovation!  Inigo Montoya: You keep using that word.
I do not think it means what you think it means.



More information about the busybox mailing list