Module: check_mk
Branch: master
Commit: d68111c0ca7d413d18c3c575cbdbff0b898cd74d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d68111c0ca7d41…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue May 23 17:07:37 2017 +0200
4662 win_ip_r: inventorizes routes table of Windows hosts
Change-Id: I98ccca999403d189b48ce7d036a341782864f4fa
---
.werks/4662 | 11 ++++++
agents/windows/plugins/mk_inventory.vbs | 35 +++++++++++++++++
inventory/win_ip_r | 68 +++++++++++++++++++++++++++++++++
3 files changed, 114 insertions(+)
diff --git a/.werks/4662 b/.werks/4662
new file mode 100644
index 0000000..d7f3c31
--- /dev/null
+++ b/.werks/4662
@@ -0,0 +1,11 @@
+Title: win_ip_r: inventorizes routes table of Windows hosts
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.5.0i1
+Date: 1495552000
+Class: feature
+
+In order to make this inventory plugin run ypu have
+to install the related agent plugin {{mk_inventory.vbs}}.
diff --git a/agents/windows/plugins/mk_inventory.vbs
b/agents/windows/plugins/mk_inventory.vbs
index df3990a..19f74fe 100644
--- a/agents/windows/plugins/mk_inventory.vbs
+++ b/agents/windows/plugins/mk_inventory.vbs
@@ -156,6 +156,37 @@ Sub getNetworkAdapter(arrVars)
Next
End Sub
+Sub getRouteTable()
+ Set objClass =
GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
+ Set Adapters = objClass.ExecQuery("Select * from Win32_NetworkAdapter")
+ Set Routes = objClass.ExecQuery("Select * from Win32_IP4RouteTable")
+
+ Dim indexNames : Set indexNames = CreateObject("Scripting.Dictionary")
+ For Each adapter in Adapters
+ indexNames.Add adapter.InterfaceIndex, adapter.Name
+ Next
+
+ Dim routeTypes : Set routeTypes = CreateObject("Scripting.Dictionary")
+ routeTypes.Add 1, "other"
+ routeTypes.Add 2, "invalid"
+ routeTypes.Add 3, "direct"
+ routeTypes.Add 4, "indirect"
+
+ For Each route in Routes
+ Dim rtType, rtGateway, rtTarget, rtMask, rtDevice
+
+ rtType = routeTypes(route.Type)
+ rtGateway = route.NextHop
+ rtTarget = route.Destination
+ rtMask = route.Mask
+ rtDevice = indexNames(route.InterfaceIndex)
+
+ If rtDevice <> "" Then
+ outPut(rtType & "|" & rtTarget & "|" &
rtMask & "|" & rtGateway & "|" & rtDevice)
+ End If
+ Next
+End Sub
+
Sub RecurseForExecs(strFolderPath)
Dim objFolder : Set objFolder = fso.GetFolder(strFolderPath)
Dim objFile
@@ -269,6 +300,10 @@ Call startSection("win_networkadapter",58,timeUntil)
adapterVars = Array("ServiceName", "MACAddress",
"AdapterType", "DeviceID", "NetworkAddresses",
"Speed")
Call getNetworkAdapter(adapterVars)
+' Route Table
+Call startSection("win_ip_r",124,timeUntil)
+Call getRouteTable()
+
' Installed Software
Call startSection("win_wmi_software",124,timeUntil)
swVars = Array( "ProductName", "Publisher",
"VersionString", "InstallDate", "Language")
diff --git a/inventory/win_ip_r b/inventory/win_ip_r
new file mode 100644
index 0000000..3e06b11
--- /dev/null
+++ b/inventory/win_ip_r
@@ -0,0 +1,68 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2017 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-
+# tails. 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.
+
+
+# -- (type|target|mask|gateway|device)
+# <<<win_ip_r:sep(124):persist(1495544240)>>>
+# indirect|0.0.0.0|0.0.0.0|11.112.81.1|vmxnet3 Ethernet Adapter #2
+# direct|11.112.81.0|255.255.255.0|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|11.112.81.34|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|11.112.81.36|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|11.112.81.39|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|11.112.81.41|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|11.112.81.43|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|11.112.81.44|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|11.112.81.45|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|11.112.81.46|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|11.112.81.255|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|11.112.136.0|255.255.252.0|0.0.0.0|vmxnet3 Ethernet Adapter
+# direct|11.112.136.112|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter
+# direct|11.112.139.255|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter
+# direct|169.254.0.0|255.255.0.0|0.0.0.0|Microsoft Failover Cluster Virtual Adapter
+# direct|169.254.2.184|255.255.255.255|0.0.0.0|Microsoft Failover Cluster Virtual
Adapter
+# direct|169.254.255.255|255.255.255.255|0.0.0.0|Microsoft Failover Cluster Virtual
Adapter
+# direct|224.0.0.0|240.0.0.0|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|224.0.0.0|240.0.0.0|0.0.0.0|vmxnet3 Ethernet Adapter
+# direct|224.0.0.0|240.0.0.0|0.0.0.0|Microsoft Failover Cluster Virtual Adapter
+# direct|255.255.255.255|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter #2
+# direct|255.255.255.255|255.255.255.255|0.0.0.0|vmxnet3 Ethernet Adapter
+# direct|255.255.255.255|255.255.255.255|0.0.0.0|Microsoft Failover Cluster Virtual
Adapter
+
+
+def inv_win_ip_r(info):
+ routes = inv_tree_list("networking.routes:")
+ for _type, target, mask, gateway, device in info:
+ routes.append({
+ "target" : target,
+ "device" : device,
+ "gateway" : gateway,
+ "type" : _type,
+ })
+
+
+inv_info['win_ip_r'] = {
+ 'inv_function' : inv_win_ip_r,
+}