Module: check_mk
Branch: master
Commit: 945c1541d270642b11ccd8e0cec93e02535ff40b
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=945c1541d27064…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jan 30 15:23:37 2015 +0100
#1970 FIX lparstat_aix: Made the check compatible to different kind of lparstat output
lparstat seem to produce a lot of different kinds of output, meaning different number
and order of columns. The check can now deal with a lot more kind of output types.
To get this new flexibility, you need to use the newest version of the agent now.
---
.werks/1970 | 12 +++++++++
ChangeLog | 1 +
agents/check_mk_agent.aix | 2 +-
checks/lparstat_aix | 63 +++++++++++++++++++++++++++++++--------------
4 files changed, 57 insertions(+), 21 deletions(-)
diff --git a/.werks/1970 b/.werks/1970
new file mode 100644
index 0000000..28f0a1a
--- /dev/null
+++ b/.werks/1970
@@ -0,0 +1,12 @@
+Title: lparstat_aix: Made the check compatible to different kind of lparstat output
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1422627719
+
+lparstat seem to produce a lot of different kinds of output, meaning different number
+and order of columns. The check can now deal with a lot more kind of output types.
+To get this new flexibility, you need to use the newest version of the agent now.
diff --git a/ChangeLog b/ChangeLog
index e3bf3b2..21cbff5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -130,6 +130,7 @@
* 1887 FIX: Logwatch event console forwarding: Better dealing with logwatch states
* 1969 FIX: apc_symmetra: Fix wrong critical state "0 batteries need
replacement"
* 1926 FIX: ps: reenable compatiblity with existing configurations...
+ * 1970 FIX: lparstat_aix: Made the check compatible to different kind of lparstat
output...
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
diff --git a/agents/check_mk_agent.aix b/agents/check_mk_agent.aix
index 616270e..489430e 100755
--- a/agents/check_mk_agent.aix
+++ b/agents/check_mk_agent.aix
@@ -142,7 +142,7 @@ ps -ef -F user,vszsize,rssize,pcpu,args | sed -e 1d -e 's/ *\([^
]*\) *\([^ ]*\)
if type lparstat >/dev/null 2>&1
then
echo '<<<lparstat_aix>>>'
- lparstat 1 1 | tail -n1
+ lparstat 1 1
fi
echo '<<<vmstat_aix>>>'
diff --git a/checks/lparstat_aix b/checks/lparstat_aix
index 134f445..732d5ce 100644
--- a/checks/lparstat_aix
+++ b/checks/lparstat_aix
@@ -30,36 +30,55 @@
# | Joerg Linge 2009 <joerg.linge(a)pnp4nagios.org> Copyright 2010 |
# +------------------------------------------------------------------+
-# %user %sys %wait %idle physc %entc lbusy app vcsw phint
-# ----- ---- ----- ----- ----- ----- ------ --- ---- -----
-# 2.5 6.0 0.1 91.5 0.03 11.4 1.8 3.27 1976647217 490545630
+# %user %sys %wait %idle physc %entc lbusy app vcsw phint
+# ----- ---- ----- ----- ----- ----- ------ --- ---- -----
+# 2.5 6.0 0.1 91.5 0.03 11.4 1.8 3.27 1976647217 490545630
+# %user %sys %wait %idle physc %entc lbusy vcsw phint %nsp %utcyc
+# ----- ----- ------ ------ ----- ----- ------ ----- ----- ----- ------
+# 0.2 0.4 0.0 99.3 0.02 1.7 0.0 215 3 101 0.64
+
+# %user %sys %wait %idle physc %entc lbusy app vcsw phint %nsp %utcyc
+# ----- ----- ------ ------ ----- ----- ------ --- ----- ----- ----- ------
+# 0.1 0.4 0.0 99.5 0.02 1.6 0.0 3.97 297 0 101 0.64
+
+# %user %sys %wait %idle physc %entc lbusy vcsw phint %nsp
+# ----- ----- ------ ------ ----- ----- ------ ----- ----- -----
+# 0.1 0.2 0.0 99.6 0.04 1.8 2.3 371 0 58
lparstat_default_levels = (5, 10)
def inventory_lparstat(info):
- if len(info) == 1 and len(info[0]) >= 5:
+ if len(info) >= 1 and len(info[2]) >= 5:
return [(None, "", "lparstat_default_levels")]
def check_lparstat(item, params, info):
- line = info[0]
- if len(line) == 10:
- cols = [ 'physc', 'entc', 'lbusy', 'app',
'vcsw', 'phint' ]
- uom = [ '', '%', '', '',
'', '' ]
- values = line[-6:]
- elif len(line) == 9:
- cols = [ 'physc', 'entc', 'lbusy', 'app' ]
- uom = [ '', '%', '', '' ]
- values = line[-4:]
- elif len(line) == 6:
- cols = [ 'nsp', 'utcyc' ]
- uom = [ '%', '%' ]
- values = line[-2:]
+ if len(info) == 1:
+ # Old agent provided only the values in a single line
+ line = info[0]
+ if len(line) == 10:
+ cols = [ 'physc', 'entc', 'lbusy', 'app',
'vcsw', 'phint' ]
+ uom = [ '', '%', '', '',
'', '' ]
+ values = line[-6:]
+ elif len(line) == 9:
+ cols = [ 'physc', 'entc', 'lbusy', 'app' ]
+ uom = [ '', '%', '', '' ]
+ values = line[-4:]
+ elif len(line) == 6:
+ cols = [ 'nsp', 'utcyc' ]
+ uom = [ '%', '%' ]
+ values = line[-2:]
+ else:
+ return 3, "Invalid output from agent"
else:
- return 3, "Invalid output from agent"
+ # The new agent provides three lines, the title line, spacer line and the values
+ cols = [ c.replace('%', '') for c in info[0] ]
+ uom = [ '%' in c and '%' or '' for c in info[0] ]
+ values = info[2]
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) ])
+
return 0, output, perfdata
check_info["lparstat_aix"] = {
@@ -73,11 +92,15 @@ check_info["lparstat_aix"] = {
kernel_util_default_levels = None
def inventory_lparstat_aix_cpu(info):
- if len(info) == 1 and len(info[0]) >= 4:
+ if len(info) >= 1 and len(info[2]) >= 4:
return [(None, "kernel_util_default_levels")]
def check_lparstat_aix_cpu(_no_item, params, info):
- user, system, wait, idle = map(float, info[0][:4])
+ if len(info) == 1:
+ line = info[0] # old (single line) agent output
+ else:
+ line = info[2]
+ user, system, wait, idle = map(float, line[:4])
perfdata = [
( "user", "%.3f" % user ),
( "system", "%.3f" % system ),