Merge "Fix collectd Memory plugin Strict Mode learning"

This commit is contained in:
Zuul 2018-12-13 20:22:44 +00:00 committed by Gerrit Code Review
commit 14f168ac4b
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))