Se encuentra viendo la documentación de la versión en desarrollo, puede estar incompleta.
Únase a nuestro proyecto de traducción y ayude a traducir la documentación de Zabbix a su lengua materna.

script.getscriptsbyevents

Descripción

object script.getscriptsbyevents(array eventIds)

Este método permite recuperar scripts disponibles para los eventos dados.

Este método está disponible para usuarios de cualquier tipo. Los permisos para llamar al método se puede revocar en la configuración de roles de usuario. Ver Roles de usuario para obtener más información.

Parámetros

(cadena/matriz) ID de eventos para los que devolver scripts.

Valores de retorno

(objeto) Devuelve un objeto con ID de evento como propiedades y matrices de scripts disponibles como valores.

El método expandirá automáticamente las macros en el texto de confirmación y la url.

Ejemplos

Recuperar scripts por ID de evento

Recupere todos los scripts disponibles para los eventos "632" y "614".

Solicitud:

{
           "jsonrpc": "2.0",
           "method": "script.getscriptsbyevents",
           "params": [
               "632",
               "614"
           ],
           "id": 1
       }

Respuesta:

{
           "jsonrpc": "2.0",
           "result": {
               "632": [
                   {
                       "scriptid": "3",
                       "name": "Detect operating system",
                       "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "7",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   },
                   {
                       "scriptid": "1",
                       "name": "Ping",
                       "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   },
                   {
                       "scriptid": "2",
                       "name": "Traceroute",
                       "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   }
               ],
               "614": [
                   {
                       "scriptid": "3",
                       "name": "Detect operating system",
                       "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "7",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   },
                   {
                       "scriptid": "1",
                       "name": "Ping",
                       "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   },
                   {
                       "scriptid": "2",
                       "name": "Traceroute",
                       "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "",
                       "type": "0",
                       "execute_on": "1",
                       "timeout": "30s",
                       "scope": "4",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   }
               ]
           },
           "id": 1
       }

Retrieve specific script with manualinput value.

Retrieve script with ID "4" on event "632" with manualinput value "dashboard.view".

Request:

{
           "jsonrpc": "2.0",
           "method": "script.getscriptsbyevents",
           "params": [
             {
               "eventid":  "632",
               "scriptid": "4",
               "manualinput": "dashboard.view"
             }
         ],
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
             "632": [
               {
                 "scriptid": "4",
                 "name": "Open Zabbix page",
                 "command": "",
                 "host_access": "2",
                 "usrgrpid": "0",
                 "groupid": "0",
                 "description": "",
                 "confirmation": "Are you sure you want to open page dashboard.view?",
                 "type": "6",
                 "execute_on": "2",
                 "timeout": "30s",
                 "scope": "4",
                 "port": "",
                 "authtype": "0",
                 "username": "",
                 "password": "",
                 "publickey": "",
                 "privatekey": "",
                 "menu_path": "",
                 "url": "http://localhost/ui/zabbix.php?action=dashboard.view",
                 "new_window": "1",
                 "manualinput": "1",
                 "manualinput_prompt": "Zabbix page to open:",
                 "manualinput_validator_type": "1",
                 "manualinput_validator": "dashboard.view,discovery.view",
                 "manualinput_default_value": "",
                 "parameters": []
               }
             ]
           },
           "id": 1
       }

Fuente

CScript::getScriptsByEvents() en ui/include/classes/api/services/CScript.php.