Module: check_mk
Branch: master
Commit: 82993b2847d9ade676f6de0b2b0c06b582e07122
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=82993b2847d9ad…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Jun 25 13:32:47 2014 +0200
FIX Fix HTTP error handling in bulk inventory
If during a bulk inventory some HTTP error occurs (e.g. due to an Apache
restart) then now the failed hosts are exactly being displayed and the
number of failed hosts is correct.
---
.werks/990 | 11 +++++++++++
ChangeLog | 3 +++
web/htdocs/js/wato.js | 45 +++++++++++++++++++++++++++++++--------------
3 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/.werks/990 b/.werks/990
new file mode 100644
index 0000000..2be2da7
--- /dev/null
+++ b/.werks/990
@@ -0,0 +1,11 @@
+Title: Fix HTTP error handling in bulk inventory
+Level: 1
+Component: wato
+Class: fix
+State: unknown
+Version: 1.2.5i5
+Date: 1403695916
+
+If during a bulk inventory some HTTP error occurs (e.g. due to an Apache
+restart) then now the failed hosts are exactly being displayed and the
+number of failed hosts is correct.
diff --git a/ChangeLog b/ChangeLog
index 0aa1bfd..b99d457 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,9 @@
* 0994 FIX: agent plugin smart: fixed syntax error
* 0989 FIX: logwatch.ec: Fix forwarding multiple messages via syslog/TCP...
+ WATO:
+ * 0990 FIX: Fix HTTP error handling in bulk inventory...
+
Livestatus:
* 0988 FIX: livedump: Fix exception in case no contact groups are defined for a
service
diff --git a/web/htdocs/js/wato.js b/web/htdocs/js/wato.js
index 30da50b..37528fb 100644
--- a/web/htdocs/js/wato.js
+++ b/web/htdocs/js/wato.js
@@ -29,7 +29,7 @@
function getElementsByClass(cl) {
var items = new Array();
var elements = document.getElementsByTagName('*');
- for(var i = 0; i < elements.length; i++)
+ for (var i = 0; i < elements.length; i++)
if (elements[i].className == cl)
items.push(elements[i]);
return items;
@@ -260,36 +260,53 @@ function progress_handle_error(data, code) {
progress_handle_response(data, '', code);
}
-function progress_handle_response(data, code, http_code) {
+function progress_handle_response(data, code, http_code)
+{
var mode = data[0];
var item = data[1];
var header = null;
var body = null;
- if(http_code !== undefined) {
+ if (http_code !== undefined) {
// If the request failed report the item as failed
+ // Note: the item is either a plain item (single-item-mode), or
+ // a list of items which are separated with ;. Also it is possible
+ // that additional parameters are prefixed to the item separated
+ // by pipes. The bulk inventory uses that format for doing a couple
+ // of hosts at the same time. So here we detect both variants.
+
+ var parts = data[1].split("|");
+ var last_part = parts[parts.length-1];
+ var items = last_part.split(";");
+ var num_failed = items.length;
+
// - Report failed state
// - Update the total count (item 0 = 1)
// - Update the failed stats
- header = [ 'failed', 1 ];
- for(var i = 1; i <= Math.max.apply(Math, progress_fail_stats); i++) {
- if(progress_fail_stats.indexOf(i) !== -1) {
- header.push(1);
- } else {
+ header = [ 'failed', num_failed ];
+ for (var i = 1; i <= Math.max.apply(Math, progress_fail_stats); i++) {
+ if (progress_fail_stats.indexOf(i) !== -1) {
+ header.push(num_failed);
+ }
+ else {
header.push(0);
}
}
- body = 'Inventory of ' + item + ' failed\n'
- +'<div class=exc><h1>HTTP-Request failed</h1>'
- +'HTTP-Code: ' + http_code + '<br />'
- +'Parameters: ' + data + '</div>\n';
- } else {
+
+ body = '';
+ for (var i=0; i < items.length; i++)
+ {
+ body += items[i] + ' failed: HTTP-Request failed with code ' +
http_code + '<br>';
+ }
+ }
+ else {
// Regular response processing
try {
var header = eval(code.split("\n", 1)[0]);
if (header === null)
alert('Header is null!');
- } catch(err) {
+ }
+ catch(err) {
alert('Invalid response: ' + code);
}