[Toybox] New toy: vmstat

Rob Landley rob at landley.net
Tue Apr 10 19:13:43 PDT 2012


On 04/09/2012 11:59 AM, Georgi Chorbadzhiyski wrote:
> On 4/9/12 2:39 PM, Elie De Brauwer wrote:
>> In attachment you can find a no-nonsense vmstat implementation.
>> Meaning most of the special things (which I personally never bothered
>> to use) are dropped. (vmstat -d however is still under consideration,
>> please shout if you're waiting for a vmstat -d or any other options).
>> +        if(first_run || (!(loop_num % 22)&&  !no_header)) {
> 
> That 22 - 3 is terminal lines, right? You should probably use
> terminal_size()
> function from lib.c and adjust the check on each loop.


I note that something I implemented for BusyBox way back when is ascii
probing for terminal size.  If all else fails and you can't figure out
how big your screen is (which happens on serial consoles, for example),
it sends an ansi probe sequence that the tty responds to with a reply
sequence.

Blog entry about it here:

http://landley.net/notes-2011.html#15-11-2011

Which refers to an earlier blog entry from 2007 (which is about when I
submitted the code to busybox, I think).

It's relevant here  because querying terminal size every line probably
wouldn't be a good idea if it goes through the ascii probe again, for
reasons explained in the blog entry. You want to call the function once
and remember the value.

Rob
-- 
GNU/Linux isn't: Linux=GPLv2, GNU=GPLv3+, they can't share code.
Either it's "mere aggregation", or a license violation.  Pick one.



More information about the Toybox mailing list