[comment]: # translation:outdated

[comment]: # ({20b62ccd-e03ef403})
# script.getscriptsbyevents

[comment]: # ({/20b62ccd-e03ef403})

[comment]: # ({5f198746-cb7939c5})
### Apraksts

`object script.getscriptsbyevents(object parameters)`

Šī metode ļauj izgūt visus pieejamos skriptus norādītajam notikumam
vai konkrētu skriptu, ja ir norādīts skripta ID. Ja ir norādīts manualinput,
tas aizstāj {MANUALINPUT} makrosu ar norādīto vērtību.

::: noteclassic
Šī metode ir pieejama jebkura tipa lietotājiem. Atļaujas
izsaukt šo metodi var tikt atsauktas lietotāja lomas iestatījumos. Skatiet [Lietotāju
lomas](/manual/web_interface/frontend_sections/users/user_roles)
papildinformācijai.
:::

[comment]: # ({/5f198746-cb7939c5})

[comment]: # ({aa7fc6d3-9fca5465})
### Parametri

`(object/array)` Metode pieņem objektu vai objektu masīvu ar šādiem parametriem.

|Parametrs|[Tips](/manual/api/reference_commentary#data-types)|Apraksts|
|--|--|------|
|eventid|ID|Atgriežamo skriptu notikuma ID.<br>Jābūt unikālam.<br><br>[Parametra darbība](/manual/api/reference_commentary#parameter-behavior):<br>- *obligāts*|
|scriptid|ID|Atgriežamā skripta ID.|
|manualinput|string|Lietotāja norādītās {MANUALINPUT} makro vērtība.|

[comment]: # ({/aa7fc6d3-9fca5465})

[comment]: # ({190a1ebe-cb6796f9})
### Atgrieztās vērtības

`(object)` Atgriež objektu, kurā notikumu ID ir kā īpašības un pieejamo skriptu masīvi ir kā
vērtības. Ja ir norādīts skripta ID, saistītā vērtība
ir masīvs, kas satur konkrēto skriptu.

::: notetip
Metode automātiski izvērsīs makrosus `confirmation` tekstā,
`manualinput prompt` tekstā un `url`.

Ja ir norādīts parametrs manualinput, makross {MANUALINPUT} tiks atrisināts uz norādīto vērtību.
:::

[comment]: # ({/190a1ebe-cb6796f9})

[comment]: # ({b41637d2-99e55c03})
### Piemēri

[comment]: # ({/b41637d2-99e55c03})

[comment]: # ({b86f8dbf-85e3003f})
#### Skriptu izgūšana pēc notikumu ID

Izgūst visus skriptus, kas pieejami notikumiem "632" un "614".

[Pieprasījums](/manual/api#performing-requests):

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

Atbilde:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "632": [
            {
                "scriptid": "3",
                "name": "Noteikt operētājsistēmu",
                "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": "http://localhost/ui/zabbix.php?action=*UNKNOWN*",
                "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": "Atvērt Zabbix lapu",
                "command": "",
                "host_access": "2",
                "usrgrpid": "0",
                "groupid": "0",
                "description": "",
                "confirmation": "Vai tiešām vēlaties atvērt lapu *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": "Atveramā Zabbix lapa:",
                "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": "Noteikt operētājsistēmu",
                "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": "Atvērt Zabbix lapu",
                "command": "",
                "host_access": "2",
                "usrgrpid": "0",
                "groupid": "0",
                "description": "",
                "confirmation": "Vai tiešām vēlaties atvērt lapu *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": "Atveramā Zabbix lapa:",
                "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
}
```

[comment]: # ({/b86f8dbf-85e3003f})

[comment]: # ({82e5ca46-efde3e92})
#### Konkrēta skripta izgūšana ar manualinput vērtību.

Izgūstiet skriptu ar ID "4" notikumam "632" ar manualinput vērtību "dashboard.view".

[Pieprasījums](/manual/api#performing-requests):

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

Atbilde:

```json
{
    "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
}
```

[comment]: # ({/82e5ca46-efde3e92})

[comment]: # ({7c5b73a2-d6be7880})
### Avots

CScript::getScriptsByEvents() failā
*ui/include/classes/api/services/CScript.php*.

[comment]: # ({/7c5b73a2-d6be7880})
