Module: check_mk
Branch: master
Commit: c2b8b88ceb9b254e7b76b207b03064f3b0e7d439
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c2b8b88ceb9b25…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Feb 25 11:27:42 2011 +0100
Improved check guidelines
---
README.writing_checks | 51 +++++++++++++++++++++++++++++++++++++++++++++-
checks/decru_cpu | 2 +-
checks/h3c_lanswitch_cpu | 22 ++++++-------------
3 files changed, 58 insertions(+), 17 deletions(-)
diff --git a/README.writing_checks b/README.writing_checks
index feaffd1..63172aa 100644
--- a/README.writing_checks
+++ b/README.writing_checks
@@ -1,8 +1,57 @@
This file will help you to write *good* checks for Check_MK.
Code styling:
+
* Use four spaces for intending your code. Just don't use tab chars.
- And if you relly can't life without tabs set the tab width to 8 spaces.
+ And if you really can't life without tabs set the tab width to 8 spaces.
+
+* For parts part of the official Check_MK the file header with the
+ copyright information must be present. This will be automatically
+ created if you call 'make headers' in the main source directory
+
+* TCP-Agent based checks *must* put an output example of the
+ agent in comments into the check file right after the header
+ and before the implementation. If the agent output can have
+ different formats or output style then put an example for each
+ kind of style the check supports (e.g.: the output of multipath -l
+ has changed its layout between SLES 10 and SLES 11).
+
+ For SNMP based checks put examples if the kind of output is
+ in some respect remarkable.
+
+ The example output is very helpful for understanding how the
+ check parser works.
+
+* Configuration variable for main.mk should be named after
+ the check, if they are only used by this check. This does
+ not hold for variables, that are used by several checks
+ (e.g. filesystem_levels is used by df, hr_fs, df_netapp, ...)
+
+* The service description of different check types that essentially
+ do the same must be identical (e.g. if/if64/ifoperstatus). Reason:
+ this makes rules in main.mk simpler for the user!
+
+* If a check does not use check parameter, then the inventory function
+ must return None as parameter and the check function must name
+ the parameter argument _no_params.
+
+* The name of the inventory and check function must be prefixed
+ with the name of the check type, for example inventory_h3c_lanswitch_cpu
+ for 'h3c_lanswitch'
+
+* Order of implementation:
+
+ 1. fileheader with GPL
+ 2. example output from agent
+ 3. default settings of configuration variables
+ 4. helper functions and variable, if any needed
+ 5. inventory function
+ 6. check function
+ 7. check_info[] definition
+ 8. snmp_info[] definition
+ 9. snmp_scan_functions[] definition
+
+* Configuration variables for main.mk
Manpages:
*
diff --git a/checks/decru_cpu b/checks/decru_cpu
index cf1bd6b..03c1170 100644
--- a/checks/decru_cpu
+++ b/checks/decru_cpu
@@ -28,7 +28,7 @@ def inventory_decru_cpu(checkname, info):
if len(info) == 5:
return [ (None, None) ]
-def check_decru_cpu(item, params, info):
+def check_decru_cpu(item, _no_params, info):
user, nice, system, interrupt, idle = map(lambda x:float(x[0]) / 10.0, info)
user += nice
diff --git a/checks/h3c_lanswitch_cpu b/checks/h3c_lanswitch_cpu
index 1fe3002..6b799bb 100644
--- a/checks/h3c_lanswitch_cpu
+++ b/checks/h3c_lanswitch_cpu
@@ -24,22 +24,14 @@
# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301 USA.
-# check for switches using H3C lanswitch MIB
-#
-#
-# on standalone switches (SS500-EL, etc) we will get stats per cpu.
-#SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.1 = Gauge32: 11
-# the id for the CPU will be "65536". The unit Id display will show
'1'.
-#
-# on multi-unit stacks (SS5500-EL, etc) we will get stats per cpu in each switch.
-# the table id for the CPU is (unitId*65536)+0.
-#SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.65536 = Gauge32: 11
+# Example output of multi-unit stack (SS5500-EL, etc):
+# SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.65536 = Gauge32: 11
#
-# on multi-slot switches (SS8800 etc) we will get stats for each card.
-#SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.0 = Gauge32: 11
-#[...]
-#SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.12 = Gauge32: 16
-#SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.13 = Gauge32: 16
+# Example outpout of multi-slot switche (SS8800 etc):
+# SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.0 = Gauge32: 11
+# [...]
+# SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.12 = Gauge32: 16
+# SNMPv2-SMI::enterprises.43.45.1.6.1.1.1.3.13 = Gauge32: 16
# Reasonably low warning and crit levels
h3c_lanswitch_cpu_default_levels = (50, 75)