Cleanup config.nodes_of
[check_mk.git] / checks / citrix_hostsystem
blob96040f500acd65dfa6420dd232d85266cae86be4
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2015 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 # <<<citrix_hostsystem>>>
29 # VMName rz1css01
30 # CitrixPoolName RZ1XenPool01 - Cisco UCS
33 # Note(1): The pool name is the same for all VMs on one host system
34 # Note(2): for the same host and vm this section can appear
35 # several times (with the same content).
36 def parse_citrix_hostsystem(info):
37 parsed = {"vms": [], "pool": ""}
38 for line in info:
39 if line[0] == "VMName":
40 vm = " ".join(line[1:])
41 if vm not in parsed["vms"]:
42 parsed["vms"].append(vm)
43 elif line[0] == "CitrixPoolName":
44 pool = " ".join(line[1:])
45 if not parsed["pool"]:
46 parsed["pool"] = pool
47 return parsed
50 # .--Host VMs------------------------------------------------------------.
51 # | _ _ _ __ ____ __ |
52 # | | | | | ___ ___| |_ \ \ / / \/ |___ |
53 # | | |_| |/ _ \/ __| __| \ \ / /| |\/| / __| |
54 # | | _ | (_) \__ \ |_ \ V / | | | \__ \ |
55 # | |_| |_|\___/|___/\__| \_/ |_| |_|___/ |
56 # | |
57 # '----------------------------------------------------------------------'
60 def inventory_citrix_hostsystem_vms(parsed):
61 if parsed["vms"]:
62 return [(None, None)]
65 def check_citrix_hostsystem_vms(_no_item, _no_params, parsed):
66 vmlist = parsed["vms"]
67 return 0, "%d VMs running: %s" % (len(vmlist), ", ".join(vmlist))
70 check_info["citrix_hostsystem.vms"] = {
71 "inventory_function": inventory_citrix_hostsystem_vms,
72 "check_function": check_citrix_hostsystem_vms,
73 "service_description": "Citrix VMs",
77 # .--Host Info-----------------------------------------------------------.
78 # | _ _ _ ___ __ |
79 # | | | | | ___ ___| |_ |_ _|_ __ / _| ___ |
80 # | | |_| |/ _ \/ __| __| | || '_ \| |_ / _ \ |
81 # | | _ | (_) \__ \ |_ | || | | | _| (_) | |
82 # | |_| |_|\___/|___/\__| |___|_| |_|_| \___/ |
83 # | |
84 # '----------------------------------------------------------------------'
87 def inventory_citrix_hostsystem(parsed):
88 if parsed["pool"]:
89 return [(None, None)]
92 def check_citrix_hostsystem(_no_item, no_params, parsed):
93 return 0, "Citrix Pool Name: %s" % parsed["pool"]
96 check_info["citrix_hostsystem"] = {
97 "parse_function": parse_citrix_hostsystem,
98 "inventory_function": inventory_citrix_hostsystem,
99 "check_function": check_citrix_hostsystem,
100 "service_description": "Citrix Host Info",