Skip to content

Commit

Permalink
fix event ack for Zabbix 4.x, #629
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderzobnin committed Oct 21, 2018
1 parent 92a08a5 commit c73078d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
11 changes: 8 additions & 3 deletions src/datasource-zabbix/constants.js
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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'},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
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.
* Creates Zabbix API instance with given parameters (url, credentials and other).
* 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,
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/datasource-zabbix/zabbix/zabbix.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class Zabbix {
password,
basicAuth,
withCredentials,
zabbixVersion,
cacheTTL,
enableDirectDBConnection,
dbConnectionDatasourceId,
Expand All @@ -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 = {
Expand Down

1 comment on commit c73078d

@glardz
Copy link

@glardz glardz commented on c73078d Oct 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello Alexander,

how can i put your new version file in my grafana server ?, please.

Please sign in to comment.