Module: check_mk
Branch: master
Commit: b5f271c4834d4bab2546e157e7433710ee890733
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b5f271c4834d4b…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Thu Jul 5 14:18:39 2018 +0200
Make sure PerfValue is float or int (not string)
Change-Id: Id01a98b34159f6eb3ec7848cfd23930d220d6417
---
checks/arcserve_backup | 2 +-
checks/drbd | 2 +-
checks/esx_vsphere_datastores | 4 ++--
checks/fileinfo | 2 +-
checks/lparstat_aix | 15 ++++++++-------
checks/mem.include | 16 ++++++++--------
6 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/checks/arcserve_backup b/checks/arcserve_backup
index 3236e0c..8b8b4d9 100644
--- a/checks/arcserve_backup
+++ b/checks/arcserve_backup
@@ -141,7 +141,7 @@ def check_arcserve_backup(item, _no_params, info):
message += "Size: %s" %
get_bytes_human_readable(parsed[item]["size"])
else:
size=0
- perfdata.append(("size", str(size) + "Bytes"))
+ perfdata.append(("size", size))
# result
if message != "":
diff --git a/checks/drbd b/checks/drbd
index 16ebfe3..d3376c5 100644
--- a/checks/drbd
+++ b/checks/drbd
@@ -410,7 +410,7 @@ def check_drbd_stats(item, params, info):
else:
parsed[key] = '0' # perfdata must always have same number of
entries
if parsed[key].isdigit():
- perfdata.append(('%s' % label.replace(" ",
"_"), parsed[key]))
+ perfdata.append(('%s' % label.replace(" ",
"_"), int(parsed[key])))
return (0, output.rstrip(', '), perfdata)
return (3, "Undefined state")
diff --git a/checks/esx_vsphere_datastores b/checks/esx_vsphere_datastores
index bbfb9bf..f730dd8 100644
--- a/checks/esx_vsphere_datastores
+++ b/checks/esx_vsphere_datastores
@@ -104,8 +104,8 @@ def check_esx_vsphere_datastores(item, params, info):
prov_warn_mb = None
prov_crit_mb = None
perfdata += [
- ('uncommitted', str(uncommitted_mb) + 'MB'),
- ('overprovisioned', str(prov_mb) + 'MB', prov_warn_mb,
prov_crit_mb),
+ ('uncommitted', uncommitted_mb),
+ ('overprovisioned', prov_mb, prov_warn_mb, prov_crit_mb),
]
if not store["accessible"]:
diff --git a/checks/fileinfo b/checks/fileinfo
index fe991f0..6b28477 100644
--- a/checks/fileinfo
+++ b/checks/fileinfo
@@ -331,7 +331,7 @@ def fileinfo_check_function(check_definition, params,
outof_range_txt):
for what_title, what, val, verbfunc in check_definition:
infos.append("%s: %s" % (what_title, verbfunc(val)))
if type(val) in [long, int]: # because strings go into infos but not into
perfdata
- warn, crit = "", ""
+ warn, crit = None, None
for how, comp, cfunc in [
("min", "<", lambda a, b: a < b),
("max", ">", lambda a, b: a > b),
diff --git a/checks/lparstat_aix b/checks/lparstat_aix
index 9fd7a8d..4ae565a 100644
--- a/checks/lparstat_aix
+++ b/checks/lparstat_aix
@@ -81,12 +81,12 @@ def check_lparstat(item, params, info):
else:
# The new agent provides three lines, the title line, spacer line and the values
cols = [ c.replace('%', '') for c in info[-3] ]
- uom = [ '%' in c and '%' or '' for c in info[-3] ]
+ uom = [ '%' * ('%' in c) for c in info[-3] ]
values = info[-1]
- perfdata = [ (cols[i], val+uom[i]) for i, val in enumerate(values) ]
- output = ', '.join([ cols[i].title()+': '+val+uom[i] for i, val in
enumerate(values) ])
-
+ perfdata = zip(cols, map(float, values))
+ output = ', '.join("%s: %s%s" % (c.title(), v, u)
+ for c, v, u in zip(cols, values, uom))
return 0, output, perfdata
check_info["lparstat_aix"] = {
@@ -110,9 +110,10 @@ def check_lparstat_aix_cpu(_no_item, params, info):
line = info[-1]
user, system, wait, idle = map(float, line[:4])
perfdata = [
- ( "user", "%.3f" % user ),
- ( "system", "%.3f" % system ),
- ( "wait", "%.3f" % wait ) ]
+ ("user", user),
+ ("system", system),
+ ("wait", wait),
+ ]
util = user + system + wait
diff --git a/checks/mem.include b/checks/mem.include
index 051020a..97777b9 100644
--- a/checks/mem.include
+++ b/checks/mem.include
@@ -118,13 +118,13 @@ def check_memory(params, meminfo):
# Prepare performance data
perfdata = [
- ('ramused', str( (memused_kb - caches_kb) / 1024) + 'MB',
'', '', 0, totalmem_mb),
- ('swapused', str(swapused_kb / 1024) + 'MB', '',
'', 0, meminfo['SwapTotal']/1024),
- ('memused', str(totalused_mb) + 'MB', warn_mb, crit_mb, 0,
totalvirt_mb),
+ ('ramused', (memused_kb - caches_kb) / 1024, None, None, 0,
totalmem_mb),
+ ('swapused', swapused_kb / 1024, None, None, 0,
meminfo['SwapTotal']/1024),
+ ('memused', totalused_mb, warn_mb, crit_mb, 0, totalvirt_mb),
]
if average_min:
- perfdata.append(('memusedavg', str(totalused_mb_avg)+'MB'))
+ perfdata.append(('memusedavg', totalused_mb_avg))
# Check levels
state = 0
@@ -153,10 +153,10 @@ def check_memory(params, meminfo):
shared_mb = int(meminfo.get('Shmem', 0)) / 1024
perfdata += [
- ('mapped', str(mapped_mb) + 'MB'),
- ('committed_as', str(committed_as_mb) + 'MB'),
- ('pagetables', str(pagetables_mb) + 'MB'),
- ('shared', str(shared_mb) + 'MB'),
+ ('mapped', mapped_mb),
+ ('committed_as', committed_as_mb),
+ ('pagetables', pagetables_mb),
+ ('shared', shared_mb),
]
infotext += ", %.1f mapped, %.1f committed, %.1f shared" % \
(mapped_mb / 1024.0, committed_as_mb / 1024.0, shared_mb / 1024.0)