[Libguestfs] [PATCH] tools: fix free -m invocation

Richard W.M. Jones rjones at redhat.com
Mon Oct 6 18:48:34 UTC 2014


On Mon, Oct 06, 2014 at 05:27:19PM +0200, Pino Toscano wrote:
> Since procps 3.3.10, free does not output the "-/+ buffers/cache" line
> anymore. On the other hand, the data from it can be calculated from the
> memory values, so just do the calculation manually (with awk).
> ---
>  df/estimate-max-threads.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/df/estimate-max-threads.c b/df/estimate-max-threads.c
> index bbcdd73..7d5b090 100644
> --- a/df/estimate-max-threads.c
> +++ b/df/estimate-max-threads.c
> @@ -44,7 +44,7 @@ estimate_max_threads (void)
>  
>    /* Choose the number of threads based on the amount of free memory. */
>    mbytes_str = read_line_from ("LANG=C free -m | "
> -                               "grep 'buffers/cache' | awk '{print $NF}'");
> +                               "grep '^Mem' | awk '{print $4+$6+$7}'");
>    if (mbytes_str == NULL)
>      return 1;

Ugh.  WTF changing the output of *free* ...?

ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list