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

Pino Toscano ptoscano at redhat.com
Mon Oct 6 15:27:19 UTC 2014


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;
 
-- 
1.9.3




More information about the Libguestfs mailing list