script.getscriptsbyhosts
Description
object script.getscriptsbyhosts(array hostIds)
This method allows to retrieve scripts available on the given hosts.
This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.
Parameters
(string/array)
IDs of hosts to return scripts for.
Return values
(object)
Returns an object with host IDs as properties and arrays of available scripts as values.
The method will automatically expand macros in the confirmation
text and url
.
Examples
Retrieve scripts by host IDs
Retrieve all scripts available on hosts “30079” and “30073”.
{
"jsonrpc": "2.0",
"method": "script.getscriptsbyhosts",
"params": [
"30079",
"30073"
],
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": {
"30079": [
{
"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": "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": "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": "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
}
Source
CScript::getScriptsByHosts() in ui/include/classes/api/services/CScript.php.