Module: check_mk
Branch: master
Commit: 4c2fb8af2e987f2265d2d66d483142467fb3990d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4c2fb8af2e987f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 26 13:14:50 2016 +0100
#2959 FIX apt: Made check more robust against invalid agent data
---
.werks/2959 | 9 +++++++++
ChangeLog | 1 +
checks/apt | 13 ++++++++++++-
3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/.werks/2959 b/.werks/2959
new file mode 100644
index 0000000..6eef615
--- /dev/null
+++ b/.werks/2959
@@ -0,0 +1,9 @@
+Title: apt: Made check more robust against invalid agent data
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1453810466
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 941fe1d..40c6fd6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -218,6 +218,7 @@
* 2939 FIX: winperf_phydisk: fixed permanent stall state if windows reports several
disks with the same drive letter...
* 2957 FIX: Renamed Lotus Domino Task Inventory rule to Lotus Domino Task Discovery
* 2958 FIX: domino_tasks: Fixed broken discovery and check
+ * 2959 FIX: apt: Made check more robust against invalid agent data
Multisite:
* 2684 Added icons for downloading agent data / walks of hosts...
diff --git a/checks/apt b/checks/apt
index 3dc2da7..3358669 100644
--- a/checks/apt
+++ b/checks/apt
@@ -44,10 +44,21 @@ factory_settings["apt_default_levels"] = {
"security" : 2,
}
+# Check that the apt section is in valid format of mk_apt plugin and not
+# from the apt agent plugin which can be found on the Check_MK exchange.
+def apt_valid_info(info):
+ return info and len(info[0]) == 1 and len(info[0][0].split(None, 3)) == 4
+
+
def inventory_apt(info):
- yield None, {}
+ if apt_valid_info(info):
+ yield None, {}
+
def check_apt(_no_item, params, info):
+ if not apt_valid_info(info):
+ return
+
sec_regex = regex("^[^\\(]*\\(.*
(Debian-Security:|Ubuntu:[^/]*/[^-]*-security)")
updates = []
sec_updates = []