pmp-check-unix-memory results to empty memory

Bug #1485919 reported by Paul Namuag
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona Monitoring Plugins
Fix Released
High
Unassigned

Bug Description

In version procps-ng 3.3.10, the format has been changed and has removed the "+ buffers/cache" section which is considered wrong to base free memory calculation which includes non-freeable page cache. See https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773.

Using the command below:

[root@localhost plugins]# /usr/lib64/nagios/plugins/pmp-check-unix-memory -w 96 -c 98
OK Memory % used | memory_used=0;96;98;0;100

This is because the format has been changed from 3.3.10 which shows an example below:

              total used free shared buff/cache available
Mem: 144887 6892 137542 8 453 137656
Swap: 4095 0 4095

having the "available" column as explained below:

available
              Estimation of how much memory is available for starting new applications, without swapping. Unlike the data provided by the cache or free fields, this field takes into account page cache and also that not all reclaimable me

So I added this workaround:

 95 get_used_memory_linux() {
 96 if [[ $( free -V|awk -F '.' '{print $NF}') -lt 10 ]]; then
 97 awk '/Mem:/ {total = $2;}
 98 /cache:/ {printf "%d\n", $3 / total * 100}' "$1"
 99 else
100 # Better to use memavailable. See
101 # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=34e431b0ae398fc54ea69ff85ec700722c9da773
102 awk '/Mem:/{total=$2; printf "%d\n", $7 / total * 100}' "$1"
103 fi
104

[root@qddbs86 plugins]# /usr/lib64/nagios/plugins/pmp-check-unix-memory -w 96 -c 98
OK Memory 74% used | memory_used=74;96;98;0;100

Revision history for this message
Roman Vynar (roman-vynar) wrote :

Thanks Paul, I will check this out.

Changed in percona-monitoring-plugins:
importance: Undecided → High
status: New → In Progress
Revision history for this message
Roman Vynar (roman-vynar) wrote :
Changed in percona-monitoring-plugins:
status: In Progress → Fix Committed
Changed in percona-monitoring-plugins:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.