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
|
// Use trends
|
||||||
var valueType = target.downsampleFunction ? target.downsampleFunction.value : "avg";
|
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);
|
return self.queryProcessor.handleTrends(history, addHostName, valueType);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -143,6 +143,9 @@ function (angular, _) {
|
|||||||
var params = {
|
var params = {
|
||||||
output: ['name'],
|
output: ['name'],
|
||||||
sortfield: 'name',
|
sortfield: 'name',
|
||||||
|
|
||||||
|
// Hack for supporting different apis (2.2 vs 2.4 vs 3.0)
|
||||||
|
selectHost: [],
|
||||||
selectHosts: []
|
selectHosts: []
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -223,7 +226,7 @@ function (angular, _) {
|
|||||||
* @param {Number} time_till Time in seconds
|
* @param {Number} time_till Time in seconds
|
||||||
* @return {Array} Array of Zabbix trend objects
|
* @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;
|
var self = this;
|
||||||
|
|
||||||
// Group items by value type
|
// Group items by value type
|
||||||
@@ -250,6 +253,30 @@ function (angular, _) {
|
|||||||
})).then(_.flatten);
|
})).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) {
|
p.getITService = function(/* optional */ serviceids) {
|
||||||
var params = {
|
var params = {
|
||||||
output: 'extend',
|
output: 'extend',
|
||||||
|
|||||||
@@ -187,10 +187,14 @@ function (angular, _, utils) {
|
|||||||
*/
|
*/
|
||||||
function convertApplications(applications) {
|
function convertApplications(applications) {
|
||||||
return _.map(_.groupBy(applications, 'name'), function(value, key) {
|
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 {
|
return {
|
||||||
name: key,
|
name: key,
|
||||||
applicationids: _.map(value, 'applicationid'),
|
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