Problems: support problems history
This commit is contained in:
@@ -425,13 +425,17 @@ export class ZabbixDatasource {
|
|||||||
problemsOptions.severities = severities;
|
problemsOptions.severities = severities;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showProblems !== ShowProblemTypes.Problems) {
|
if (showProblems === ShowProblemTypes.History) {
|
||||||
problemsOptions.timeFrom = timeFrom;
|
problemsOptions.timeFrom = timeFrom;
|
||||||
problemsOptions.timeTo = timeTo;
|
problemsOptions.timeTo = timeTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getProblemsPromise = showProblems === ShowProblemTypes.History ?
|
||||||
|
this.zabbix.getProblemsHistory(groupFilter, hostFilter, appFilter, proxyFilter, problemsOptions) :
|
||||||
|
this.zabbix.getProblems(groupFilter, hostFilter, appFilter, proxyFilter, problemsOptions);
|
||||||
|
|
||||||
const problemsPromises = Promise.all([
|
const problemsPromises = Promise.all([
|
||||||
this.zabbix.getProblems(groupFilter, hostFilter, appFilter, proxyFilter, problemsOptions),
|
getProblemsPromise,
|
||||||
getProxiesPromise
|
getProxiesPromise
|
||||||
])
|
])
|
||||||
.then(([problems, sourceProxies]) => {
|
.then(([problems, sourceProxies]) => {
|
||||||
|
|||||||
@@ -485,20 +485,34 @@ export class ZabbixAPIConnector {
|
|||||||
return this.request('event.get', params);
|
return this.request('event.get', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAcknowledges(eventids) {
|
getEventsHistory(groupids, hostids, applicationids, options) {
|
||||||
const params = {
|
const { timeFrom, timeTo, severities, limit } = options;
|
||||||
|
|
||||||
|
const params: any = {
|
||||||
output: 'extend',
|
output: 'extend',
|
||||||
eventids: eventids,
|
time_from: timeFrom,
|
||||||
preservekeys: true,
|
time_till: timeTo,
|
||||||
select_acknowledges: 'extend',
|
value: '1',
|
||||||
sortfield: 'clock',
|
source: '0',
|
||||||
sortorder: 'DESC'
|
object: '0',
|
||||||
|
evaltype: '0',
|
||||||
|
sortfield: ['eventid'],
|
||||||
|
sortorder: 'DESC',
|
||||||
|
selectSuppressionData: ['maintenanceid', 'suppress_until'],
|
||||||
|
groupids,
|
||||||
|
hostids,
|
||||||
|
applicationids,
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.request('event.get', params)
|
if (limit) {
|
||||||
.then(events => {
|
params.limit = limit;
|
||||||
return _.filter(events, (event) => event.acknowledges.length);
|
}
|
||||||
});
|
|
||||||
|
if (severities) {
|
||||||
|
params.severities = severities;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.request('event.get', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
getExtendedEventData(eventids) {
|
getExtendedEventData(eventids) {
|
||||||
@@ -530,6 +544,22 @@ export class ZabbixAPIConnector {
|
|||||||
return this.request('alert.get', params);
|
return this.request('alert.get', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getAcknowledges(eventids) {
|
||||||
|
const params = {
|
||||||
|
output: 'extend',
|
||||||
|
eventids: eventids,
|
||||||
|
preservekeys: true,
|
||||||
|
select_acknowledges: 'extend',
|
||||||
|
sortfield: 'clock',
|
||||||
|
sortorder: 'DESC'
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.request('event.get', params)
|
||||||
|
.then(events => {
|
||||||
|
return _.filter(events, (event) => event.acknowledges.length);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
getAlerts(itemids, timeFrom, timeTo) {
|
getAlerts(itemids, timeFrom, timeTo) {
|
||||||
const params: any = {
|
const params: any = {
|
||||||
output: 'extend',
|
output: 'extend',
|
||||||
|
|||||||
@@ -316,7 +316,6 @@ export class Zabbix implements ZabbixConnector {
|
|||||||
|
|
||||||
return query;
|
return query;
|
||||||
})
|
})
|
||||||
// .then(query => this.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, options))
|
|
||||||
.then(query => this.zabbixAPI.getProblems(query.groupids, query.hostids, query.applicationids, options))
|
.then(query => this.zabbixAPI.getProblems(query.groupids, query.hostids, query.applicationids, options))
|
||||||
.then(problems => {
|
.then(problems => {
|
||||||
const triggerids = problems?.map(problem => problem.objectid);
|
const triggerids = problems?.map(problem => problem.objectid);
|
||||||
@@ -327,6 +326,40 @@ export class Zabbix implements ZabbixConnector {
|
|||||||
.then(triggers => this.expandUserMacro.bind(this)(triggers, true));
|
.then(triggers => this.expandUserMacro.bind(this)(triggers, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getProblemsHistory(groupFilter, hostFilter, appFilter, proxyFilter?, options?) {
|
||||||
|
const promises = [
|
||||||
|
this.getGroups(groupFilter),
|
||||||
|
this.getHosts(groupFilter, hostFilter),
|
||||||
|
this.getApps(groupFilter, hostFilter, appFilter)
|
||||||
|
];
|
||||||
|
|
||||||
|
return Promise.all(promises)
|
||||||
|
.then(results => {
|
||||||
|
const [filteredGroups, filteredHosts, filteredApps] = results;
|
||||||
|
const query: any = {};
|
||||||
|
|
||||||
|
if (appFilter) {
|
||||||
|
query.applicationids = _.flatten(_.map(filteredApps, 'applicationid'));
|
||||||
|
}
|
||||||
|
if (hostFilter) {
|
||||||
|
query.hostids = _.map(filteredHosts, 'hostid');
|
||||||
|
}
|
||||||
|
if (groupFilter) {
|
||||||
|
query.groupids = _.map(filteredGroups, 'groupid');
|
||||||
|
}
|
||||||
|
|
||||||
|
return query;
|
||||||
|
})
|
||||||
|
.then(query => this.zabbixAPI.getEventsHistory(query.groupids, query.hostids, query.applicationids, options))
|
||||||
|
.then(problems => {
|
||||||
|
const triggerids = problems?.map(problem => problem.objectid);
|
||||||
|
return Promise.all([Promise.resolve(problems), this.zabbixAPI.getTriggersByIds(triggerids)]);
|
||||||
|
})
|
||||||
|
.then(([problems, triggers]) => joinTriggersWithProblems(problems, triggers))
|
||||||
|
.then(triggers => this.filterTriggersByProxy(triggers, proxyFilter))
|
||||||
|
.then(triggers => this.expandUserMacro.bind(this)(triggers, true));
|
||||||
|
}
|
||||||
|
|
||||||
filterTriggersByProxy(triggers, proxyFilter) {
|
filterTriggersByProxy(triggers, proxyFilter) {
|
||||||
return this.getFilteredProxies(proxyFilter)
|
return this.getFilteredProxies(proxyFilter)
|
||||||
.then(proxies => {
|
.then(proxies => {
|
||||||
|
|||||||
Reference in New Issue
Block a user