From b0b3e280171656dabd50eade27f90d024c024a7d Mon Sep 17 00:00:00 2001 From: evandro-portugal Date: Wed, 20 Jan 2016 15:17:54 -0200 Subject: [PATCH] Add select events option Added a option to select which events should be displayed, thus giving the ability to have a trigger history, showing all the problem events as well as the OK events. --- plugins/datasource-zabbix/zabbixAPIWrapper.js | 6 ++++-- plugins/panel-triggers/editor.html | 10 ++++++++++ plugins/panel-triggers/module.js | 10 +++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/plugins/datasource-zabbix/zabbixAPIWrapper.js b/plugins/datasource-zabbix/zabbixAPIWrapper.js index 9fe2ff2..c406fa5 100644 --- a/plugins/datasource-zabbix/zabbixAPIWrapper.js +++ b/plugins/datasource-zabbix/zabbixAPIWrapper.js @@ -574,7 +574,7 @@ function (angular, _) { return this.performZabbixAPIRequest('service.getsla', params); }; - p.getTriggers = function(limit, sortfield, groupids, hostids, applicationids, name) { + p.getTriggers = function(limit, sortfield, groupids, hostids, applicationids, name, showevents) { var params = { output: 'extend', expandDescription: true, @@ -582,7 +582,7 @@ function (angular, _) { monitored: true, //only_true: true, filter: { - value: 1 + value: [0,1] }, search : { description: name @@ -600,6 +600,8 @@ function (angular, _) { params.sortfield = sortfield; } + params.filter.value = showevents; + return this.performZabbixAPIRequest('trigger.get', params); }; diff --git a/plugins/panel-triggers/editor.html b/plugins/panel-triggers/editor.html index ac49831..c7695fe 100644 --- a/plugins/panel-triggers/editor.html +++ b/plugins/panel-triggers/editor.html @@ -112,6 +112,16 @@ ng-change="get_data()"> +
  • + Show events +
  • +
  • + +
  • diff --git a/plugins/panel-triggers/module.js b/plugins/panel-triggers/module.js index 0894f1b..27dd7c1 100644 --- a/plugins/panel-triggers/module.js +++ b/plugins/panel-triggers/module.js @@ -48,6 +48,12 @@ function (angular, app, _, $, config, PanelMeta) { { text: 'severity', value: 'priority' } ]; + $scope.showEventsFields = [ + { text: 'all events', value: [0,1] }, + { text: 'Ok events', value: 0 }, + { text: 'Problem events', value: 1 } + ]; + var grafanaDefaultSeverity = [ { priority: 0, severity: 'Not classified', color: '#B7DBAB', show: true }, { priority: 1, severity: 'Information', color: '#82B5D8', show: true }, @@ -72,6 +78,7 @@ function (angular, app, _, $, config, PanelMeta) { limit: 10, showTriggers: 'all triggers', sortTriggersBy: { text: 'last change', value: 'lastchange' }, + showEvents: { text: 'Problem events', value: '1' }, triggerSeverity: grafanaDefaultSeverity }; @@ -125,7 +132,8 @@ function (angular, app, _, $, config, PanelMeta) { groupid, hostid, applicationids, - $scope.panel.triggers.name) + $scope.panel.triggers.name, + $scope.panel.showEvents.value) .then(function(triggers) { var promises = _.map(triggers, function (trigger) { var lastchange = new Date(trigger.lastchange * 1000);