Execute scripts from problem details
This commit is contained in:
@@ -54,4 +54,7 @@ export interface ZBXScript {
|
||||
execute_on?: string;
|
||||
}
|
||||
|
||||
export type APIScriptGetResponse = ZabbixAPIResponse<ZBXScript[]>;
|
||||
export interface APIExecuteScriptResponse {
|
||||
response: 'success' | 'failed';
|
||||
value?: string;
|
||||
}
|
||||
|
||||
@@ -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, APIScriptGetResponse } from './types';
|
||||
import { JSONRPCRequestParams, ZBXScript, APIExecuteScriptResponse } from './types';
|
||||
|
||||
const DEFAULT_ZABBIX_VERSION = '3.0.0';
|
||||
|
||||
@@ -665,13 +665,22 @@ export class ZabbixAPIConnector {
|
||||
return this.request('proxy.get', params);
|
||||
}
|
||||
|
||||
getScripts(hostids: string[], options?: any): APIScriptGetResponse {
|
||||
getScripts(hostids: string[], options?: any): Promise<ZBXScript[]> {
|
||||
const params: any = {
|
||||
output: 'extend',
|
||||
hostids,
|
||||
};
|
||||
|
||||
return this.request('script.get', params);
|
||||
return this.request('script.get', params).then(utils.mustArray);
|
||||
}
|
||||
|
||||
executeScript(hostid: string, scriptid: string): Promise<APIExecuteScriptResponse> {
|
||||
const params: any = {
|
||||
hostid,
|
||||
scriptid,
|
||||
};
|
||||
|
||||
return this.request('script.execute', params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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', 'getScripts'
|
||||
'getExtendedEventData', 'getScripts', 'executeScript',
|
||||
];
|
||||
|
||||
export class Zabbix implements ZabbixConnector {
|
||||
|
||||
Reference in New Issue
Block a user