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
Richard W.M. Jones
2014-Oct-06 18:48 UTC
Re: [Libguestfs] [PATCH] tools: fix free -m invocation
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
Maybe Matching Threads
- [PATCH] When calling getline first time, initialize length to zero.
- Problem with Win 7 and Samba 3.3.10 PDC (Trust Relationship Between Workstation and Domain Failed)
- CEBA-2016:0180 CentOS 7 procps-ng BugFix Update
- CESA-2018:1700 Important CentOS 7 procps-ng Security Update
- CEBA-2019:3068 CentOS 7 procps-ng BugFix Update