2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 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 # hardware.pciDevice.deviceName.00:00.0 5520 I/O Hub to ESI Port
29 # hardware.pciDevice.deviceName.00:01.0 5520/5500/X58 I/O Hub PCI Express Root Port 1
30 # hardware.pciDevice.deviceName.00:02.0 5520/5500/X58 I/O Hub PCI Express Root Port 2
31 # hardware.pciDevice.deviceName.00:03.0 5520/5500/X58 I/O Hub PCI Express Root Port 3
32 # hardware.cpuPkg.busHz.0 133338028
33 # hardware.cpuPkg.busHz.1 133338066
34 # hardware.cpuPkg.description.0 Intel(R) Xeon(R) CPU X5670 @ 2.93GHz
35 # hardware.cpuPkg.description.1 Intel(R) Xeon(R) CPU X5670 @ 2.93GHz
36 # hardware.cpuPkg.hz.0 2933437438
37 # hardware.cpuPkg.hz.1 2933437797
38 # hardware.cpuPkg.index.0 0
39 # hardware.cpuPkg.index.1 1
40 # hardware.cpuPkg.vendor.0 intel
41 # hardware.cpuPkg.vendor.1 intel
44 def inv_esx_vsphere_hostsystem_parse(info
, inv_items
=None):
52 for pattern
, settings
in inv_items
.items():
53 if key
.startswith(pattern
):
54 tokens
= key
.split(".")
55 if settings
.get("index"):
56 name
, subtype
, index
= ".".join(tokens
[:2]), tokens
[2], ".".join(tokens
[3:])
57 result
.setdefault(name
, {})
58 result
[name
].setdefault(index
, {})[subtype
] = " ".join(line
[1:])
60 result
.setdefault(".".join(tokens
[:-1]), {})[tokens
[-1]] = " ".join(line
[1:])
65 def inv_esx_vsphere_hostsystem(info
):
73 "hardware.biosInfo": {
76 "hardware.systemInfo": {
79 "hardware.memorySize": {
84 data
= inv_esx_vsphere_hostsystem_parse(info
, inv_items
)
85 # data example: {'hardware.cpuPkg': {'0': {'busHz': '133338028',
86 # 'description': 'Intel(R) Xeon(R) CPU X5670 @ 2.93GHz',
89 # 'vendor': 'intel'}}}
91 node
= inv_tree("hardware.cpu.")
92 if "hardware.cpuInfo" in data
:
93 node
["max_speed"] = float(data
["hardware.cpuInfo"]["hz"])
94 node
["cpus"] = int(data
["hardware.cpuInfo"]["numCpuPackages"])
95 node
["cores"] = int(data
["hardware.cpuInfo"]["numCpuCores"])
96 node
["threads"] = int(data
["hardware.cpuInfo"]["numCpuThreads"])
98 node
["cores_per_cpu"] = node
["cores"] / node
["cpus"]
99 node
["threads_per_cpu"] = node
["threads"] / node
["cpus"]
100 if "hardware.cpuPkg" in data
:
101 node
["model"] = data
["hardware.cpuPkg"]["0"]["description"]
102 node
["vendor"] = data
["hardware.cpuPkg"]["0"]["vendor"]
103 node
["bus_speed"] = float(data
["hardware.cpuPkg"]["0"]["busHz"])
105 if "hardware.biosInfo" in data
:
106 node
= inv_tree("software.bios.")
107 node
["version"] = data
["hardware.biosInfo"]["biosVersion"]
110 node
["date"] = float(time
.strftime("%s", \
111 time
.strptime(data
["hardware.biosInfo"]["releaseDate"],"%Y-%m-%dT%H:%M:%SZ")))
115 if "hardware.systemInfo" in data
:
116 node
= inv_tree("hardware.system.")
117 node
["product"] = data
["hardware.systemInfo"]["model"]
118 node
["vendor"] = data
["hardware.systemInfo"]["vendor"]
119 # We only know for HP that ServiceTag is the serial
120 if node
["vendor"] == "HP":
121 node
["serial"] = data
["hardware.systemInfo.otherIdentifyingInfo.ServiceTag"]["0"]
123 hardware_systeminfo
= data
.get("hardware.systemInfo", {})
124 if "uuid" in hardware_systeminfo
:
125 node
["uuid"] = hardware_systeminfo
["uuid"]
126 if "0" in hardware_systeminfo
:
127 node
["serial"] = hardware_systeminfo
["0"]["ServiceTag"]
128 if "memorySize" in data
["hardware"]:
129 node
= inv_tree("hardware.memory.")
130 node
["total_ram_usable"] = int(data
["hardware"]["memorySize"])
133 inv_info
['esx_vsphere_hostsystem'] = {
134 "inv_function": inv_esx_vsphere_hostsystem
,