2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2017 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
28 # <<<win_networkadapter:sep(58)>>>
29 # AdapterType: Ethernet 802.3
31 # MACAddress: 08:00:27:9C:F8:39
32 # Name: Intel(R) PRO/1000 MT-Desktopadapter
36 # Address: 192.168.178.26
37 # Subnet: 255.255.255.0
38 # DefaultGateway: 192.168.178.1
41 def inv_win_networkadapter(info
):
42 node
= inv_tree_list("hardware.nwadapter:")
48 line
= [line
[0], ":".join(line
[1:])]
50 varname
= re
.sub(" *", "", varname
)
51 value
= re
.sub("^ ", "", value
)
56 if first_varname
and varname
== first_varname
:
57 # Looks like we have a new instance
62 first_varname
= varname
66 elif varname
== "AdapterType":
68 elif varname
== "MACAddress":
69 array
["macaddress"] = value
70 elif varname
== "Speed":
71 array
["speed"] = int(value
)
72 elif varname
== "Address":
73 for address
in value
.split(' '):
77 addrtypes
.setdefault(addrtype
+ "_address", []).append(address
)
78 elif varname
== "Subnet":
79 for address
in value
.split(' '):
83 #addrtypes.setdefault(addrtype, {}).setdefault("subnet", []).append(address)
84 addrtypes
.setdefault(addrtype
+ "_subnet", []).append(address
)
85 elif varname
== "DefaultGateway":
86 array
["gateway"] = value
88 for addrtype
in addrtypes
:
89 array
[addrtype
] = ', '.join(addrtypes
[addrtype
])
90 #for type in addrtypes[addrtype]:
91 # array[addrtype + '_' + type] = ', '.join(addrtypes[addrtype][type])
95 inv_info
['win_networkadapter'] = {
96 "inv_function": inv_win_networkadapter
,