You are viewing documentation for the development version, it may be incomplete.
Join our translation project and help translate Zabbix documentation into your native language.

script.getscriptsbyhosts

Beschrijving

object script.getscriptsbyhosts(array hostIds)

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

Deze methode is beschikbaar voor gebruikers van elk type. Rechten om de methode op te roepen kunnen worden ingetrokken in de instellingen van gebruikersrollen. Zie Gebruikersrollen voor meer informatie.

Parameters

(string/array) ID's van hosts om scripts voor te retourneren.

Teruggegeven waarden

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

De methode zal automatisch macro's uitbreiden in de confirmation-tekst en url.

Voorbeelden

Scripts ophalen op basis van host-ID's

Haal alle beschikbare scripts op van de hosts "30079" en "30073".

Aanvraag:

{
           "jsonrpc": "2.0",
           "method": "script.getscriptsbyhosts",
           "params": [
               "30079",
               "30073"
           ],
           "id": 1
       }

Reactie:

{
           "jsonrpc": "2.0",
           "result": {
               "30079": [
                   {
                       "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": "2",
                       "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": "2",
                       "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": "2",
                       "port": "",
                       "authtype": "0",
                       "username": "",
                       "password": "",
                       "publickey": "",
                       "privatekey": "",
                       "menu_path": "",
                       "url": "",
                       "new_window": "1",
                       "parameters": []
                   }
               ],
               "30073": [
                   {
                       "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": "2",
                       "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": "2",
                       "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": "2",
                       "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 host "30079" with manualinput value "dashboard.view".

Request:

{
           "jsonrpc": "2.0",
           "method": "script.getscriptsbyhosts",
           "params": [
             {
               "hostid":  "30079",
               "scriptid": "4",
               "manualinput": "dashboard.view"
             }
         ],
           "id": 1
       }

Response:

{
           "jsonrpc": "2.0",
           "result": {
             "30079": [
               {
                 "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": "2",
                 "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
       }

Bron

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