Triggers query mode, allow to get active triggers count, #141
This commit is contained in:
@@ -136,6 +136,10 @@ class ZabbixAPIDatasource {
|
||||
} else if (target.mode === c.MODE_ITSERVICE) {
|
||||
// IT services mode
|
||||
return this.queryITServiceData(target, timeRange, options);
|
||||
} else if (target.mode === c.MODE_TRIGGERS) {
|
||||
return this.queryTriggersData(target, timeRange);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -350,6 +354,24 @@ class ZabbixAPIDatasource {
|
||||
});
|
||||
}
|
||||
|
||||
queryTriggersData(target, timeRange) {
|
||||
let [timeFrom, timeTo] = timeRange;
|
||||
return this.zabbix.getHostsFromTarget(target)
|
||||
.then((results) => {
|
||||
let [hosts, apps] = results;
|
||||
if (hosts.length) {
|
||||
let hostids = _.map(hosts, 'hostid');
|
||||
let appids = _.map(apps, 'applicationid');
|
||||
return this.zabbix.getHostAlerts(hostids, appids, target.minSeverity, target.options.countTriggers, timeFrom, timeTo)
|
||||
.then((triggers) => {
|
||||
return responseHandler.handleTriggersResponse(triggers, timeRange);
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test connection to Zabbix API
|
||||
* @return {object} Connection status and Zabbix API version
|
||||
|
||||
Reference in New Issue
Block a user