Module: check_mk
Branch: master
Commit: 4219e778b6f17a1eac51b5866ad8f97b539bc183
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4219e778b6f17a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Oct 14 20:02:37 2013 +0200
inventory check of SNMP devices now does scan per default
Previously the inventory check for SNMP devices just detected
new items for already configured checks. Now it does the usual
SNMP scan that is also done during cmk -I. This can be switched
off the the old beviour with inventory_check_do_scan = False
and also via WATO
---
ChangeLog | 1 +
modules/check_mk.py | 16 ++++++++++++++--
web/plugins/wato/check_mk_configuration.py | 11 +++++++++++
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 332de69..46ba14f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
* FIX: continue inventory, if one check does not support it
* FIX: fix configuration of explicit SNMP community, allow unicode
* FIX: avoid invalid cache of 2nd and up hosts in bulk inventory
+ * inventory check of SNMP devices now does scan per default (configurable)
Multisite:
* Speed-O-Meter: now measure only service checks. Host checks
diff --git a/modules/check_mk.py b/modules/check_mk.py
index ff09864..8211c1c 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -243,6 +243,7 @@ explicit_snmp_communities = {} # override the rule based
configuration
# Inventory and inventory checks
inventory_check_interval = None # Nagios intervals (4h = 240)
inventory_check_severity = 1 # warning
+inventory_check_do_scan = True # include SNMP scan for SNMP devices
inventory_max_cachefile_age = 120 # secs.
always_cleanup_autochecks = True
@@ -2713,13 +2714,24 @@ def check_inventory(hostname):
is_snmp = is_snmp_host(hostname)
is_tcp = is_tcp_host(hostname)
check_table = get_check_table(hostname)
+ if is_snmp and inventory_check_do_scan:
+ try:
+ ipaddress = lookup_ipaddress(hostname)
+ snmp_checktypes = snmp_scan(hostname, ipaddress)
+ except:
+ if opt_debug:
+ raise
+ pass
+ else:
+ snmp_checktypes = []
+
hosts_checktypes = set([ ct for (ct, item), params in check_table.items() ])
try:
for ct in inventorable_checktypes("all"):
if check_uses_snmp(ct) and not is_snmp:
continue # Skip SNMP checks on non-SNMP hosts
- elif check_uses_snmp(ct) and ct not in hosts_checktypes:
- continue # Do not look for new SNMP services (maybe change in future)
+ elif check_uses_snmp(ct) and ct not in hosts_checktypes and ct not in
snmp_checktypes:
+ continue # Only try positive scans and existing types
elif not check_uses_snmp(ct) and not is_tcp:
continue # Skip TCP checks on non-TCP hosts
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index 88b360a..057f89e 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -1013,6 +1013,17 @@ register_configvar(group,
(3, _("Unknown") ),
]))
+register_configvar(group,
+ "inventory_check_do_scan",
+ DropdownChoice(
+ title = _("Inventory check for SNMP devices"),
+ choices = [
+ ( True, _("Perform full SNMP scan always, detect new check types")
),
+ ( False, _("Just rely on existing check files, detect new items
only") )
+ ]
+ ))
+
+
_if_portstate_choices = [
( '1', 'up(1)'),
( '2', 'down(2)'),