Module: check_mk
Branch: master
Commit: 0d2e80ac28d9c448d5b3c52ad7a4020a4bc97f5d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0d2e80ac28d9c4…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sun Oct 13 00:53:45 2013 +0200
bulk inventory: display percentage in progress bar
---
ChangeLog | 2 ++
web/htdocs/js/wato.js | 8 +++++++-
web/htdocs/wato.py | 5 +++--
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5e0d080..521484e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
WATO:
* You can now have site-specific global settings when using
distributed WATO (available in the "Distributed Monitoring")
+ * bulk inventory: display percentage in progress bar
+ * FIX: correct display of number of hosts in bulk inventory
1.2.3i4:
Core:
diff --git a/web/htdocs/js/wato.js b/web/htdocs/js/wato.js
index 16a8e23..182ee4c 100644
--- a/web/htdocs/js/wato.js
+++ b/web/htdocs/js/wato.js
@@ -435,6 +435,7 @@ function progress_clean_log() {
function progress_scheduler(mode, url_prefix, timeout, items, end_url, success_stats,
fail_stats, term_url, finished_txt) {
// Initialize
if (progress_items === null) {
+ total_num_items = items.length;
progress_items = items;
failed_items = Array();
progress_total_num = items.length;
@@ -455,10 +456,15 @@ function progress_scheduler(mode, url_prefix, timeout, items,
end_url, success_s
// Regular processing when not paused and not already running
if (!progress_paused && !progress_running) {
if (progress_items.length > 0) {
+ num_items_left = progress_items.length;
+ perc = Math.round(100 - (100.0 * num_items_left / total_num_items));
+ // title = progress_items.length + " Items, " +
progress_success_stats.length + " Stats, " + progress_fail_stats.length + "
Failed.";
+ title = perc + "%";
// Progressing
progress_running = true;
// Remove leading pipe signs (when having no folder set)
- update_progress_title(progress_items[0].replace(/^\|*/g,
'').substr(0, 60));
+ // update_progress_title(percentage + "%");
+ update_progress_title(title);
get_url(url_prefix + '&_transid=-1&_item=' +
escape(progress_items[0]),
progress_handle_response, // regular handler (http code 200)
[ mode, progress_items[0] ], // data to hand over to handlers
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index b21531b..e372316 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2606,6 +2606,7 @@ def mode_bulk_inventory(phase):
try:
site_id, folderpath, hostnamesstring =
html.var("_item").split("|")
hostnames = hostnamesstring.split(";")
+ num_hosts = len(hostnames)
folder = g_folders[folderpath]
load_hosts(folder)
arguments = [how,] + hostnames
@@ -2613,7 +2614,7 @@ def mode_bulk_inventory(phase):
arguments = [ "--cache" ] + arguments
counts, failed_hosts = check_mk_automation(site_id,
"inventory", arguments)
#counts = ( 1, 2, 3, 4 )
- result = repr([ 'continue', 1, 0 ] + list(counts)) +
"\n"
+ result = repr([ 'continue', num_hosts, 0 ] + list(counts)) +
"\n"
for hostname in hostnames:
host = folder[".hosts"][hostname]
if hostname in failed_hosts:
@@ -2631,7 +2632,7 @@ def mode_bulk_inventory(phase):
save_hosts(folder) # Could be optimized, but difficult here
except Exception, e:
- result = repr([ 'failed', 1, 1, 0, 0, 0, 0, ]) + "\n"
+ result = repr([ 'failed', num_hosts, num_hosts, 0, 0, 0, 0, ]) +
"\n"
if site_id:
msg = _("Error during inventory of %s on site %s<div
class=exc>%s</div") % \
(", ".join(hostnames), site_id, e)