Refactored snapin server_time to new snapin API
[check_mk.git] / checks / citrix_hostsystem
blob85c23b08c89eeb048b5e24559a050c412a6bc43e
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
32 # Note(1): The pool name is the same for all VMs on one host system
33 # Note(2): for the same host and vm this section can appear
34 # several times (with the same content).
35 def parse_citrix_hostsystem(info):
36 parsed = { "vms" : [], "pool" : "" }
37 for line in info:
38 if line[0] == "VMName":
39 vm = " ".join(line[1:])
40 if vm not in parsed["vms"]:
41 parsed["vms"].append(vm)
42 elif line[0] == "CitrixPoolName":
43 pool = " ".join(line[1:])
44 if not parsed["pool"]:
45 parsed["pool"] = pool
46 return parsed
49 # .--Host VMs------------------------------------------------------------.
50 # | _ _ _ __ ____ __ |
51 # | | | | | ___ ___| |_ \ \ / / \/ |___ |
52 # | | |_| |/ _ \/ __| __| \ \ / /| |\/| / __| |
53 # | | _ | (_) \__ \ |_ \ V / | | | \__ \ |
54 # | |_| |_|\___/|___/\__| \_/ |_| |_|___/ |
55 # | |
56 # '----------------------------------------------------------------------'
58 def inventory_citrix_hostsystem_vms(parsed):
59 if parsed["vms"]:
60 return [ (None, None) ]
63 def check_citrix_hostsystem_vms(_no_item, _no_params, parsed):
64 vmlist = parsed["vms"]
65 return 0, "%d VMs running: %s" % (len(vmlist), ", ".join(vmlist))
68 check_info["citrix_hostsystem.vms"] = {
69 "inventory_function" : inventory_citrix_hostsystem_vms,
70 "check_function" : check_citrix_hostsystem_vms,
71 "service_description" : "Citrix VMs",
75 # .--Host Info-----------------------------------------------------------.
76 # | _ _ _ ___ __ |
77 # | | | | | ___ ___| |_ |_ _|_ __ / _| ___ |
78 # | | |_| |/ _ \/ __| __| | || '_ \| |_ / _ \ |
79 # | | _ | (_) \__ \ |_ | || | | | _| (_) | |
80 # | |_| |_|\___/|___/\__| |___|_| |_|_| \___/ |
81 # | |
82 # '----------------------------------------------------------------------'
84 def inventory_citrix_hostsystem(parsed):
85 if parsed["pool"]:
86 return [ (None, None) ]
89 def check_citrix_hostsystem(_no_item, no_params, parsed):
90 return 0, "Citrix Pool Name: %s" % parsed["pool"]
93 check_info["citrix_hostsystem"] = {
94 "parse_function" : parse_citrix_hostsystem,
95 "inventory_function" : inventory_citrix_hostsystem,
96 "check_function" : check_citrix_hostsystem,
97 "service_description" : "Citrix Host Info",