filter triggers by acknowledged status, #141
This commit is contained in:
9
dist/datasource-zabbix/datasource.js
vendored
9
dist/datasource-zabbix/datasource.js
vendored
@@ -579,7 +579,14 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
||||
if (hosts.length) {
|
||||
var hostids = _.map(hosts, 'hostid');
|
||||
var appids = _.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 responseHandler.handleTriggersResponse(triggers, timeRange);
|
||||
});
|
||||
} else {
|
||||
|
||||
2
dist/datasource-zabbix/datasource.js.map
vendored
2
dist/datasource-zabbix/datasource.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -123,14 +123,24 @@
|
||||
<div class="gf-form-select-wrapper width-16">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.minSeverity"
|
||||
ng-model="ctrl.target.triggers.minSeverity"
|
||||
ng-options="s.val as s.text for s in ctrl.triggerSeverity">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form max-width-20" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<label class="gf-form-label query-keyword width-8">Acknowledged</label>
|
||||
<div class="gf-form-select-wrapper width-12">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.triggers.acknowledged"
|
||||
ng-options="a.value as a.text for a in ctrl.ackFilters">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label="Count" ng-show="ctrl.target.mode == editorMode.TRIGGERS"
|
||||
checked="ctrl.target.countTriggers" on-change="ctrl.onTargetBlur()">
|
||||
checked="ctrl.target.triggers.count" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
|
||||
9
dist/datasource-zabbix/query.controller.js
vendored
9
dist/datasource-zabbix/query.controller.js
vendored
@@ -95,6 +95,8 @@ System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metri
|
||||
|
||||
_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
|
||||
@@ -136,8 +138,11 @@ System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metri
|
||||
'application': { 'filter': "" },
|
||||
'item': { 'filter': "" },
|
||||
'functions': [],
|
||||
'minSeverity': 3,
|
||||
'countTriggers': true,
|
||||
'triggers': {
|
||||
'count': true,
|
||||
'minSeverity': 3,
|
||||
'acknowledged': 2
|
||||
},
|
||||
'options': {
|
||||
'showDisabledItems': false
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
34
dist/datasource-zabbix/zabbixAPI.service.js
vendored
34
dist/datasource-zabbix/zabbixAPI.service.js
vendored
@@ -415,7 +415,13 @@ System.register(['angular', 'lodash', './utils', './zabbixAPICore.service'], fun
|
||||
}
|
||||
}, {
|
||||
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,
|
||||
@@ -431,7 +437,7 @@ System.register(['angular', 'lodash', './utils', './zabbixAPICore.service'], fun
|
||||
selectHosts: ['host', 'name']
|
||||
};
|
||||
|
||||
if (count) {
|
||||
if (count && acknowledged !== 0 && acknowledged !== 1) {
|
||||
params.countOutput = true;
|
||||
}
|
||||
|
||||
@@ -444,7 +450,15 @@ System.register(['angular', 'lodash', './utils', './zabbixAPICore.service'], fun
|
||||
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;
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
@@ -454,6 +468,20 @@ System.register(['angular', 'lodash', './utils', './zabbixAPICore.service'], fun
|
||||
return ZabbixAPI;
|
||||
}
|
||||
|
||||
function filterTriggersByAcknowledge(triggers, acknowledged) {
|
||||
if (acknowledged === 0) {
|
||||
return _.filter(triggers, function (trigger) {
|
||||
return trigger.lastEvent.acknowledged === "0";
|
||||
});
|
||||
} else if (acknowledged === 1) {
|
||||
return _.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.";
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user