[PATCH] add nmeter applet

Rob Landley rob at landley.net
Tue Feb 14 13:22:35 UTC 2006


On Tuesday 14 February 2006 3:51 am, Denis Vlasenko wrote:
> On Tuesday 14 February 2006 04:44, Rob Landley wrote:
> > On Tuesday 14 February 2006 2:29 am, Denis Vlasenko wrote:
> > > > Ok, looking slightly more closely at it, you have a point.  I was
> > > > misled by the "based on nanotop.c" comment, and thought it was
> > > > collecting what I always consider the most useful statistic:
> > > > percentage CPU usage in user, system, iowait, and idle (which
> > > > requires iterating through processes because loadavg just doesn't cut
> > > > it).
> > >
> > > Not true. nmeter's collect_cpu() uses this /proc file in order to get
> > > nice CPU usage bar:
> > >
> > > # cat /proc/stat
> > > cpu  16091 0 5029 119503 15712 395 399 0
> > > cpu0 16091 0 5029 119503 15712 395 399 0
> > > ...  ^^^^^ ^ ^^^^
> > >      usr nice sys idle iowait irq softirq steal
> > >
> > > (dunno what is "steal", I just looked into
> > > linux-2.6.15.1.org/fs/proc/proc_misc.c)
> >
> > Yup.  (Reading up on it.  Never implemented a top variant myself before.)
> >
> > That's in jiffies.  You have to figure out how many jiffies per second
> > there are (top.c has the world's ugliest hack for this), and snapshot
> > previous values in order to turn that into percentage usage over any
> > given time period.  But it seems pretty straightforward, and the jiffy
> > determination wouldn't be so bad if it was in libbb...
>
> Why do you want to convert it to seconds? nmeter code goes straight to
> percents... --
> vda

Mostly because the existing top code went to such great lengths to figure out 
how many jiffies had passed, but now that I look closer you _do_ have idle 
ticks so you can add up the four to get total ticks.

Apparently, the hoops it was jumping through haven't been necessary since at 
least the 2.2 kernel.  (I love having a Red Hat 7.3 test system...)

Rob
-- 
Never bet against the cheap plastic solution.



More information about the busybox mailing list