Module: check_mk
Branch: master
Commit: 14a9eaf1effa740dd15e4f7a80b960da826ac427
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=14a9eaf1effa74…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Wed Mar 9 14:44:12 2016 +0100
3280 FIX Fixed too often executed network scans
The network scan interval was not handled correctly and network scan of a folder
could be executed multiple time in parallel if running more than 1 minute.
---
.werks/3280 | 11 +++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 20 +++++++++++---------
web/plugins/wato/builtin_attributes.py | 3 +++
4 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/.werks/3280 b/.werks/3280
new file mode 100644
index 0000000..32ad0c2
--- /dev/null
+++ b/.werks/3280
@@ -0,0 +1,11 @@
+Title: Fixed too often executed network scans
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457530987
+
+The network scan interval was not handled correctly and network scan of a folder
+could be executed multiple time in parallel if running more than 1 minute.
diff --git a/ChangeLog b/ChangeLog
index aa12e38..e95622a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -111,6 +111,7 @@
* 3231 FIX: Not showing network scan properties in host search form anymore
* 3086 FIX: fixed incorrect host list when one wato folder was a substring of
another...
* 3091 FIX: fixed failure to rename hosts in raw edition...
+ * 3280 FIX: Fixed too often executed network scans...
Notifications:
* 3263 Notifications: allow users to restrict by their contact groups...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 8ad268c..e8bd23a 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -14974,11 +14974,16 @@ def execute_network_scan_job():
result = {
"start" : time.time(),
- "end" : None,
+ "end" : True, # means currently running
"state" : None,
- "output" : "",
+ "output" : "The scan is currently running.",
}
+ # Mark the scan in progress: Is important in case the request takes longer than
+ # the interval of the cron job (1 minute). Otherwise the scan might be started
+ # a second time before the first one finished.
+ save_network_scan_result(folder, result)
+
try:
if config.site_is_local(folder.site_id()):
found = do_network_scan(folder)
@@ -15017,7 +15022,7 @@ def find_folder_to_scan():
folder_to_scan = None
for folder_path, folder in Folder.all_folders().items():
scheduled_time = folder.next_network_scan_at()
- if scheduled_time != None:
+ if scheduled_time != None and scheduled_time < time.time():
if folder_to_scan == None:
folder_to_scan = folder
elif folder_to_scan.next_network_scan_at() >
folder.next_network_scan_at():
@@ -15163,7 +15168,7 @@ def ping_worker(addresses, hosts):
while True:
try:
ipaddress = addresses.pop()
- except IndexError:
+ except KeyError:
break
if ping(ipaddress):
@@ -15194,11 +15199,8 @@ def scan_ip_addresses(folder, ip_addresses):
t.start()
# Now wait for all workers to finish
- while threads:
- for t in threads:
- if not t.isAlive():
- threads.remove(t)
- time.sleep(1)
+ for t in threads:
+ t.join()
return found_hosts
diff --git a/web/plugins/wato/builtin_attributes.py
b/web/plugins/wato/builtin_attributes.py
index 75f2100..8657c19 100644
--- a/web/plugins/wato/builtin_attributes.py
+++ b/web/plugins/wato/builtin_attributes.py
@@ -261,6 +261,9 @@ class NetworkScanResultAttribute(ValueSpecAttribute):
FixedValue(None,
totext = _("No scan has finished yet."),
),
+ FixedValue(True,
+ totext = "", # currently running
+ ),
AbsoluteDate(
include_time = True,
default_value = 0,