From b846d0ec28f5ba6b737d8760c28f3f337c00a154 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 20 Nov 2015 23:29:17 +0300 Subject: [PATCH 1/5] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f901771..5fe60de 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/alexanderzobnin/grafana-zabbix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) +##### [Donate](https://www.paypal.me/alexanderzobnin) + ##### See features overview and dashboards examples at Grafana-Zabbix [Live demo](http://play.grafana-zabbix.org) site. ##### Download [latest release](https://github.com/alexanderzobnin/grafana-zabbix/releases/latest) From 2cab3d0de074073052cb00997cd15f0592747d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Fri, 27 Nov 2015 11:31:20 +0100 Subject: [PATCH 2/5] Adapt annotations prototypes to calling convention of 2.5.1 From public/app/plugins/PLUGIN_CHANGES.md: 2.5.1 datasource annotationQuery changed. now single options parameter with: - range - rangeRaw - annotation --- zabbix/datasource.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/zabbix/datasource.js b/zabbix/datasource.js index 447d827..a5fc203 100644 --- a/zabbix/datasource.js +++ b/zabbix/datasource.js @@ -336,24 +336,24 @@ function (angular, _, dateMath) { // Annotations // ///////////////// - ZabbixAPIDatasource.prototype.annotationQuery = function(annotation, rangeUnparsed) { - var from = Math.ceil(dateMath.parse(rangeUnparsed.from) / 1000); - var to = Math.ceil(dateMath.parse(rangeUnparsed.to) / 1000); + ZabbixAPIDatasource.prototype.annotationQuery = function(options) { + var from = Math.ceil(dateMath.parse(options.rangeRaw.from) / 1000); + var to = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000); var self = this; var params = { output: ['triggerid', 'description'], search: { - 'description': annotation.trigger + 'description': options.annotation.trigger }, searchWildcardsEnabled: true, expandDescription: true }; - if (annotation.host) { - params.host = templateSrv.replace(annotation.host); + if (options.annotation.host) { + params.host = templateSrv.replace(options.annotation.host); } - else if (annotation.group) { - params.group = templateSrv.replace(annotation.group); + else if (options.annotation.group) { + params.group = templateSrv.replace(options.annotation.group); } return this.zabbixAPI.performZabbixAPIRequest('trigger.get', params) @@ -369,7 +369,7 @@ function (angular, _, dateMath) { }; // Show problem events only - if (!annotation.showOkEvents) { + if (!options.annotation.showOkEvents) { params.value = 1; } @@ -379,7 +379,7 @@ function (angular, _, dateMath) { _.each(result, function(e) { var formatted_acknowledges = zabbixHelperSrv.formatAcknowledges(e.acknowledges); events.push({ - annotation: annotation, + annotation: options.annotation, time: e.clock * 1000, title: Number(e.value) ? 'Problem' : 'OK', text: objects[e.objectid].description + formatted_acknowledges From 9dac49a3dc6debec9fcf0c40955e5bfd750e9279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Fri, 27 Nov 2015 13:45:21 +0100 Subject: [PATCH 3/5] Option to show hostname in annotation A new checkbox in the annotation configuration form allows to prefix the hostname to the title used in the annotation. This option is relevant for people not stating the hostname in their triggers. Within Zabbix, the hostname would be shown redundantly everywhere, except in notifications. --- zabbix/datasource.js | 12 ++++++++++-- zabbix/partials/annotations.editor.html | 6 ++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/zabbix/datasource.js b/zabbix/datasource.js index a5fc203..ca0008f 100644 --- a/zabbix/datasource.js +++ b/zabbix/datasource.js @@ -365,7 +365,8 @@ function (angular, _, dateMath) { time_from: from, time_till: to, objectids: _.keys(objects), - select_acknowledges: 'extend' + select_acknowledges: 'extend', + selectHosts: 'extend' }; // Show problem events only @@ -376,12 +377,19 @@ function (angular, _, dateMath) { return self.zabbixAPI.performZabbixAPIRequest('event.get', params) .then(function (result) { var events = []; + + var title =''; + if (options.annotation.showHostname) { + title += e.hosts[0]['name'] + ': '; + } + title += Number(e.value) ? 'Problem' : 'OK'; + _.each(result, function(e) { var formatted_acknowledges = zabbixHelperSrv.formatAcknowledges(e.acknowledges); events.push({ annotation: options.annotation, time: e.clock * 1000, - title: Number(e.value) ? 'Problem' : 'OK', + title: title, text: objects[e.objectid].description + formatted_acknowledges }); }); diff --git a/zabbix/partials/annotations.editor.html b/zabbix/partials/annotations.editor.html index 1a95b36..bc7fea0 100644 --- a/zabbix/partials/annotations.editor.html +++ b/zabbix/partials/annotations.editor.html @@ -32,5 +32,11 @@ + + From 46d656d49ea2b4fa4878f696d4666a9facb9ce2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volker=20Fr=C3=B6hlich?= Date: Mon, 30 Nov 2015 14:52:52 +0100 Subject: [PATCH 4/5] Add a severity and acknowledgement filter for annotations Add a severity filter, much like it is present in various places in Zabbix, as well as a filter for the acknowledgement status. This brings the interface closer to what is asked for in https://support.zabbix.com/browse/ZBXNEXT-410 --- zabbix/datasource.js | 14 ++++++++++++-- zabbix/partials/annotations.editor.html | 11 +++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/zabbix/datasource.js b/zabbix/datasource.js index ca0008f..93e81ca 100644 --- a/zabbix/datasource.js +++ b/zabbix/datasource.js @@ -341,8 +341,15 @@ function (angular, _, dateMath) { var to = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000); var self = this; + // Remove events below the chose severity + var severities = []; + for (var i = 5; i >= options.annotation.minseverity; i--) { + severities.push(i); + } var params = { - output: ['triggerid', 'description'], + output: ['triggerid', 'description', 'priority'], + preservekeys: 1, + filter: { 'priority': severities }, search: { 'description': options.annotation.trigger }, @@ -359,7 +366,7 @@ function (angular, _, dateMath) { return this.zabbixAPI.performZabbixAPIRequest('trigger.get', params) .then(function (result) { if(result) { - var objects = _.indexBy(result, 'triggerid'); + var objects = result; var params = { output: 'extend', time_from: from, @@ -385,6 +392,9 @@ function (angular, _, dateMath) { title += Number(e.value) ? 'Problem' : 'OK'; _.each(result, function(e) { + // Hide acknowledged events + if (e.acknowledges.length > 0 && options.annotation.showAcknowledged) { return; } + var formatted_acknowledges = zabbixHelperSrv.formatAcknowledges(e.acknowledges); events.push({ annotation: options.annotation, diff --git a/zabbix/partials/annotations.editor.html b/zabbix/partials/annotations.editor.html index bc7fea0..7dc8fb8 100644 --- a/zabbix/partials/annotations.editor.html +++ b/zabbix/partials/annotations.editor.html @@ -21,6 +21,11 @@ +
+ + +
@@ -38,5 +43,11 @@ + +
From 6118147623d6a25de0e9d25718059b8bbbad4adf Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Mon, 28 Dec 2015 22:28:36 +0300 Subject: [PATCH 5/5] Fixed "e is undefined" error. --- zabbix/datasource.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/zabbix/datasource.js b/zabbix/datasource.js index 93e81ca..019d63c 100644 --- a/zabbix/datasource.js +++ b/zabbix/datasource.js @@ -385,13 +385,13 @@ function (angular, _, dateMath) { .then(function (result) { var events = []; - var title =''; - if (options.annotation.showHostname) { - title += e.hosts[0]['name'] + ': '; - } - title += Number(e.value) ? 'Problem' : 'OK'; - _.each(result, function(e) { + var title =''; + if (options.annotation.showHostname) { + title += e.hosts[0]['name'] + ': '; + } + title += Number(e.value) ? 'Problem' : 'OK'; + // Hide acknowledged events if (e.acknowledges.length > 0 && options.annotation.showAcknowledged) { return; }