Fix collectd Memory plugin Strict Mode learning

Existing code sets overcommit strict mode to True
if any non-zero value is returned from a read
of /proc/sys/vm/overcommit_memory.

This is incorrect.

Strict mode should only be set when the returned
value is 2.

Change-Id: I2c5328624571bb3b2f478d5a79615650bb92cbd2
Closes-Bug: 1808225
Signed-off-by: Eric MacDonald <eric.macdonald@windriver.com>
This commit is contained in:
Eric MacDonald 2018-12-12 17:15:10 -05:00
parent 3ae2753959
commit 0ec1725371
2 changed files with 13 additions and 3 deletions

View File

@ -16,4 +16,4 @@ COPY_LIST="$PKG_BASE/src/LICENSE \
$PKG_BASE/src/example.py \
$PKG_BASE/src/example.conf"
TIS_PATCH_VER=2
TIS_PATCH_VER=3

View File

@ -74,16 +74,26 @@ def config_func(config):
(PLUGIN, obj.cmd))
# Get the platform cpu list and number of cpus reported by /proc/cpuinfo
# Load the hostname and kernel memory 'overcommit' setting.
def init_func():
# get current hostname
obj.hostname = os.uname()[1]
# get strict setting
#
# a value of 0 means "heuristic overcommit"
# a value of 1 means "always overcommit"
# a value of 2 means "don't overcommit".
#
# set strict true strict=1 if value is = 2
# otherwise strict is false strict=0 (default)
fn = '/proc/sys/vm/overcommit_memory'
if os.path.exists(fn):
with open(fn, 'r') as infile:
for line in infile:
obj.strict = int(line)
if int(line) == 2:
obj.strict = 1
break
collectd.info("%s strict:%d" % (PLUGIN, obj.strict))