GUI CSS: Removed snapin styles from py modules and added a _snapins.scss for the...
[check_mk.git] / checks / vbox_guest
blob3fecd149c8e5168fb1ac8dac732c8f7cfb83dee2
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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 def vbox_guest_make_dict(info):
29 return dict([(l[1].split('/', 2)[2].rstrip(','), l[3]) for l in info])
32 def check_vbox_guest(_no_item, _no_params, info):
33 if len(info) == 1 and info[0][0] == "ERROR":
34 return (3, "Error running VBoxControl guestproperty enumerate")
35 try:
36 d = vbox_guest_make_dict(info)
37 except:
38 d = {}
40 if len(d) == 0:
41 return (2, "No guest additions installed")
43 version = d.get('GuestAdd/Version')
44 revision = d.get('GuestAdd/Revision')
45 if not version or not version[0].isdigit():
46 return (3, "No guest addition version available")
47 infotext = "version: %s, revision: %s" % (version, revision)
49 host_version = d['HostInfo/VBoxVer']
50 host_revision = d['HostInfo/VBoxRev']
51 if (host_version, host_revision) != (version, revision):
52 return (1, infotext + ", Host has %s/%s" % (host_version, host_revision))
53 return (0, infotext)
56 def inventory_vbox_guest(info):
57 if len(info) > 0:
58 return [(None, None)]
61 check_info["vbox_guest"] = {
62 'check_function': check_vbox_guest,
63 'inventory_function': inventory_vbox_guest,
64 'service_description': 'VBox Guest Additions',
65 'group': 'vm_state',