From f922c2fe6ff1fc932a4aa6aec5ec3fa42169880a Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 1 Apr 2016 12:27:04 +0300 Subject: [PATCH 1/2] Fixed migration issue with 'All' host or item value. --- src/datasource-zabbix/migrations.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/datasource-zabbix/migrations.js b/src/datasource-zabbix/migrations.js index 0bbd737..9429211 100644 --- a/src/datasource-zabbix/migrations.js +++ b/src/datasource-zabbix/migrations.js @@ -34,5 +34,9 @@ export function migrate(target) { } function convertToRegex(str) { - return '/' + str + '/'; + if (str) { + return '/' + str + '/'; + } else { + return '/.*/'; + } } From 1b7abd5d376094d7dbc34d5836495e0bed1d97e6 Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 1 Apr 2016 12:35:39 +0300 Subject: [PATCH 2/2] Improved annotations fetching (use dashboard time interval for triggers getting). --- src/datasource-zabbix/datasource.js | 9 +++++---- src/datasource-zabbix/zabbixAPI.service.js | 7 ++++++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/datasource-zabbix/datasource.js b/src/datasource-zabbix/datasource.js index faeda51..dbb1241 100644 --- a/src/datasource-zabbix/datasource.js +++ b/src/datasource-zabbix/datasource.js @@ -337,8 +337,8 @@ export class ZabbixAPIDatasource { ///////////////// annotationQuery(options) { - var from = Math.ceil(dateMath.parse(options.rangeRaw.from) / 1000); - var to = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000); + var timeFrom = Math.ceil(dateMath.parse(options.rangeRaw.from) / 1000); + var timeTo = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000); var annotation = options.annotation; var self = this; var showOkEvents = annotation.showOkEvents ? [0, 1] : 1; @@ -353,7 +353,8 @@ export class ZabbixAPIDatasource { return self.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, - showTriggers) + showTriggers, + timeFrom, timeTo) .then(function(triggers) { // Filter triggers by description @@ -373,7 +374,7 @@ export class ZabbixAPIDatasource { }); var objectids = _.map(triggers, 'triggerid'); - return self.zabbixAPI.getEvents(objectids, from, to, showOkEvents) + return self.zabbixAPI.getEvents(objectids, timeFrom, timeTo, showOkEvents) .then(function (events) { var indexedTriggers = _.indexBy(triggers, 'triggerid'); diff --git a/src/datasource-zabbix/zabbixAPI.service.js b/src/datasource-zabbix/zabbixAPI.service.js index beb4eec..e85045b 100644 --- a/src/datasource-zabbix/zabbixAPI.service.js +++ b/src/datasource-zabbix/zabbixAPI.service.js @@ -298,7 +298,7 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) { return this.request('service.getsla', params); } - getTriggers(groupids, hostids, applicationids, showTriggers) { + getTriggers(groupids, hostids, applicationids, showTriggers, timeFrom, timeTo) { var params = { output: 'extend', groupids: groupids, @@ -322,6 +322,11 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) { params.filter.value = showTriggers; } + if (timeFrom || timeTo) { + params.lastChangeSince = timeFrom; + params.lastChangeTill = timeTo; + } + return this.request('trigger.get', params); }