diff --git a/plugins/datasource-zabbix/datasource.js b/plugins/datasource-zabbix/datasource.js index fffbd97..0691a80 100644 --- a/plugins/datasource-zabbix/datasource.js +++ b/plugins/datasource-zabbix/datasource.js @@ -151,7 +151,6 @@ function (angular, _, dateMath) { return []; } } - console.log(hosts); // Find items belongs to selected hosts items = _.filter(self.zabbixCache.getItems(), function (itemObj) { @@ -205,9 +204,11 @@ function (angular, _, dateMath) { return []; } } - console.log(items); - //items = _.flatten(items); + // Set host as host name for each item + items = _.each(items, function (itemObj) { + itemObj.host = _.find(hosts, {'hostid': itemObj.hostid}).name; + }); // Use alias only for single metric, otherwise use item names var alias; @@ -217,10 +218,12 @@ function (angular, _, dateMath) { var history; if ((from < useTrendsFrom) && self.trends) { + // Use trends var points = target.downsampleFunction ? target.downsampleFunction.value : "avg"; history = self.zabbixAPI.getTrends(items, from, to) .then(_.bind(zabbixHelperSrv.handleTrendResponse, zabbixHelperSrv, items, alias, target.scale, points)); } else { + // Use history history = self.zabbixAPI.getHistory(items, from, to) .then(_.bind(zabbixHelperSrv.handleHistoryResponse, zabbixHelperSrv, items, alias, target.scale)); } diff --git a/plugins/datasource-zabbix/helperFunctions.js b/plugins/datasource-zabbix/helperFunctions.js index f1b84fd..d844d92 100644 --- a/plugins/datasource-zabbix/helperFunctions.js +++ b/plugins/datasource-zabbix/helperFunctions.js @@ -47,7 +47,7 @@ function (angular, _) { return $q.when(_.map(grouped_history, function (history, itemid) { var item = indexed_items[itemid]; return { - target: (item.hosts ? item.hosts[0].name+': ' : '') + target: (item.host ? item.host + ': ' : '') + (alias ? alias : self.expandItemName(item)), datapoints: _.map(history, function (p) {