Module: check_mk
Branch: master
Commit: 530eee4d9d55d56067de49bb021e6e0006462352
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=530eee4d9d55d5…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Fri Aug 2 12:10:30 2013 +0200
new check emcvnx_hba added (including manpage and pnp-template)
---
checkman/{emc_storage.hba => emcvnx_hba} | 8 --
checks/emcvnx_hba | 133 ++++++++++++++++++++++++++++++
pnp-templates/check_mk-emcvnx_disks.php | 1 +
pnp-templates/check_mk-emcvnx_hba.php | 60 ++++++++++++++
4 files changed, 194 insertions(+), 8 deletions(-)
diff --git a/checkman/emc_storage.hba b/checkman/emcvnx_hba
similarity index 58%
rename from checkman/emc_storage.hba
rename to checkman/emcvnx_hba
index 58bd975..c90339b 100644
--- a/checkman/emc_storage.hba
+++ b/checkman/emcvnx_hba
@@ -9,18 +9,10 @@ description:
The values for Blocks Read/sec and Blocks Written/sec are just informational.
The check always returns {OK}
- Hint for implementation: Look for "Blocks Read:" and "Blocks
Written:"
- lines in section "SP Name: <my Name>" and "SP Port ID: <my
ID>" lines found under
- "Information about each SPPORT:". Remember values of last check and devide by
the
- time since last check.
-
item:
Consists of the SP Name and the SP Port ID as returned by the agent.
E. g. "SP A Port 0"
- Hint for implementation: Look for "SP Name:" and "SP Port ID:" lines
in section
- "Information about each SPPORT:"
-
perfdata:
Two values: Blocks Read/sec and Blocks Written/sec
diff --git a/checks/emcvnx_hba b/checks/emcvnx_hba
new file mode 100644
index 0000000..a0df51c
--- /dev/null
+++ b/checks/emcvnx_hba
@@ -0,0 +1,133 @@
+#!/usr/bin/python # -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | 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.
+
+# Example output from agent:
+#<<<emcvnx_hba>>>
+#Information about each SPPORT:
+#
+#SP Name: SP A
+#SP Port ID: 0
+#SP UID: 50:06:01:60:BE:A0:5D:E5:50:06:01:60:3E:A0:5D:E5
+#Link Status: Up
+#Port Status: Online
+#Switch Present: YES
+#Switch UID: 10:00:00:27:F8:28:52:5B:20:02:00:27:F8:28:52:5B
+#SP Source ID: 66048
+#ALPA Value: 0
+#Speed Value : 8Gbps
+#Auto Negotiable : NO
+#Available Speeds:
+#2Gbps
+#4Gbps
+#8Gbps
+#Auto
+#Requested Value: Auto
+#MAC Address: Not Applicable
+#SFP State: Online
+#Reads: 426729
+#Writes: 8683578
+#Blocks Read: 4917783
+#Blocks Written: 12008476
+#Queue Full/Busy: 0
+#I/O Module Slot: Onboard
+#Physical Port ID: 2
+#Usage: Mirrorview
+#SFP/Connector EMC Part Number: 019-078-042
+#SFP/Connector EMC Serial Number: 00000000000
+#SFP/Connector Vendor Part Number: AFBR-57D7APZ-E2
+#SFP/Connector Vendor Serial Number: AGL1213A3188822
+#SFP/Connector Supported Speeds:
+#2Gbps
+#4Gbps
+#8Gbps
+#
+#SP Name: SP A
+#SP Port ID: 1
+#SP UID: 50:06:01:60:BE:A0:5D:E5:50:06:01:61:3E:A0:5D:E5
+#Link Status: Up
+#Port Status: Online
+#Switch Present: YES
+#[...]
+
+# Parse agent output into a dict of the form:
+# parsed = {
+# {'SP A Port 0': {'Blocks Read': 4917783, 'Blocks Written':
12008476},
+# 'SP A Port 1': {'Blocks Read': 363283639, 'Blocks Written':
218463965},
+# 'SP A Port 2': {'Blocks Read': 2, 'Blocks Written': 0},
+# 'SP B Port 0': {'Blocks Read': 0, 'Blocks Written': 4348086},
+# }
+
+def parse_emcvnx_hba(info):
+ parsed = {}
+ for line in info:
+ if len(line) > 2 and line[0] == "SP" and line[1] ==
"Name:":
+ hba_id = " ".join(line[2:])
+ elif len(line) > 2 and line[0] == "SP" and line[1] ==
"Port" and line[2] == "ID:":
+ hba_id += " Port " + line[-1]
+ hba = {}
+ parsed[hba_id] = hba
+ elif len(line) > 2 and line[0] == "Blocks" and line[1] in
("Read:", "Written:"):
+ hba["Blocks " + line[1].replace(":", "")] =
saveint(line[-1])
+ return parsed
+
+
+def inventory_emcvnx_hba(info):
+ parsed = parse_emcvnx_hba(info)
+ import pprint; pprint.pprint(parsed)
+ inventory = []
+ for hba in parsed:
+ inventory.append( (hba, None) )
+ return inventory
+
+
+def check_emcvnx_hba(item, _no_params, info):
+ now = time.time()
+ perfdata = []
+ try:
+ read_blocks = parse_emcvnx_hba(info)[item]["Blocks Read"]
+ write_blocks = parse_emcvnx_hba(info)[item]["Blocks Written"]
+ countername_r = "emcvnx_hba.read_blocks.%s" % item.replace("
", "_")
+ countername_w = "emcvnx_hba.write_blocks.%s" % item.replace("
", "_")
+ timedif, read_blocks_per_sec = get_counter(countername_r, now, read_blocks)
+ timedif, write_blocks_per_sec = get_counter(countername_w, now, write_blocks)
+ read_blocks_per_sec = saveint(read_blocks_per_sec)
+ write_blocks_per_sec = saveint(write_blocks_per_sec)
+ perfdata.append(("read_blocks", read_blocks_per_sec))
+ perfdata.append(("write_blocks", write_blocks_per_sec))
+ #print "read blocks: %s, %s/sec" % (read_blocks, read_blocks_per_sec)
+ #print "write blocks: %s, %s/sec" % (write_blocks,
write_blocks_per_sec)
+
+ return 0, "Read: %s Blocks/s, Write: %s Blocks/s" %
(read_blocks_per_sec, write_blocks_per_sec), perfdata
+
+ except KeyError:
+ return 3, "HBA %s not found in agent output" % item
+
+
+check_info['emcvnx_hba'] = {
+ "inventory_function" : inventory_emcvnx_hba,
+ "check_function" : check_emcvnx_hba,
+ "service_description" : "HBA %s",
+ 'has_perfdata' : True,
+}
diff --git a/pnp-templates/check_mk-emcvnx_disks.php
b/pnp-templates/check_mk-emcvnx_disks.php
new file mode 120000
index 0000000..8b45325
--- /dev/null
+++ b/pnp-templates/check_mk-emcvnx_disks.php
@@ -0,0 +1 @@
+check_mk-diskstat.php
\ No newline at end of file
diff --git a/pnp-templates/check_mk-emcvnx_hba.php
b/pnp-templates/check_mk-emcvnx_hba.php
new file mode 100644
index 0000000..9823030
--- /dev/null
+++ b/pnp-templates/check_mk-emcvnx_hba.php
@@ -0,0 +1,60 @@
+<?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.
+
+// Make data sources available via names
+$RRD = array();
+foreach ($NAME as $i => $n) {
+ $RRD[$n] = "$RRDFILE[$i]:$DS[$i]:MAX";
+ $WARN[$n] = $WARN[$i];
+ $CRIT[$n] = $CRIT[$i];
+ $MIN[$n] = $MIN[$i];
+ $MAX[$n] = $MAX[$i];
+}
+
+$servicedesc = str_replace("_", " ", $servicedesc);
+
+$opt[1] = "--vertical-label 'I/O (Blocks/s)' -X0 --title \"iSCSI
traffic $hostname / $servicedesc\" ";
+
+$def[1] =
+ "HRULE:0#a0a0a0 ".
+# read
+ "DEF:read_blocks=$RRD[read_blocks] ".
+ "AREA:read_blocks#40c080:\"Read \" ".
+ "GPRINT:read_blocks:LAST:\"%8.1lf Blocks/s last\" ".
+ "GPRINT:read_blocks:AVERAGE:\"%6.1lf Blocks/s avg\" ".
+ "GPRINT:read_blocks:MAX:\"%6.1lf Blocks/s max\\n\" ";
+
+# write
+$def[1] .=
+ "DEF:write_blocks=$RRD[write_blocks] ".
+ "CDEF:write_blocks_neg=write_blocks,-1,* ".
+ "AREA:write_blocks_neg#4080c0:\"Write \" ".
+ "GPRINT:write_blocks:LAST:\"%6.1lf Blocks/s last\" ".
+ "GPRINT:write_blocks:AVERAGE:\"%6.1lf Blocks/s avg\" ".
+ "GPRINT:write_blocks:MAX:\"%6.1lf Blocks/s max\\n\" ".
+ "";
+
+?>
+