filter triggers by acknowledged status, #141
This commit is contained in:
9
dist/test/datasource-zabbix/datasource.js
vendored
9
dist/test/datasource-zabbix/datasource.js
vendored
@@ -457,7 +457,14 @@ var ZabbixAPIDatasource = function () {
|
||||
if (hosts.length) {
|
||||
var hostids = _lodash2.default.map(hosts, 'hostid');
|
||||
var appids = _lodash2.default.map(apps, 'applicationid');
|
||||
return _this7.zabbix.getHostAlerts(hostids, appids, target.minSeverity, target.countTriggers, timeFrom, timeTo).then(function (triggers) {
|
||||
var options = {
|
||||
minSeverity: target.triggers.minSeverity,
|
||||
acknowledged: target.triggers.acknowledged,
|
||||
count: target.triggers.count,
|
||||
timeFrom: timeFrom,
|
||||
timeTo: timeTo
|
||||
};
|
||||
return _this7.zabbix.getHostAlerts(hostids, appids, options).then(function (triggers) {
|
||||
return _responseHandler2.default.handleTriggersResponse(triggers, timeRange);
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -72,6 +72,8 @@ var ZabbixQueryController = exports.ZabbixQueryController = function (_QueryCtrl
|
||||
|
||||
_this.slaPropertyList = [{ name: "Status", property: "status" }, { name: "SLA", property: "sla" }, { name: "OK time", property: "okTime" }, { name: "Problem time", property: "problemTime" }, { name: "Down time", property: "downtimeTime" }];
|
||||
|
||||
_this.ackFilters = [{ text: 'all triggers', value: 2 }, { text: 'unacknowledged', value: 0 }, { text: 'acknowledged', value: 1 }];
|
||||
|
||||
_this.triggerSeverity = c.TRIGGER_SEVERITY;
|
||||
|
||||
// Map functions for bs-typeahead
|
||||
@@ -113,8 +115,11 @@ var ZabbixQueryController = exports.ZabbixQueryController = function (_QueryCtrl
|
||||
'application': { 'filter': "" },
|
||||
'item': { 'filter': "" },
|
||||
'functions': [],
|
||||
'minSeverity': 3,
|
||||
'countTriggers': true,
|
||||
'triggers': {
|
||||
'count': true,
|
||||
'minSeverity': 3,
|
||||
'acknowledged': 2
|
||||
},
|
||||
'options': {
|
||||
'showDisabledItems': false
|
||||
}
|
||||
|
||||
34
dist/test/datasource-zabbix/zabbixAPI.service.js
vendored
34
dist/test/datasource-zabbix/zabbixAPI.service.js
vendored
@@ -487,7 +487,13 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
||||
}
|
||||
}, {
|
||||
key: 'getHostAlerts',
|
||||
value: function getHostAlerts(hostids, applicationids, minSeverity, count, timeFrom, timeTo) {
|
||||
value: function getHostAlerts(hostids, applicationids, options) {
|
||||
var minSeverity = options.minSeverity,
|
||||
acknowledged = options.acknowledged,
|
||||
count = options.count,
|
||||
timeFrom = options.timeFrom,
|
||||
timeTo = options.timeTo;
|
||||
|
||||
var params = {
|
||||
output: 'extend',
|
||||
hostids: hostids,
|
||||
@@ -503,7 +509,7 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
||||
selectHosts: ['host', 'name']
|
||||
};
|
||||
|
||||
if (count) {
|
||||
if (count && acknowledged !== 0 && acknowledged !== 1) {
|
||||
params.countOutput = true;
|
||||
}
|
||||
|
||||
@@ -516,7 +522,15 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
||||
params.lastChangeTill = timeTo;
|
||||
}
|
||||
|
||||
return this.request('trigger.get', params);
|
||||
return this.request('trigger.get', params).then(function (triggers) {
|
||||
if (!count || acknowledged === 0 || acknowledged === 1) {
|
||||
triggers = filterTriggersByAcknowledge(triggers, acknowledged);
|
||||
if (count) {
|
||||
triggers = triggers.length;
|
||||
}
|
||||
}
|
||||
return triggers;
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
@@ -526,6 +540,20 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
||||
return ZabbixAPI;
|
||||
}
|
||||
|
||||
function filterTriggersByAcknowledge(triggers, acknowledged) {
|
||||
if (acknowledged === 0) {
|
||||
return _lodash2.default.filter(triggers, function (trigger) {
|
||||
return trigger.lastEvent.acknowledged === "0";
|
||||
});
|
||||
} else if (acknowledged === 1) {
|
||||
return _lodash2.default.filter(triggers, function (trigger) {
|
||||
return trigger.lastEvent.acknowledged === "1";
|
||||
});
|
||||
} else {
|
||||
return triggers;
|
||||
}
|
||||
}
|
||||
|
||||
function isNotAuthorized(message) {
|
||||
return message === "Session terminated, re-login, please." || message === "Not authorised." || message === "Not authorized.";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user