Skip to content

Commit

Permalink
Add MemFree and MemAvailable as unused memory.
Browse files Browse the repository at this point in the history
  • Loading branch information
dasm committed May 31, 2021
1 parent 4152aed commit 08064cb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions check_mem/check_mem.pl
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ sub get_memory_info {
$total_memory_kb = $2;
}
}
elsif (/^MemAvailable:\s+(\d+) kB/) {
$caches_kb += $1;
}
elsif (/^(Buffers|Cached|SReclaimable):\s+(\d+) kB/) {
$caches_kb += $2;
}
Expand Down

1 comment on commit 08064cb

@theodocius
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems to break memory checks on (at least) Ubuntu 20.04. From what I can tell the MemAvailable count includes free Swap space, and now gets added to the total size of Cache memory. This can result in a cache value that is way too large, and in the rest of the calculation can then yield a negative used-memory result, and/or a free-memory result that is higher than the total amount of physical memory.

Please sign in to comment.