diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/types.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/types.ts index 007d592..677ad71 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/types.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/types.ts @@ -37,6 +37,21 @@ export interface ZabbixRequestResponse { data?: JSONRPCResponse; } -export type ZabbixAPIResponse = T; +export type ZabbixAPIResponse = Promise; export type APILoginResponse = string; + +export interface ZBXScript { + scriptid: string; + name?: string; + command?: string; + host_access?: string; + usrgrpid?: string; + groupid?: string; + description?: string; + confirmation?: string; + type?: string; + execute_on?: string; +} + +export type APIScriptGetResponse = ZabbixAPIResponse; diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index b30cb5c..6fa3482 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -5,7 +5,7 @@ import * as utils from '../../../utils'; import { ZabbixAPICore } from './zabbixAPICore'; import { ZBX_ACK_ACTION_NONE, ZBX_ACK_ACTION_ACK, ZBX_ACK_ACTION_ADD_MESSAGE, MIN_SLA_INTERVAL } from '../../../constants'; import { ShowProblemTypes, ZBXProblem } from '../../../types'; -import { JSONRPCRequestParams } from './types'; +import { JSONRPCRequestParams, APIScriptGetResponse } from './types'; const DEFAULT_ZABBIX_VERSION = '3.0.0'; @@ -664,6 +664,15 @@ export class ZabbixAPIConnector { return this.request('proxy.get', params); } + + getScripts(hostids: string[], options?: any): APIScriptGetResponse { + const params: any = { + output: 'extend', + hostids, + }; + + return this.request('script.get', params); + } } function filterTriggersByAcknowledge(triggers, acknowledged) { diff --git a/src/datasource-zabbix/zabbix/zabbix.ts b/src/datasource-zabbix/zabbix/zabbix.ts index 9328f34..f4aa4aa 100644 --- a/src/datasource-zabbix/zabbix/zabbix.ts +++ b/src/datasource-zabbix/zabbix/zabbix.ts @@ -20,7 +20,7 @@ interface AppsResponse extends Array { const REQUESTS_TO_PROXYFY = [ 'getHistory', 'getTrend', 'getGroups', 'getHosts', 'getApps', 'getItems', 'getMacros', 'getItemsByIDs', 'getEvents', 'getAlerts', 'getHostAlerts', 'getAcknowledges', 'getITService', 'getSLA', 'getVersion', 'getProxies', - 'getEventAlerts', 'getExtendedEventData', 'getProblems', 'getEventsHistory', 'getTriggersByIds' + 'getEventAlerts', 'getExtendedEventData', 'getProblems', 'getEventsHistory', 'getTriggersByIds', 'getScripts' ]; const REQUESTS_TO_CACHE = [ @@ -30,7 +30,7 @@ const REQUESTS_TO_CACHE = [ const REQUESTS_TO_BIND = [ 'getHistory', 'getTrend', 'getMacros', 'getItemsByIDs', 'getEvents', 'getAlerts', 'getHostAlerts', 'getAcknowledges', 'getITService', 'getVersion', 'login', 'acknowledgeEvent', 'getProxies', 'getEventAlerts', - 'getExtendedEventData' + 'getExtendedEventData', 'getScripts' ]; export class Zabbix implements ZabbixConnector {