From 834b953e4100969f42a8114624ce2b2269ae080e Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Sun, 13 Nov 2016 18:40:50 +0300 Subject: [PATCH] Add host name to metric if multiple hosts returned. --- src/datasource-zabbix/responseHandler.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/datasource-zabbix/responseHandler.js b/src/datasource-zabbix/responseHandler.js index 0f6a8e2..7ebe7a9 100644 --- a/src/datasource-zabbix/responseHandler.js +++ b/src/datasource-zabbix/responseHandler.js @@ -22,7 +22,7 @@ function convertHistory(history, items, addHostName, convertPointCallback) { // Group history by itemid var grouped_history = _.groupBy(history, 'itemid'); - var hosts = _.uniq(_.flatten(_.map(items, 'hosts')),'hostid'); //uniq is needed to deduplicate + var hosts = _.uniqBy(_.flatten(_.map(items, 'hosts')), 'hostid'); //uniqBy is needed to deduplicate return _.map(grouped_history, function(hist, itemid) { var item = _.find(items, {'itemid': itemid}); @@ -38,11 +38,11 @@ function convertHistory(history, items, addHostName, convertPointCallback) { }); } -function handleHistory(history, items, addHostName) { +function handleHistory(history, items, addHostName = true) { return convertHistory(history, items, addHostName, convertHistoryPoint); } -function handleTrends(history, items, addHostName, valueType) { +function handleTrends(history, items, valueType, addHostName = true) { var convertPointCallback = _.partial(convertTrendPoint, valueType); return convertHistory(history, items, addHostName, convertPointCallback); }