Module: check_mk
Branch: master
Commit: b8c8a06817cf7ad96d99c6710f5e5fd671323b70
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b8c8a06817cf7a…
Author: Bernd Stroessenreuther <bs(a)mathias-kettner.de>
Date: Thu Feb 27 16:11:10 2014 +0100
windows_os_bonding: new check for bonding interfaces on windows
new check for bonding interfaces on windows configured on operating system
level
---
.werks/704 | 9 +++
ChangeLog | 1 +
agents/windows/plugins/windows_os_bonding.ps1 | 28 +++++++++
checkman/windows_os_bonding | 28 +++++++++
checks/bonding.include | 11 +++-
checks/windows_os_bonding | 77 +++++++++++++++++++++++++
6 files changed, 151 insertions(+), 3 deletions(-)
diff --git a/.werks/704 b/.werks/704
new file mode 100644
index 0000000..e103909
--- /dev/null
+++ b/.werks/704
@@ -0,0 +1,9 @@
+Title: windows_os_bonding: new check for bonding interfaces on windows
+Level: 1
+Component: checks
+Version: 1.2.5i1
+Date: 1393513807
+Class: feature
+
+new check for bonding interfaces on windows configured on operating system
+level
diff --git a/ChangeLog b/ChangeLog
index 64d651f..e00ed5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -95,6 +95,7 @@
* 0560 check_mk_agent.solaris: report statgrab_mem section if solaris_mem section is missing...
* 0702 Rule for checking agents for wanted version...
* 0586 rmon_stats: new snmp check to gather network traffic statistics on RMON enabled network interfaces
+ * 0704 windows_os_bonding: new check for bonding interfaces on windows...
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
diff --git a/agents/windows/plugins/windows_os_bonding.ps1 b/agents/windows/plugins/windows_os_bonding.ps1
new file mode 100644
index 0000000..3b23cfa
--- /dev/null
+++ b/agents/windows/plugins/windows_os_bonding.ps1
@@ -0,0 +1,28 @@
+# Changelog: v0.02 Rearranged info
+# v0.03 Included try block for older operating systems
+# v0.04 Added speed info
+#
+
+try {
+ $teams = Get-NetLbfoTeam
+} catch {}
+if ($teams){
+ Write-Host "<<<windows_os_bonding:sep(58)>>>"
+ foreach ($team in $teams){
+ Write-Host Team Name: $team.Name
+ Write-Host Bonding Mode: $team.LoadBalancingAlgorithm
+ Write-Host Status: $team.Status
+ $bondspeed = (Get-NetAdapter | where {$_.InterfaceDescription -match "Multiplex"}).LinkSpeed
+ Write-Host Speed: $bondspeed `n
+ foreach ($slave in $team.members){
+ Write-Host Slave Name: $slave
+ $net = Get-Netadapter $slave
+ Write-Host Slave Interface: $net.ifName
+ Write-Host Slave Description: $net.interfaceDescription
+ Write-Host Slave Status: $net.Status
+ Write-Host Slave Speed: $net.LinkSpeed
+ Write-Host Slave MAC address: $net.MacAddress `n
+ }
+ }
+}
+
diff --git a/checkman/windows_os_bonding b/checkman/windows_os_bonding
new file mode 100644
index 0000000..0bd182e
--- /dev/null
+++ b/checkman/windows_os_bonding
@@ -0,0 +1,28 @@
+title: Bonding Network Interface on Windows (Operating System Level)
+agents: windows
+catalog: os/networking
+license: GPL
+distribution: check_mk
+description:
+ Checks the current state of a Windows bonding interface
+ (configured on operating system level).
+ If the total bonding state of the interface is down, then the
+ check returns {CRIT}, for status degraded it returns {WARN}.
+ If at least one slave interface is down or not the expected slave
+ is currently active, then the check gets {WARN}.
+
+ For this check to work you need to install the agent plugin
+ windows_os_bonding.ps1 on the target machine.
+
+ Since the check uses the same check logic as lnx_bonding, please
+ refer to lnx_bonding check manpage vor examples and parameters.
+
+item:
+ The team name of the bonding interface.
+
+inventory:
+ One check will be created for every bonding interface found in state
+ up or degraded.
+
+[parameters]
+parameters (dict): see lnx_bonding check manpage.
diff --git a/checks/bonding.include b/checks/bonding.include
index 9a1048b..6b9caaa 100644
--- a/checks/bonding.include
+++ b/checks/bonding.include
@@ -27,7 +27,7 @@
def inventory_bonding(parsed):
inventory = []
for bond, status in parsed.items():
- if status["status"] == "up":
+ if status["status"] in ("up", "degraded"):
# If no information about primary interface is available
# then assume currently active one as primary
if "primary" not in status and "active" in status:
@@ -42,7 +42,7 @@ def check_bonding(item, params, parsed):
if item not in parsed:
return (3, "no such bonding interface")
status = parsed[item]
- if status["status"] != "up":
+ if status["status"] not in ("up", "degraded"):
return 2, "interface is " + status["status"]
infos = [ "mode: " + status["mode"] ]
@@ -74,7 +74,12 @@ def check_bonding(item, params, parsed):
if expected_active != None and expected_active != active:
infos[-1] += "(!)"
infos.append("expected is %s" % expected_active)
- state = 1
+ state = 1
+
+ infos.append("bond status: " + status["status"])
+ if status["status"] != "up":
+ infos[-1] += "(!)"
+ state = 1
return state, ", ".join(infos)
diff --git a/checks/windows_os_bonding b/checks/windows_os_bonding
new file mode 100644
index 0000000..d2265c6
--- /dev/null
+++ b/checks/windows_os_bonding
@@ -0,0 +1,77 @@
+#!/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.
+
+# <<<windows_os_bonding:sep(58)>>>
+# Team Name: LAN
+# Bonding Mode: Dynamic
+# Status: Up
+# Speed: 20 Gbps
+#
+# Slave Name: NIC1
+# Slave Interface: Ethernet_14
+# Slave Description: Intel(R) Ethernet 10G 2P X520-k bNDC #2
+# Slave Status: Up
+# Slave Speed: 10 Gbps
+# Slave MAC address: 18-A9-9B-9F-AD-28
+#
+# Slave Name: NIC2
+# Slave Interface: Ethernet_10
+# Slave Description: Intel(R) Ethernet 10G 2P X520-k bNDC
+# Slave Status: Up
+# Slave Speed: 10 Gbps
+# Slave MAC address: 18-A9-9B-9F-AD-2A
+
+def parse_windows_os_bonding(info):
+ bonds = {}
+
+ for line in info:
+ if len(line)>1:
+ line[1] = re.sub("^ +", "", line[1])
+ if line[0] == "Team Name":
+ bond = line[1]
+ bonds[bond] = {}
+ bonds[bond]["interfaces"] = {}
+ elif line[0] == "Bonding Mode":
+ bonds[bond]["mode"] = line[1]
+ elif line[0] == "Status":
+ bonds[bond]["status"] = line[1].lower()
+ elif line[0] == "Slave Interface":
+ slave = line[1]
+ bonds[bond]["interfaces"][slave] = {}
+ elif line[0] == "Slave Status":
+ bonds[bond]["interfaces"][slave]["status"] = line[1].lower()
+ elif line[0] == "Slave MAC address":
+ bonds[bond]["interfaces"][slave]["hwaddr"] = line[1].lower().replace("-", ":")
+ return bonds
+
+
+check_info['windows_os_bonding'] = {
+ "check_function" : lambda item,params,info: check_bonding(item, params, parse_windows_os_bonding(info)),
+ "inventory_function" : lambda info: inventory_bonding(parse_windows_os_bonding(info)),
+ "service_description" : "Bonding Interface %s",
+ "group" : "bonding",
+ "includes" : [ "bonding.include" ],
+}