Module: check_mk
Branch: master
Commit: e63c4fafd64447c77e00f5bab365165fc4ee13e1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e63c4fafd64447…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jan 23 12:32:21 2015 +0100
cmk -I for yet un-discovered hosts forces SNMP scan
---
modules/discovery.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/modules/discovery.py b/modules/discovery.py
index 58fccfe..ffd5eb0 100644
--- a/modules/discovery.py
+++ b/modules/discovery.py
@@ -74,7 +74,11 @@ def do_discovery(hostnames, check_types, only_new):
def do_discovery_for(hostname, check_types, only_new, use_caches):
- new_items = discover_services(hostname, check_types, use_caches, not use_caches)
+ # Usually we disable SNMP scan if cmk -I is used without a list of
+ # explicity hosts. But for host that have never been service-discovered
+ # yet (do not have autochecks), we enable SNMP scan.
+ do_snmp_scan = not use_caches or not has_autochecks(hostname)
+ new_items = discover_services(hostname, check_types, use_caches, do_snmp_scan)
if not check_types and not only_new:
old_items = [] # do not even read old file
else:
@@ -811,6 +815,10 @@ def parse_autochecks_file(hostname):
return table
+def has_autochecks(hostname):
+ return os.path.exists(autochecksdir + "/" + hostname + ".mk")
+
+
def save_autochecks_file(hostname, items):
if not os.path.exists(autochecksdir):
os.makedirs(autochecksdir)