script.getscriptsbyevents

Descripción

objeto script.getscriptsbyevents(parámetros de objeto)

Este método permite recuperar todos los scripts disponibles en el evento dado o un script específico si se proporciona el ID del script. Cuando se proporciona la entrada manual, sustituye la macro {MANUALINPUT} por el valor especificado.

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

Parámetros

(objeto/matriz) El método acepta un objeto o una matriz de objetos con los siguientes parámetros.

Parámetro Tipo Descripción
eventid ID ID del evento para el cual se devolverán los scripts.
Debe ser único.

Comportamiento del parámetro:
- obligatorio
scriptid ID ID del script a devolver.
manualinput cadena Valor del valor de macro {MANUALINPUT} proporcionado por el usuario.

Valores de retorno

(objeto) Devuelve un objeto con ID de evento como propiedades y matrices de scripts disponibles como valores. Si se proporciona el ID del script, el valor asociado es una matriz que contiene el script específico.

El método expandirá automáticamente las macros en el texto de "confirmation", texto de manualinput prompt y url.

Si se proporciona el parámetro de entrada manual, la macro {MANUALINPUT} se resolverá con el valor especificado.

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": [
             {
                "eventid":  "632"
             },
             {
                "eventid":  "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",
                       "manualinput": "0",
                       "manualinput_prompt": "",
                       "manualinput_validator_type": "0",
                       "manualinput_validator": "",
                       "manualinput_default_value": "",
                       "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",
                       "manualinput": "0",
                       "manualinput_prompt": "",
                       "manualinput_validator_type": "0",
                       "manualinput_validator": "",
                       "manualinput_default_value": "",
                       "parameters": []
                   },
                   {
                       "scriptid": "4",
                       "name": "Open Zabbix page",
                       "command": "",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "Are you sure you want to open page *UNKNOWN*?",
                       "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=*UNKNOWN*",
                       "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": []
                   },
                   {
                       "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",
                       "manualinput": "0",
                       "manualinput_prompt": "",
                       "manualinput_validator_type": "0",
                       "manualinput_validator": "",
                       "manualinput_default_value": "",
                       "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",
                       "manualinput": "0",
                       "manualinput_prompt": "",
                       "manualinput_validator_type": "1",
                       "manualinput_validator": "",
                       "manualinput_default_value": "",
                       "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",
                       "manualinput": "0",
                       "manualinput_prompt": "",
                       "manualinput_validator_type": "0",
                       "manualinput_validator": "",
                       "manualinput_default_value": "",
                       "parameters": []
                   },
                   {
                       "scriptid": "4",
                       "name": "Open Zabbix page",
                       "command": "",
                       "host_access": "2",
                       "usrgrpid": "0",
                       "groupid": "0",
                       "description": "",
                       "confirmation": "Are you sure you want to open page *UNKNOWN*?",
                       "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=*UNKNOWN*",
                       "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": []
                   },
                   {
                       "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",
                       "manualinput": "0",
                       "manualinput_prompt": "",
                       "manualinput_validator_type": "0",
                       "manualinput_validator": "",
                       "manualinput_default_value": "",
                       "parameters": []
                   }
               ]
           },
           "id": 1
       }

Recuperar un script específico con valor de entrada manual.

Recupere el script con ID "4" en el evento "632" con el valor de entrada manual "dashboard.view".

Solicitud:

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

Respuesta:

{
           "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.