integer/array script.get(object parameters)
El método permite recuperar scripts según los parámetros dados.
Este método está disponible para usuarios de cualquier tipo. Los permisos para llamar al método pueden ser revocados en la configuración de roles de usuario. Consulte Roles de usuario para más información.
(objeto)
Parámetros que definen la salida deseada.
El método admite los siguientes parámetros.
Parámetro | Tipo | Descripción |
---|---|---|
groupids | ID/array | Devolver solo los scripts que se pueden ejecutar en los grupos de equipos indicados. |
hostids | ID/array | Devolver solo los scripts que se pueden ejecutar en los equipos indicados. |
scriptids | ID/array | Devolver solo los scripts con los IDs indicados. |
usrgrpids | ID/array | Devolver solo los scripts que pueden ser ejecutados por usuarios en los grupos de usuarios indicados. |
selectHostGroups | query | Devolver una propiedad hostgroups con los grupos de equipos en los que se puede ejecutar el script. |
selectHosts | query | Devolver una propiedad hosts con los equipos en los que se puede ejecutar el script. |
selectActions | query | Devolver una propiedad actions con las acciones asociadas al script. |
sortfield | string/array | Ordenar el resultado por las propiedades indicadas. Valores posibles: scriptid , name . |
countOutput | boolean | Estos parámetros se describen en el comentario de referencia. |
editable | boolean | |
excludeSearch | boolean | |
filter | object | |
limit | integer | |
output | query | |
preservekeys | boolean | |
search | object | |
searchByAny | boolean | |
searchWildcardsEnabled | boolean | |
sortorder | string/array | |
startSearch | boolean |
(integer/array)
Devuelve:
countOutput
.Recuperar todos los scripts configurados.
Respuesta:
{
"jsonrpc": "2.0",
"result": [
{
"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": "",
"manualinput_validator_type": "0",
"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": "",
"manualinput_validator_type": "0",
"manualinput_default_value": "",
"parameters": []
},
{
"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": "",
"manualinput_validator_type": "0",
"manualinput_default_value": "",
"parameters": []
},
{
"scriptid": "4",
"name": "Webhook",
"command": "try {\n var request = new HttpRequest(),\n response,\n data;\n\n request.addHeader('Content-Type: application/json');\n\n response = request.post('https://localhost/post', value);\n\n try {\n response = JSON.parse(response);\n }\n catch (error) {\n response = null;\n }\n\n if (request.getStatus() !== 200 || !('data' in response)) {\n throw 'Unexpected response.';\n }\n\n data = JSON.stringify(response.data);\n\n Zabbix.log(3, '[Webhook Script] response data: ' + data);\n\n return data;\n}\ncatch (error) {\n Zabbix.log(3, '[Webhook Script] script execution failed: ' + error);\n throw 'Execution failed: ' + error + '.';\n}",
"host_access": "2",
"usrgrpid": "7",
"groupid": "0",
"description": "",
"confirmation": "",
"type": "5",
"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": "",
"manualinput_validator_type": "0",
"manualinput_default_value": "",
"parameters": [
{
"name": "token",
"value": "{$WEBHOOK.TOKEN}"
},
{
"name": "host",
"value": "{HOST.HOST}"
},
{
"name": "v",
"value": "2.2"
}
]
},
{
"scriptid": "5",
"name": "URL",
"command": "",
"host_access": "2",
"usrgrpid": "0",
"groupid": "0",
"description": "",
"confirmation": "Go to {HOST.NAME}?",
"type": "6",
"execute_on": "1",
"timeout": "30s",
"scope": "4",
"port": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"menu_path": "",
"url": "http://zabbix/ui/zabbix.php?action=latest.view&hostids[]={HOST.ID}",
"new_window": "0",
"manualinput": "0",
"manualinput_prompt": "",
"manualinput_validator": "",
"manualinput_validator_type": "0",
"manualinput_default_value": "",
"parameters": []
},
{
"scriptid": "6",
"name": "URL with user input",
"command": "",
"host_access": "2",
"usrgrpid": "0",
"groupid": "0",
"description": "",
"confirmation": "Open zabbix page {MANUALINPUT}?",
"type": "6",
"execute_on": "1",
"timeout": "30s",
"scope": "2",
"port": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"menu_path": "",
"url": "http://zabbix/ui/zabbix.php?action={MANUALINPUT}",
"new_window": "0",
"manualinput": "1",
"manualinput_prompt": "Seleccione una página para abrir:",
"manualinput_validator": "dashboard.view,script.list,actionlog.list",
"manualinput_validator_type": "1",
"parameters": []
}
],
"id": 1
}
CScript::get() en ui/include/classes/api/services/CScript.php.