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] 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 @@ + +