object script.getscriptsbyhosts(object parameters)
Este método permite recuperar todos los scripts disponibles en el equipo dado o un script específico si se proporciona el ID del script. Cuando se proporciona manualinput, 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 pueden ser revocados en la configuración del rol de usuario. Consulte Roles de usuario para más información.
(objeto/array)
El método acepta un objeto o un array de objetos con los siguientes parámetros.
Parámetro | Tipo | Descripción |
---|---|---|
hostid | ID | ID del equipo para devolver scripts. Debe ser único. Comportamiento del parámetro: - obligatorio |
scriptid | ID | ID del script a devolver. |
manualinput | string | Valor proporcionado por el usuario para la macro {MANUALINPUT}. |
(object)
Devuelve un objeto con los IDs de equipo como propiedades y arreglos de scripts disponibles como valores. Si se proporciona el ID de script, el valor asociado es un arreglo que contiene el script específico.
El método expandirá automáticamente las macros en el texto de confirmation
, el texto de manualinput prompt
y la url
.
Si se proporciona el parámetro manualinput, la macro {MANUALINPUT} se resolverá al valor especificado.
Recupera todos los scripts disponibles en los equipos "30079" y "30073".
{
"jsonrpc": "2.0",
"method": "script.getscriptsbyhosts",
"params": [
{
"hostid": "30079"
},
{
"hostid": "30073"
}
],
"id": 1
}
Respuesta:
{
"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",
"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": "2",
"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": "2",
"port": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"menu_path": "",
"url": "http://localhost/ui/zabbix.php?action=*UNKNOWN*",
"new_window": "1",
"manualinput": "0",
"manualinput_prompt": "Zabbix page to open:",
"manualinput_validator_type": "0",
"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": "2",
"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": []
}
],
"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",
"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": "2",
"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": "2",
"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": "2",
"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 el script con ID "4" en el equipo "30079" con el valor manualinput "dashboard.view".
{
"jsonrpc": "2.0",
"method": "script.getscriptsbyhosts",
"params": [
{
"hostid": "30079",
"scriptid": "4",
"manualinput": "dashboard.view"
}
],
"id": 1
}
Respuesta:
{
"jsonrpc": "2.0",
"result": {
"30079": [
{
"scriptid": "4",
"name": "Abrir página de Zabbix",
"command": "",
"host_access": "2",
"usrgrpid": "0",
"groupid": "0",
"description": "",
"confirmation": "¿Está seguro de que desea abrir la página 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": "Página de Zabbix a abrir:",
"manualinput_validator_type": "1",
"manualinput_validator": "dashboard.view,discovery.view",
"manualinput_default_value": "",
"parameters": []
}
]
},
"id": 1
}
CScript::getScriptsByHosts() en ui/include/classes/api/services/CScript.php.