Module: check_mk
Branch: master
Commit: 840785f476704aaeceb6d090080d0973e28ef3d9
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=840785f476704a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Jun 23 11:50:18 2011 +0200
vbox_guest: handle case where VBoxControl fails
---
agents/check_mk_agent.linux | 1 +
checks/vbox_guest | 28 ++--------------------------
2 files changed, 3 insertions(+), 26 deletions(-)
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index a0777e5..d11c237 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -291,6 +291,7 @@ fi
echo '<<<vbox_guest>>>'
if which VBoxControl > /dev/null 2>&1 ; then
VBoxControl -nologo guestproperty enumerate | cut -d, -f1,2
+ [ ${PIPESTATUS[0]} = 0 ] || echo "ERROR"
fi
diff --git a/checks/vbox_guest b/checks/vbox_guest
index 065522e..5fbcd19 100644
--- a/checks/vbox_guest
+++ b/checks/vbox_guest
@@ -1,35 +1,11 @@
#!/usr/bin/python
-# -*- encoding: utf-8; py-indent-offset: 4 -*-
-# +------------------------------------------------------------------+
-# | ____ _ _ __ __ _ __ |
-# | / ___| |__ ___ ___| | __ | \/ | |/ / |
-# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
-# | | |___| | | | __/ (__| < | | | | . \ |
-# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
-# | |
-# | Copyright Mathias Kettner 2010 mk(a)mathias-kettner.de |
-# +------------------------------------------------------------------+
-#
-# This file is part of Check_MK.
-# The official homepage is at http://mathias-kettner.de/check_mk.
-#
-# check_mk is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation in version 2. check_mk is distributed
-# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
-# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE. See the GNU General Public License for more de-
-# ails. You should have received a copy of the GNU General Public
-# License along with GNU Make; see the file COPYING. If not, write
-# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
-# Boston, MA 02110-1301 USA.
-
-#!/usr/bin/python
def vbox_guest_make_dict(info):
return dict([(l[1].split('/',2)[2].rstrip(','), l[3]) for l in info])
def check_vbox_guest(item, _no_params, info):
+ if len(info) == 1 and info[0][0] == "ERROR":
+ return (3, "UNKNOWN - Error running VBoxControl guestproperty enumerate")
try:
d = vbox_guest_make_dict(info)
except:
Module: check_mk
Branch: master
Commit: 4401b23fdc69744446b59ea29a01433cf4e4821a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4401b23fdc6974…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Jun 23 11:42:58 2011 +0200
vbox_guest: fix agent output
---
agents/check_mk_agent.linux | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 6e4bbd2..a0777e5 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -289,7 +289,7 @@ fi
# check would not be executed in case no guest additions are installed.
# And that is something the check wants to detect
echo '<<<vbox_guest>>>'
-if which VBoxControl ; then
+if which VBoxControl > /dev/null 2>&1 ; then
VBoxControl -nologo guestproperty enumerate | cut -d, -f1,2
fi
Module: check_mk
Branch: master
Commit: 6abfb879f99a6fac29330038c3b58d24af10d9f3
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6abfb879f99a6f…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Jun 23 11:37:06 2011 +0200
vbox_guest: new check for checking guest additions in VBox hosts
---
ChangeLog | 1 +
agents/check_mk_agent.linux | 9 ++++++
checkman/vbox_guest | 23 ++++++++++++++++
checks/vbox_guest | 59 +++++++++++++++++++++++++++++++++++++++++++
4 files changed, 92 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 08aaceb..abded47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,7 @@
also be lists of allowed states.
* lnx_if: treat interfaces without information from ethtool as
softwareLoopback interface. The will not be found by inventory now.
+ * vbox_guest: new check for checking guest additions of Linux virtual box hosts
Multisite:
* FIX: make non-Ascii characters in services names work again
diff --git a/agents/check_mk_agent.linux b/agents/check_mk_agent.linux
index 445cbbf..6e4bbd2 100755
--- a/agents/check_mk_agent.linux
+++ b/agents/check_mk_agent.linux
@@ -285,6 +285,15 @@ if which vcbVmName > /dev/null 2>&1 ; then
vcbVmName -s any
fi
+# VirtualBox Guests. Section must always been output. Otherwise the
+# check would not be executed in case no guest additions are installed.
+# And that is something the check wants to detect
+echo '<<<vbox_guest>>>'
+if which VBoxControl ; then
+ VBoxControl -nologo guestproperty enumerate | cut -d, -f1,2
+fi
+
+
if which ntpq > /dev/null 2>&1 ; then
echo '<<<ntp>>>'
# remote heading, make first column space separated
diff --git a/checkman/vbox_guest b/checkman/vbox_guest
new file mode 100644
index 0000000..6db654e
--- /dev/null
+++ b/checkman/vbox_guest
@@ -0,0 +1,23 @@
+title: Check version of VirtualBox guest additions in Linux guests
+agents: linux
+author: Mathias Kettner <mk(a)mathias-kettner.de>
+license: GPL
+distribution: check_mk
+description:
+ This check uses {VBoxControl} to query to version und revision of the
+ guest additions installed in a VirtualBox Linux guest. If no guest additions
+ are installed at all, the check will get critical. if the version and
+ revision of the guest additions do not match the version and revision
+ of the virtual box host, the check will warn.
+
+inventory:
+ One check will be created on each Linux VBox host having guest
+ additions installed(!). If you want to force the check on {all}
+ of your Linux guests, you need to configure explicit checks using
+ {checks=}.
+
+examples:
+ # Force this check on all hosts with the tags {vboxguest} and {linux}.
+ checks += [
+ ( ["vboxguest", "linux"], ALL_HOSTS, "vbox_guest", None, None ),
+ ]
diff --git a/checks/vbox_guest b/checks/vbox_guest
new file mode 100644
index 0000000..065522e
--- /dev/null
+++ b/checks/vbox_guest
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2010 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+#!/usr/bin/python
+
+def vbox_guest_make_dict(info):
+ return dict([(l[1].split('/',2)[2].rstrip(','), l[3]) for l in info])
+
+def check_vbox_guest(item, _no_params, info):
+ try:
+ d = vbox_guest_make_dict(info)
+ except:
+ d = {}
+
+ if len(d) == 0:
+ return (2, "CRIT - No guest additions installed")
+
+ version = d.get('GuestAdd/Version')
+ revision = d.get('GuestAdd/Revision')
+ if not version or not version[0].isdigit():
+ return (3, "UNKNOWN - No guest addition version available")
+ infotext = " - version: %s, revision: %s" % (version, revision)
+
+ host_version = d['HostInfo/VBoxVer']
+ host_revision = d['HostInfo/VBoxRev']
+ if (host_version, host_revision) != (version, revision):
+ return (1, "WARN" + infotext + ", Host has %s/%s" % (host_version, host_revision))
+ else:
+ return (0, "OK" + infotext)
+
+def inventory_vbox_guest(checktype, info):
+ if len(info) > 0:
+ return [(None, None)]
+
+check_info["vbox_guest"] = ( check_vbox_guest, "VBox Guest Additions", 0, inventory_vbox_guest)
+