[comment]: # translation:outdated

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

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

[comment]: # ({e5635c19-cb7939c5})
### Beschrijving

`object script.getscriptsbyevents(array eventIds)`

Deze methode maakt het mogelijk om scripts op te halen die beschikbaar zijn voor de opgegeven gebeurtenissen.

::: noteclassic
Deze methode is beschikbaar voor gebruikers van elk type. Toestemming
om de methode op te roepen kan worden ingetrokken in de instellingen van gebruikersrollen. Zie [Gebruikersrollen](/handleiding/web_interface/frontend_sections/users/user_roles)
voor meer informatie.
:::

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

[comment]: # ({ccbedc39-9fca5465})
### Parameters

`(string/array)` IDs van gebeurtenissen waarvoor scripts moeten worden opgehaald.

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

[comment]: # ({66b5c952-cb6796f9})
### Retourwaarden

`(object)` Geeft een object terug met gebeurtenis-ID's als eigenschappen en arrays van beschikbare scripts als waarden.

::: notitietip
De methode zal automatisch macro's uitbreiden in de tekst van `bevestiging` en `url`.
:::

[comment]: # ({/66b5c952-cb6796f9})

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

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

[comment]: # ({5de5bd91-85e3003f})
#### Scripts ophalen op basis van gebeurtenis-ID's

Haal alle beschikbare scripts op voor gebeurtenissen "632" en "614".

[Aanvraag](/manual/api#performing-requests):

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

Reactie:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "632": [
            {
                "scriptid": "3",
                "name": "Besturingssysteem detecteren",
                "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": "Besturingssysteem detecteren",
                "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
}
```

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

[comment]: # ({new-efde3e92})
#### Retrieve specific script with manualinput value.

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

[Request](/manual/api#performing-requests):

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

Response:

```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]: # ({/new-efde3e92})

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

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

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