2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2013 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.
27 # Example output from agent:
28 # <<<prtconf:sep(58):persist(1404743142)>>>
29 # System Model: IBM,8231-E2D
30 # Machine Serial Number: 06AAB2T
31 # Processor Type: PowerPC_POWER7
32 # Processor Implementation Mode: POWER 7
33 # Processor Version: PV_7_Compat
34 # Number Of Processors: 8
35 # Processor Clock Speed: 4284 MHz
38 # LPAR Info: 1 wiaix001
39 # Memory Size: 257792 MB
40 # Good Memory Size: 257792 MB
41 # Platform Firmware level: AL770_076
42 # Firmware Version: IBM,AL770_076
43 # Console Login: enable
47 # Note: this is only the header. Much more stuff follows, but is currently
51 def parse_prtconf(info
):
57 if line
[0].startswith("========="):
58 break # ignore the rest of the output currently
66 def _split_vendor(string
):
67 if string
.upper().startswith("IBM"):
68 return "IBM", string
[3:].lstrip('., -/')
72 def inv_prtconf(info
, inventory_tree
):
73 parsed
= parse_prtconf(info
)
75 cpu_dict
= inventory_tree
.get_dict("hardware.cpu.")
76 sys_dict
= inventory_tree
.get_dict("hardware.system.")
77 mem_dict
= inventory_tree
.get_dict("hardware.memory.")
78 fmw_dict
= inventory_tree
.get_dict("software.firmware.")
80 cpu_type
= parsed
.get("CPU Type")
81 if cpu_type
is not None:
82 cpu_dict
["arch"] = "ppc64" if cpu_type
== "64-bit" else "ppc"
84 kernel_type
= parsed
.get("Kernel Type")
85 if kernel_type
is not None:
86 os_dict
= inventory_tree
.get_dict("software.os.")
87 os_dict
["arch"] = "ppc64" if kernel_type
== "64-bit" else "ppc"
89 proc_type
= parsed
.get("Processor Type")
90 if proc_type
is not None:
91 cpu_dict
["model"] = proc_type
93 proc_impl_mode
= parsed
.get("Processor Implementation Mode")
94 if proc_impl_mode
is not None:
95 cpu_dict
["implementation_mode"] = proc_impl_mode
97 max_speed
= parsed
.get("Processor Clock Speed")
98 if max_speed
is not None:
99 cpu_dict
["max_speed"] = float(max_speed
.split()[0]) * 1000 * 1000
101 num_cpu
= parsed
.get("Number Of Processors")
102 if num_cpu
is not None:
103 cpu_dict
.setdefault("cpus", int(num_cpu
))
105 fw_version
= parsed
.get("Firmware Version")
106 if fw_version
is not None:
107 vendor
, fmw_dict
["version"] = _split_vendor(fw_version
)
109 fmw_dict
["vendor"] = vendor
111 fw_platform_level
= parsed
.get("Platform Firmware level")
112 if fw_platform_level
is not None:
113 fmw_dict
["platform_level"] = fw_platform_level
115 serial
= parsed
.get("Machine Serial Number")
116 if serial
is not None:
117 sys_dict
["serial"] = serial
119 model
= parsed
.get("System Model")
120 if model
is not None:
121 manufacturer
, sys_dict
["product"] = _split_vendor(model
)
123 sys_dict
["manufacturer"] = manufacturer
125 ram
= parsed
.get("Memory Size")
127 mem_dict
["total_ram_usable"] = int(ram
.split()[0]) * 1024 * 1024
129 swap
= parsed
.get("Total Paging Space")
131 mem_dict
["total_swap"] = int(swap
.replace("MB", "")) * 1024 * 1024
134 inv_info
['prtconf'] = {
135 "inv_function": inv_prtconf
,