fix event ack for Zabbix 4.x, #629

This commit is contained in:
Alexander Zobnin
2018-10-21 12:13:25 +03:00
parent 92a08a5c58
commit c73078d1fb
3 changed files with 17 additions and 8 deletions

View File

@@ -1,3 +1,7 @@
// Data point
export const DATAPOINT_VALUE = 0;
export const DATAPOINT_TS = 1;
// Editor modes
export const MODE_METRICS = 0;
export const MODE_ITSERVICE = 1;
@@ -17,9 +21,10 @@ export const SHOW_ALL_TRIGGERS = [0, 1];
export const SHOW_ALL_EVENTS = [0, 1];
export const SHOW_OK_EVENTS = 1;
// Data point
export const DATAPOINT_VALUE = 0;
export const DATAPOINT_TS = 1;
// Acknowledge
export const ZBX_ACK_ACTION_NONE = 0;
export const ZBX_ACK_ACTION_ACK = 2;
export const ZBX_ACK_ACTION_ADD_MESSAGE = 4;
export const TRIGGER_SEVERITY = [
{val: 0, text: 'Not classified'},

View File

@@ -1,6 +1,7 @@
import _ from 'lodash';
import * as utils from '../../../utils';
import { ZabbixAPICore } from './zabbixAPICore';
import { ZBX_ACK_ACTION_NONE, ZBX_ACK_ACTION_ACK, ZBX_ACK_ACTION_ADD_MESSAGE } from '../../../constants';
/**
* Zabbix API Wrapper.
@@ -8,11 +9,12 @@ import { ZabbixAPICore } from './zabbixAPICore';
* Wraps API calls and provides high-level methods.
*/
export class ZabbixAPIConnector {
constructor(api_url, username, password, basicAuth, withCredentials, backendSrv) {
constructor(api_url, username, password, version, basicAuth, withCredentials, backendSrv) {
this.url = api_url;
this.username = username;
this.password = password;
this.auth = "";
this.auth = '';
this.version = version;
this.requestOptions = {
basicAuth: basicAuth,
@@ -90,10 +92,11 @@ export class ZabbixAPIConnector {
////////////////////////////////
acknowledgeEvent(eventid, message) {
var params = {
const action = this.version >= 4 ? ZBX_ACK_ACTION_ACK + ZBX_ACK_ACTION_ADD_MESSAGE : ZBX_ACK_ACTION_NONE;
const params = {
eventids: eventid,
message: message,
action: 6
action: action
};
return this.request('event.acknowledge', params);

View File

@@ -28,6 +28,7 @@ export class Zabbix {
password,
basicAuth,
withCredentials,
zabbixVersion,
cacheTTL,
enableDirectDBConnection,
dbConnectionDatasourceId,
@@ -43,7 +44,7 @@ export class Zabbix {
};
this.cachingProxy = new CachingProxy(cacheOptions);
this.zabbixAPI = new ZabbixAPIConnector(url, username, password, basicAuth, withCredentials, backendSrv);
this.zabbixAPI = new ZabbixAPIConnector(url, username, password, zabbixVersion, basicAuth, withCredentials, backendSrv);
if (enableDirectDBConnection) {
let dbConnectorOptions = {