From 1b11f3d46dae561bc37ac3cf9ee61c96f1cb356d Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 15 May 2020 15:24:30 +0300 Subject: [PATCH] Chore: ZabbixConnector types --- src/datasource-zabbix/datasource.ts | 2 +- src/datasource-zabbix/zabbix/types.ts | 24 +++++++++++++++++++++--- src/datasource-zabbix/zabbix/zabbix.ts | 22 +++++++++++++++++----- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/src/datasource-zabbix/datasource.ts b/src/datasource-zabbix/datasource.ts index 19335b0..d405b74 100644 --- a/src/datasource-zabbix/datasource.ts +++ b/src/datasource-zabbix/datasource.ts @@ -34,7 +34,7 @@ export class ZabbixDatasource { dbConnectionDatasourceName: string; dbConnectionRetentionPolicy: string; enableDebugLog: boolean; - zabbix: any; + zabbix: Zabbix; replaceTemplateVars: (target: any, scopedVars?: any) => any; diff --git a/src/datasource-zabbix/zabbix/types.ts b/src/datasource-zabbix/zabbix/types.ts index e6e9f91..dfc53d9 100644 --- a/src/datasource-zabbix/zabbix/types.ts +++ b/src/datasource-zabbix/zabbix/types.ts @@ -1,5 +1,23 @@ export interface ZabbixConnector { - getMacros(hostids: any[]): any; - getVersion(): string; - login(): any; + getHistory: (items, timeFrom, timeTill) => Promise; + getTrend: (items, timeFrom, timeTill) => Promise; + getItemsByIDs: (itemids) => Promise; + getEvents: (objectids, timeFrom, timeTo, showEvents, limit?) => Promise; + getAlerts: (itemids, timeFrom?, timeTo?) => Promise; + getHostAlerts: (hostids, applicationids, options?) => Promise; + getAcknowledges: (eventids) => Promise; + getITService: (serviceids?) => Promise; + acknowledgeEvent: (eventid, message) => Promise; + getProxies: () => Promise; + getEventAlerts: (eventids) => Promise; + getExtendedEventData: (eventids) => Promise; + getMacros: (hostids: any[]) => Promise; + getVersion: () => Promise; + login: () => Promise; + + getGroups: (groupFilter?) => any; + getHosts: (groupFilter?, hostFilter?) => any; + getApps: (groupFilter?, hostFilter?, appFilter?) => any; + getItems: (groupFilter?, hostFilter?, appFilter?, itemFilter?, options?) => any; + getSLA: (itservices, timeRange, target, options?) => any; } diff --git a/src/datasource-zabbix/zabbix/zabbix.ts b/src/datasource-zabbix/zabbix/zabbix.ts index 1b99a44..239eaef 100644 --- a/src/datasource-zabbix/zabbix/zabbix.ts +++ b/src/datasource-zabbix/zabbix/zabbix.ts @@ -21,7 +21,7 @@ const REQUESTS_TO_CACHE = [ const REQUESTS_TO_BIND = [ 'getHistory', 'getTrend', 'getMacros', 'getItemsByIDs', 'getEvents', 'getAlerts', 'getHostAlerts', - 'getAcknowledges', 'getITService', 'getVersion', 'login', 'acknowledgeEvent', 'getProxies', 'getEventAlerts', + 'getAcknowledges', 'getITService', 'getSLA', 'getVersion', 'login', 'acknowledgeEvent', 'getProxies', 'getEventAlerts', 'getExtendedEventData' ]; @@ -33,9 +33,21 @@ export class Zabbix implements ZabbixConnector { dbConnector: any; getTrendsDB: any; - getMacros: any; - getVersion: any; - login: any; + getHistory: (items, timeFrom, timeTill) => Promise; + getTrend: (items, timeFrom, timeTill) => Promise; + getItemsByIDs: (itemids) => Promise; + getEvents: (objectids, timeFrom, timeTo, showEvents, limit?) => Promise; + getAlerts: (itemids, timeFrom?, timeTo?) => Promise; + getHostAlerts: (hostids, applicationids, options?) => Promise; + getAcknowledges: (eventids) => Promise; + getITService: (serviceids?) => Promise; + acknowledgeEvent: (eventid, message) => Promise; + getProxies: () => Promise; + getEventAlerts: (eventids) => Promise; + getExtendedEventData: (eventids) => Promise; + getMacros: (hostids: any[]) => Promise; + getVersion: () => Promise; + login: () => Promise; constructor(options) { const { @@ -277,7 +289,7 @@ export class Zabbix implements ZabbixConnector { /** * Build query - convert target filters to array of Zabbix items */ - getTriggers(groupFilter, hostFilter, appFilter, options, proxyFilter) { + getTriggers(groupFilter, hostFilter, appFilter, options?, proxyFilter?) { const promises = [ this.getGroups(groupFilter), this.getHosts(groupFilter, hostFilter),