Execute scripts from problem details

This commit is contained in:
Alexander Zobnin
2020-05-27 15:15:36 +03:00
parent 092acec295
commit 6841fa0386
7 changed files with 114 additions and 88 deletions

View File

@@ -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);
}
}