Added methods for getting trend from different api types. Added some
hacks for getting applications from different apis.
This commit is contained in:
@@ -138,7 +138,7 @@ function (angular, _, dateMath, utils, metricFunctions) {
|
||||
|
||||
// Use trends
|
||||
var valueType = target.downsampleFunction ? target.downsampleFunction.value : "avg";
|
||||
getHistory = self.zabbixAPI.getTrends(items, from, to).then(function(history) {
|
||||
getHistory = self.zabbixAPI.getTrend(items, from, to).then(function(history) {
|
||||
return self.queryProcessor.handleTrends(history, addHostName, valueType);
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -143,6 +143,9 @@ function (angular, _) {
|
||||
var params = {
|
||||
output: ['name'],
|
||||
sortfield: 'name',
|
||||
|
||||
// Hack for supporting different apis (2.2 vs 2.4 vs 3.0)
|
||||
selectHost: [],
|
||||
selectHosts: []
|
||||
};
|
||||
|
||||
@@ -223,7 +226,7 @@ function (angular, _) {
|
||||
* @param {Number} time_till Time in seconds
|
||||
* @return {Array} Array of Zabbix trend objects
|
||||
*/
|
||||
p.getTrends = function(items, time_from, time_till) {
|
||||
p.getTrend_ZBXNEXT1193 = function(items, time_from, time_till) {
|
||||
var self = this;
|
||||
|
||||
// Group items by value type
|
||||
@@ -250,6 +253,30 @@ function (angular, _) {
|
||||
})).then(_.flatten);
|
||||
};
|
||||
|
||||
p.getTrend_30 = function(items, time_from, time_till, value_type) {
|
||||
var self = this;
|
||||
var itemids = _.map(items, 'itemid');
|
||||
|
||||
var params = {
|
||||
output: ["itemid",
|
||||
"clock",
|
||||
value_type
|
||||
],
|
||||
itemids: itemids,
|
||||
time_from: time_from
|
||||
};
|
||||
|
||||
// Relative queries (e.g. last hour) don't include an end time
|
||||
if (time_till) {
|
||||
params.time_till = time_till;
|
||||
}
|
||||
|
||||
return self.request('trend.get', params);
|
||||
};
|
||||
|
||||
p.getTrend = p.getTrend_ZBXNEXT1193;
|
||||
//p.getTrend = p.getTrend_30;
|
||||
|
||||
p.getITService = function(/* optional */ serviceids) {
|
||||
var params = {
|
||||
output: 'extend',
|
||||
|
||||
@@ -187,10 +187,14 @@ function (angular, _, utils) {
|
||||
*/
|
||||
function convertApplications(applications) {
|
||||
return _.map(_.groupBy(applications, 'name'), function(value, key) {
|
||||
|
||||
// Hack for supporting different apis (2.2 vs 2.4 vs 3.0)
|
||||
var hostField = value['hosts'] ? 'hosts' : 'host';
|
||||
|
||||
return {
|
||||
name: key,
|
||||
applicationids: _.map(value, 'applicationid'),
|
||||
hosts: _.uniq(_.map(_.flatten(value, 'hosts'), 'hostid'))
|
||||
hosts: _.uniq(_.map(_.flatten(value, hostField), 'hostid'))
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user