Merge ~lihuiguo/charm-nrpe:bug/1975886 into charm-nrpe:master

Proposed by Linda Guo
Status: Merged
Approved by: Alvaro Uria
Approved revision: 94e17687f888fcc492efd5eb6ed30b6198103d42
Merged at revision: b85a5429d3440d52422bc64036700cf9fea75fa3
Proposed branch: ~lihuiguo/charm-nrpe:bug/1975886
Merge into: charm-nrpe:master
Diff against target: 30 lines (+3/-2)
1 file modified
files/plugins/check_mem.pl (+3/-2)
Reviewer Review Type Date Requested Status
Alvaro Uria (community) Approve
Andrea Ieri Approve
🤖 prod-jenkaas-bootstack (community) continuous-integration Needs Fixing
Review via email: mp+423497@code.launchpad.net

Commit message

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.

To post a comment you must log in.
Revision history for this message
Linda Guo (lihuiguo) wrote :
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :

A CI job is currently in progress. A follow up comment will be added when it completes.

Revision history for this message
🤖 prod-jenkaas-bootstack (prod-jenkaas-bootstack) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Gui Maluf Balzana (guimalufb) :
Revision history for this message
Alvaro Uria (aluria) wrote :

These tests passed in jenkaas [1].

+1 from me, after the extra indentation is addressed (reported by Gui).

1. https://jenkins.canonical.com/bootstack/job/lp-charm-test-functest/834/console

review: Needs Fixing
Revision history for this message
Linda Guo (lihuiguo) wrote :

pushed an update to fix extra indentation

Revision history for this message
Andrea Ieri (aieri) wrote :

Approved, but please fix the commit message: MemAvailable does *not* include free swap. See https://www.kernel.org/doc/html/latest/filesystems/proc.html#meminfo

review: Approve
Revision history for this message
Linda Guo (lihuiguo) wrote :

> Approved, but please fix the commit message: MemAvailable does *not* include
> free swap. See
> https://www.kernel.org/doc/html/latest/filesystems/proc.html#meminfo

Thanks, updated the commit message

Revision history for this message
Alvaro Uria (aluria) wrote :

+1

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision b85a5429d3440d52422bc64036700cf9fea75fa3

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/files/plugins/check_mem.pl b/files/plugins/check_mem.pl
2index 044ed5c..a1cd87c 100755
3--- a/files/plugins/check_mem.pl
4+++ b/files/plugins/check_mem.pl
5@@ -140,6 +140,7 @@ sub get_memory_info {
6 my $hugepages_nr = 0;
7 my $hugepages_size = 0;
8 my $hugepages_kb = 0;
9+ my $available_memory_kb = 0;
10
11 my $uname;
12 if ( -e '/usr/bin/uname') {
13@@ -166,7 +167,7 @@ sub get_memory_info {
14 }
15 }
16 elsif (/^MemAvailable:\s+(\d+) kB/) {
17- $caches_kb += $1;
18+ $available_memory_kb = $1;
19 }
20 elsif (/^(Buffers|Cached|SReclaimable):\s+(\d+) kB/) {
21 $caches_kb += $2;
22@@ -185,7 +186,7 @@ sub get_memory_info {
23 }
24 }
25 $hugepages_kb = $hugepages_nr * $hugepages_size;
26- $used_memory_kb = $total_memory_kb - $free_memory_kb;
27+ $used_memory_kb = $total_memory_kb - $available_memory_kb;
28
29 # Read hugepages info from the newer sysfs interface if available
30 my $hugepages_sysfs_dir = '/sys/kernel/mm/hugepages';

Subscribers

People subscribed via source and target branches

to all changes: