Module: check_mk
Branch: master
Commit: d1d8e8a35991bd52cfd566d5a40fd33739e5f3ee
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d1d8e8a35991bd…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Apr 15 09:35:16 2013 +0200
Fix levels on disk IO (was wrong by 10^12)
---
checks/diskstat.include | 2 +-
modules/check_mk_base.py | 15 +++++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/checks/diskstat.include b/checks/diskstat.include
index 3ea731b..ac50687 100644
--- a/checks/diskstat.include
+++ b/checks/diskstat.include
@@ -121,7 +121,7 @@ def check_diskstat_line(this_time, item, params, line):
# check levels
state, text, extraperf = check_levels(bytes_per_sec, dsname, levels,
- unit = "MB/s", factor = 1.0 / 1048576, statemarkers=True)
+ unit = "MB/s", factor = 1048576, statemarkers=True)
if text:
infos.append(text)
status = max(state, status)
diff --git a/modules/check_mk_base.py b/modules/check_mk_base.py
index 1585a8c..56c7de0 100755
--- a/modules/check_mk_base.py
+++ b/modules/check_mk_base.py
@@ -1293,6 +1293,13 @@ def nodes_of(hostname):
# Generic function for checking a value against levels. This also support
# predictive levels.
+# value: currently measured value
+# dsname: name of the datasource in the RRD that corresponds to this value
+# unit: unit to be displayed in the plugin output, e.g. "MB/s"
+# factor: the levels are multiplied with this factor before applying
+# them to the value. For example the disk-IO check uses B/s
+# as the unit for the value. But the levels are in MB/s. In that
+# case the factor is 1.0 / 1048576.
def check_levels(value, dsname, params, unit = "", factor = 1.0, statemarkers=False):
if params == None or params == (None, None):
@@ -1325,18 +1332,18 @@ def check_levels(value, dsname, params, unit = "", factor = 1.0, statemarkers=Fa
# Critical cases
if crit_upper != None and value >= crit_upper:
state = 2
- infotext += " (critical level at %.2f)" % crit_upper
+ infotext += " (critical level at %.2f%s)" % (crit_upper / factor, unit)
elif crit_lower != None and value <= crit_lower:
state = 2
- infotext += " (too low: critical level at %.2f)" % crit_lower
+ infotext += " (too low: critical level at %.2f%s)" % (crit_lower / factor, unit)
# Warning cases
elif warn_upper != None and value >= warn_upper:
state = 1
- infotext += " (warning level at %.2f)" % warn_upper
+ infotext += " (warning level at %.2f%s)" % (warn_upper / factor, unit)
elif warn_lower != None and value <= warn_lower:
state = 1
- infotext += " (too low: warning level at %.2f)" % warn_lower
+ infotext += " (too low: warning level at %.2f%s)" % (warn_lower / factor, unit)
# OK
else:
Module: check_mk
Branch: master
Commit: 1750fd4719424158d4914e2720405773e4c46932
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1750fd47194241…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Apr 11 16:05:05 2013 +0200
Added check parameter to sap_values check to limit the number of levels to use as servicename
---
checks/sap | 20 ++++++++++++++++----
web/plugins/wato/check_parameters.py | 10 +++++++++-
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/checks/sap b/checks/sap
index 9e6bf27..f27bdc1 100644
--- a/checks/sap
+++ b/checks/sap
@@ -91,12 +91,19 @@ def inventory_sap_value(info):
continue
v = rule[0]
- patterns.append(v['match'])
+ patterns.append((v['match'], v.get('limit_item_levels')))
for line in info:
- for pattern in patterns:
+ for pattern, limit_item_levels in patterns:
+ print pattern, limit_item_levels
if sap_value_path_matches(line[3], pattern):
- inv.append((line[0] + ' ' + line[3], {}))
+ params = {}
+ if limit_item_levels:
+ path = '/'.join(line[3].split('/')[-limit_item_levels:])
+ params['limit_item_levels'] = limit_item_levels
+ else:
+ path = line[3]
+ inv.append((line[0] + ' ' + path, params))
return inv
@@ -122,7 +129,12 @@ def check_sap_value(item, params, info):
status = None
perfdata = []
for line in info:
- if line[0] + ' ' + line[3] == item:
+ if params.get('limit_item_levels'):
+ this_path = '/'.join(line[3].split('/')[-params.get('limit_item_levels'):])
+ else:
+ this_path = line[3]
+
+ if line[0] + ' ' + this_path == item:
status = sap_nagios_state_map[int(line[1])]
if line[4] != '-':
# This is a performance value, has no output
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index c253cef..5d6ed73 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -418,8 +418,16 @@ register_rule(group + '/' + subgroup_inventory,
match = lambda x: (not x and 2) or (x[0] == '~' and 1 or 0),
default_value = 'SAP CCMS Monitor Templates/Dialog Overview/Dialog Response Time/ResponseTime',
)),
+ ('limit_item_levels', Integer(
+ title = _("Limit Levels for Service Names"),
+ unit = _('levels'),
+ minvalue = 1,
+ help = _("The service descriptions of the inventorized services are named like the paths "
+ "in SAP. You can use this option to let the inventory function only use the last "
+ "x path levels for naming."),
+ )),
],
- optional_keys = [],
+ optional_keys = ['limit_item_levels'],
),
match = 'list',
)
Module: check_mk
Branch: master
Commit: 8284fb20f20ea0bab84da6202012d89acefef8cc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8284fb20f20ea0…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Apr 11 15:33:52 2013 +0200
Fix file header of one PNP-template and convert to unix
---
pnp-templates/check_mk-apc_symmetra_power.php | 75 ++++++++++++-------------
1 files changed, 36 insertions(+), 39 deletions(-)
diff --git a/pnp-templates/check_mk-apc_symmetra_power.php b/pnp-templates/check_mk-apc_symmetra_power.php
index 63b2c8b..3d7ecc2 100644
--- a/pnp-templates/check_mk-apc_symmetra_power.php
+++ b/pnp-templates/check_mk-apc_symmetra_power.php
@@ -1,39 +1,36 @@
-<?php
-# +------------------------------------------------------------------+
-# | ____ _ _ __ __ _ __ |
-# | / ___| |__ ___ ___| | __ | \/ | |/ / |
-# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
-# | | |___| | | | __/ (__| < | | | | . \ |
-# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
-# | |
-# | Copyright Mathias Kettner 2012 mk(a)mathias-kettner.de |
-# +------------------------------------------------------------------+
-#
-# This file is part of Check_MK.
-# The official homepage is at http://mathias-kettner.de/check_mk.
-#
-# check_mk is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation in version 2. check_mk is distributed
-# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
-# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE. See the GNU General Public License for more de-
-# ails. You should have received a copy of the GNU General Public
-# License along with GNU Make; see the file COPYING. If not, write
-# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
-# Boston, MA 02110-1301 USA.
-
-$opt[1] = "--vertical-label \"Watt\" -l 0 -u 60 --title \"Current Power\" ";
-
-
-$def[1] = "DEF:var1=$RRDFILE[1]:$DS[1]:MAX ";
-$def[1] .= "AREA:var1#800040:\"Power\:\" ";
-$def[1] .= "GPRINT:var1:LAST:\"%2.0lfW\" ";
-$def[1] .= "LINE1:var1#800040:\"\" ";
-$def[1] .= "GPRINT:var1:MAX:\"(Max\: %2.0lfW,\" ";
-$def[1] .= "GPRINT:var1:AVERAGE:\"Avg\: %2.0lfW)\" ";
-$def[1] .= "HRULE:$CRIT[1]#FF0000:\"Critical\: $CRIT[1]W\" ";
-
-
-
-?>
+<?php
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2013 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+$opt[1] = "--vertical-label \"Watt\" -l 0 -u 60 --title \"Current Power\" ";
+
+$def[1] = "DEF:var1=$RRDFILE[1]:$DS[1]:MAX ";
+$def[1] .= "AREA:var1#800040:\"Power\:\" ";
+$def[1] .= "GPRINT:var1:LAST:\"%2.0lfW\" ";
+$def[1] .= "LINE1:var1#800040:\"\" ";
+$def[1] .= "GPRINT:var1:MAX:\"(Max\: %2.0lfW,\" ";
+$def[1] .= "GPRINT:var1:AVERAGE:\"Avg\: %2.0lfW)\" ";
+$def[1] .= "HRULE:$CRIT[1]#FF0000:\"Critical\: $CRIT[1]W\" ";
+
+?>