filter triggers by acknowledged status, #141
This commit is contained in:
17
dist/dashboards/zabbix_system_status.json
vendored
17
dist/dashboards/zabbix_system_status.json
vendored
@@ -171,7 +171,6 @@
|
|||||||
"application": {
|
"application": {
|
||||||
"filter": ""
|
"filter": ""
|
||||||
},
|
},
|
||||||
"countTriggers": false,
|
|
||||||
"functions": [],
|
"functions": [],
|
||||||
"group": {
|
"group": {
|
||||||
"filter": "/.*/"
|
"filter": "/.*/"
|
||||||
@@ -182,11 +181,11 @@
|
|||||||
"item": {
|
"item": {
|
||||||
"filter": ""
|
"filter": ""
|
||||||
},
|
},
|
||||||
"minSeverity": 0,
|
|
||||||
"mode": 4,
|
"mode": 4,
|
||||||
"options": {
|
"triggers": {
|
||||||
"countTriggers": false,
|
"count": false,
|
||||||
"showDisabledItems": false
|
"minSeverity": 0,
|
||||||
|
"acknowledged": 2
|
||||||
},
|
},
|
||||||
"refId": "A",
|
"refId": "A",
|
||||||
"target": ""
|
"target": ""
|
||||||
@@ -269,7 +268,6 @@
|
|||||||
"application": {
|
"application": {
|
||||||
"filter": ""
|
"filter": ""
|
||||||
},
|
},
|
||||||
"countTriggers": true,
|
|
||||||
"functions": [],
|
"functions": [],
|
||||||
"group": {
|
"group": {
|
||||||
"filter": "$group"
|
"filter": "$group"
|
||||||
@@ -280,10 +278,11 @@
|
|||||||
"item": {
|
"item": {
|
||||||
"filter": ""
|
"filter": ""
|
||||||
},
|
},
|
||||||
"minSeverity": 3,
|
|
||||||
"mode": 4,
|
"mode": 4,
|
||||||
"options": {
|
"triggers": {
|
||||||
"showDisabledItems": false
|
"count": true,
|
||||||
|
"minSeverity": 3,
|
||||||
|
"acknowledged": 2
|
||||||
},
|
},
|
||||||
"refId": "A",
|
"refId": "A",
|
||||||
"target": ""
|
"target": ""
|
||||||
|
|||||||
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) {
|
if (hosts.length) {
|
||||||
var hostids = _.map(hosts, 'hostid');
|
var hostids = _.map(hosts, 'hostid');
|
||||||
var appids = _.map(apps, 'applicationid');
|
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);
|
return responseHandler.handleTriggersResponse(triggers, timeRange);
|
||||||
});
|
});
|
||||||
} else {
|
} 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">
|
<div class="gf-form-select-wrapper width-16">
|
||||||
<select class="gf-form-input"
|
<select class="gf-form-input"
|
||||||
ng-change="ctrl.onTargetBlur()"
|
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">
|
ng-options="s.val as s.text for s in ctrl.triggerSeverity">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</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"
|
<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>
|
</gf-form-switch>
|
||||||
|
|
||||||
<div class="gf-form gf-form--grow">
|
<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.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;
|
_this.triggerSeverity = c.TRIGGER_SEVERITY;
|
||||||
|
|
||||||
// Map functions for bs-typeahead
|
// Map functions for bs-typeahead
|
||||||
@@ -136,8 +138,11 @@ System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metri
|
|||||||
'application': { 'filter': "" },
|
'application': { 'filter': "" },
|
||||||
'item': { 'filter': "" },
|
'item': { 'filter': "" },
|
||||||
'functions': [],
|
'functions': [],
|
||||||
'minSeverity': 3,
|
'triggers': {
|
||||||
'countTriggers': true,
|
'count': true,
|
||||||
|
'minSeverity': 3,
|
||||||
|
'acknowledged': 2
|
||||||
|
},
|
||||||
'options': {
|
'options': {
|
||||||
'showDisabledItems': false
|
'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',
|
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 = {
|
var params = {
|
||||||
output: 'extend',
|
output: 'extend',
|
||||||
hostids: hostids,
|
hostids: hostids,
|
||||||
@@ -431,7 +437,7 @@ System.register(['angular', 'lodash', './utils', './zabbixAPICore.service'], fun
|
|||||||
selectHosts: ['host', 'name']
|
selectHosts: ['host', 'name']
|
||||||
};
|
};
|
||||||
|
|
||||||
if (count) {
|
if (count && acknowledged !== 0 && acknowledged !== 1) {
|
||||||
params.countOutput = true;
|
params.countOutput = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,7 +450,15 @@ System.register(['angular', 'lodash', './utils', './zabbixAPICore.service'], fun
|
|||||||
params.lastChangeTill = timeTo;
|
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;
|
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) {
|
function isNotAuthorized(message) {
|
||||||
return message === "Session terminated, re-login, please." || message === "Not authorised." || message === "Not authorized.";
|
return message === "Session terminated, re-login, please." || message === "Not authorised." || message === "Not authorized.";
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
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) {
|
if (hosts.length) {
|
||||||
var hostids = _lodash2.default.map(hosts, 'hostid');
|
var hostids = _lodash2.default.map(hosts, 'hostid');
|
||||||
var appids = _lodash2.default.map(apps, 'applicationid');
|
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);
|
return _responseHandler2.default.handleTriggersResponse(triggers, timeRange);
|
||||||
});
|
});
|
||||||
} else {
|
} 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.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;
|
_this.triggerSeverity = c.TRIGGER_SEVERITY;
|
||||||
|
|
||||||
// Map functions for bs-typeahead
|
// Map functions for bs-typeahead
|
||||||
@@ -113,8 +115,11 @@ var ZabbixQueryController = exports.ZabbixQueryController = function (_QueryCtrl
|
|||||||
'application': { 'filter': "" },
|
'application': { 'filter': "" },
|
||||||
'item': { 'filter': "" },
|
'item': { 'filter': "" },
|
||||||
'functions': [],
|
'functions': [],
|
||||||
'minSeverity': 3,
|
'triggers': {
|
||||||
'countTriggers': true,
|
'count': true,
|
||||||
|
'minSeverity': 3,
|
||||||
|
'acknowledged': 2
|
||||||
|
},
|
||||||
'options': {
|
'options': {
|
||||||
'showDisabledItems': false
|
'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',
|
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 = {
|
var params = {
|
||||||
output: 'extend',
|
output: 'extend',
|
||||||
hostids: hostids,
|
hostids: hostids,
|
||||||
@@ -503,7 +509,7 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
|||||||
selectHosts: ['host', 'name']
|
selectHosts: ['host', 'name']
|
||||||
};
|
};
|
||||||
|
|
||||||
if (count) {
|
if (count && acknowledged !== 0 && acknowledged !== 1) {
|
||||||
params.countOutput = true;
|
params.countOutput = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,7 +522,15 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
|||||||
params.lastChangeTill = timeTo;
|
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;
|
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) {
|
function isNotAuthorized(message) {
|
||||||
return message === "Session terminated, re-login, please." || message === "Not authorised." || message === "Not authorized.";
|
return message === "Session terminated, re-login, please." || message === "Not authorised." || message === "Not authorized.";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,6 @@
|
|||||||
"application": {
|
"application": {
|
||||||
"filter": ""
|
"filter": ""
|
||||||
},
|
},
|
||||||
"countTriggers": false,
|
|
||||||
"functions": [],
|
"functions": [],
|
||||||
"group": {
|
"group": {
|
||||||
"filter": "/.*/"
|
"filter": "/.*/"
|
||||||
@@ -182,11 +181,11 @@
|
|||||||
"item": {
|
"item": {
|
||||||
"filter": ""
|
"filter": ""
|
||||||
},
|
},
|
||||||
"minSeverity": 0,
|
|
||||||
"mode": 4,
|
"mode": 4,
|
||||||
"options": {
|
"triggers": {
|
||||||
"countTriggers": false,
|
"count": false,
|
||||||
"showDisabledItems": false
|
"minSeverity": 0,
|
||||||
|
"acknowledged": 2
|
||||||
},
|
},
|
||||||
"refId": "A",
|
"refId": "A",
|
||||||
"target": ""
|
"target": ""
|
||||||
@@ -269,7 +268,6 @@
|
|||||||
"application": {
|
"application": {
|
||||||
"filter": ""
|
"filter": ""
|
||||||
},
|
},
|
||||||
"countTriggers": true,
|
|
||||||
"functions": [],
|
"functions": [],
|
||||||
"group": {
|
"group": {
|
||||||
"filter": "$group"
|
"filter": "$group"
|
||||||
@@ -280,10 +278,11 @@
|
|||||||
"item": {
|
"item": {
|
||||||
"filter": ""
|
"filter": ""
|
||||||
},
|
},
|
||||||
"minSeverity": 3,
|
|
||||||
"mode": 4,
|
"mode": 4,
|
||||||
"options": {
|
"triggers": {
|
||||||
"showDisabledItems": false
|
"count": true,
|
||||||
|
"minSeverity": 3,
|
||||||
|
"acknowledged": 2
|
||||||
},
|
},
|
||||||
"refId": "A",
|
"refId": "A",
|
||||||
"target": ""
|
"target": ""
|
||||||
|
|||||||
@@ -362,7 +362,14 @@ class ZabbixAPIDatasource {
|
|||||||
if (hosts.length) {
|
if (hosts.length) {
|
||||||
let hostids = _.map(hosts, 'hostid');
|
let hostids = _.map(hosts, 'hostid');
|
||||||
let appids = _.map(apps, 'applicationid');
|
let appids = _.map(apps, 'applicationid');
|
||||||
return this.zabbix.getHostAlerts(hostids, appids, target.minSeverity, target.countTriggers, timeFrom, timeTo)
|
let options = {
|
||||||
|
minSeverity: target.triggers.minSeverity,
|
||||||
|
acknowledged: target.triggers.acknowledged,
|
||||||
|
count: target.triggers.count,
|
||||||
|
timeFrom: timeFrom,
|
||||||
|
timeTo: timeTo
|
||||||
|
};
|
||||||
|
return this.zabbix.getHostAlerts(hostids, appids, options)
|
||||||
.then((triggers) => {
|
.then((triggers) => {
|
||||||
return responseHandler.handleTriggersResponse(triggers, timeRange);
|
return responseHandler.handleTriggersResponse(triggers, timeRange);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -123,14 +123,24 @@
|
|||||||
<div class="gf-form-select-wrapper width-16">
|
<div class="gf-form-select-wrapper width-16">
|
||||||
<select class="gf-form-input"
|
<select class="gf-form-input"
|
||||||
ng-change="ctrl.onTargetBlur()"
|
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">
|
ng-options="s.val as s.text for s in ctrl.triggerSeverity">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</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"
|
<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>
|
</gf-form-switch>
|
||||||
|
|
||||||
<div class="gf-form gf-form--grow">
|
<div class="gf-form gf-form--grow">
|
||||||
|
|||||||
@@ -45,6 +45,12 @@ export class ZabbixQueryController extends QueryCtrl {
|
|||||||
{name: "Down time", property: "downtimeTime"}
|
{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;
|
this.triggerSeverity = c.TRIGGER_SEVERITY;
|
||||||
|
|
||||||
// Map functions for bs-typeahead
|
// Map functions for bs-typeahead
|
||||||
@@ -84,8 +90,11 @@ export class ZabbixQueryController extends QueryCtrl {
|
|||||||
'application': { 'filter': "" },
|
'application': { 'filter': "" },
|
||||||
'item': { 'filter': "" },
|
'item': { 'filter': "" },
|
||||||
'functions': [],
|
'functions': [],
|
||||||
'minSeverity': 3,
|
'triggers': {
|
||||||
'countTriggers': true,
|
'count': true,
|
||||||
|
'minSeverity': 3,
|
||||||
|
'acknowledged': 2
|
||||||
|
},
|
||||||
'options': {
|
'options': {
|
||||||
'showDisabledItems': false
|
'showDisabledItems': false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -434,8 +434,9 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
|||||||
return this.request('trigger.get', params);
|
return this.request('trigger.get', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getHostAlerts(hostids, applicationids, minSeverity, count, timeFrom, timeTo) {
|
getHostAlerts(hostids, applicationids, options) {
|
||||||
var params = {
|
let {minSeverity, acknowledged, count, timeFrom, timeTo} = options;
|
||||||
|
let params = {
|
||||||
output: 'extend',
|
output: 'extend',
|
||||||
hostids: hostids,
|
hostids: hostids,
|
||||||
min_severity: minSeverity,
|
min_severity: minSeverity,
|
||||||
@@ -450,7 +451,7 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
|||||||
selectHosts: ['host', 'name']
|
selectHosts: ['host', 'name']
|
||||||
};
|
};
|
||||||
|
|
||||||
if (count) {
|
if (count && acknowledged !== 0 && acknowledged !== 1) {
|
||||||
params.countOutput = true;
|
params.countOutput = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,13 +464,32 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
|||||||
params.lastChangeTill = timeTo;
|
params.lastChangeTill = timeTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.request('trigger.get', params);
|
return this.request('trigger.get', params)
|
||||||
|
.then((triggers) => {
|
||||||
|
if (!count || acknowledged === 0 || acknowledged === 1) {
|
||||||
|
triggers = filterTriggersByAcknowledge(triggers, acknowledged);
|
||||||
|
if (count) {
|
||||||
|
triggers = triggers.length;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return triggers;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ZabbixAPI;
|
return ZabbixAPI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterTriggersByAcknowledge(triggers, acknowledged) {
|
||||||
|
if (acknowledged === 0) {
|
||||||
|
return _.filter(triggers, (trigger) => trigger.lastEvent.acknowledged === "0");
|
||||||
|
} else if (acknowledged === 1) {
|
||||||
|
return _.filter(triggers, (trigger) => trigger.lastEvent.acknowledged === "1");
|
||||||
|
} else {
|
||||||
|
return triggers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function isNotAuthorized(message) {
|
function isNotAuthorized(message) {
|
||||||
return (
|
return (
|
||||||
message === "Session terminated, re-login, please." ||
|
message === "Session terminated, re-login, please." ||
|
||||||
|
|||||||
Reference in New Issue
Block a user