On this page
hostprototype.get
Descrizione
integer/array hostprototype.get(object parameters)
Il metodo consente di recuperare i prototipi di host in base ai parametri specificati.
Questo metodo è disponibile per utenti di qualsiasi tipo. Le autorizzazioni per chiamare il metodo possono essere revocate nelle impostazioni dei ruoli utente. Per ulteriori informazioni, vedere Ruoli utente.
Parametri
(object) Parametri che definiscono l'output desiderato.
Il metodo supporta i seguenti parametri.
| Parameter | Type | Description |
|---|---|---|
| hostids | ID/array | Restituisce solo i host prototype con gli ID specificati. |
| discoveryids | ID/array | Restituisce solo i host prototype che appartengono alle LLD rule specificate. |
| inherited | boolean | Se impostato su true, restituisce solo gli item ereditati da un template. |
| selectDiscoveryData | query | Restituisce una proprietà discoveryData con i dati dell'oggetto di discovery del host prototype. L'oggetto di discovery del host prototype collega un host prototype scoperto a un host prototype da cui è stato scoperto.Ha le seguenti proprietà: host - (string) ID dell'host;parent_hostid - (string) ID del host prototype da cui è stato creato il host prototype;status - (int) stato di discovery del host prototype:0 - (default) il host prototype è scoperto, 1 - il host prototype non è più scoperto; ts_delete - (timestamp) momento in cui un host prototype che non è più scoperto verrà eliminato;ts_disable - (timestamp) momento in cui un host prototype che non è più scoperto verrà disabilitato;disable_source - (int) indicatore che mostra se il host prototype è stato disabilitato da una LLD rule o manualmente:0 - (default) disabilitato automaticamente, 1 - disabilitato da una LLD rule. |
| selectDiscoveryRule | query | Restituisce una proprietà discoveryRule con la LLD rule a cui appartiene il host prototype. |
| selectDiscoveryRulePrototype | query | Restituisce una proprietà discoveryRulePrototype con il parent LLD rule prototype a cui appartiene il host prototype. |
| selectInterfaces | query | Restituisce una proprietà interfaces con le interfacce personalizzate del host prototype. |
| selectGroupLinks | query | Restituisce una proprietà groupLinks con i group link del host prototype. |
| selectGroupPrototypes | query | Restituisce una proprietà groupPrototypes con i group prototype del host prototype. |
| selectMacros | query | Restituisce una proprietà macros con le macro del host prototype. |
| selectParentHost | query | Restituisce una proprietà parentHost con l'host a cui appartiene il host prototype. |
| selectTags | query | Restituisce una proprietà tags con i tag del host prototype. |
| selectTemplates | query | Restituisce una proprietà templates con i template collegati al host prototype.Supporta count. |
| sortfield | string/array | Ordina il risultato in base alle proprietà specificate. Valori possibili: hostid, host, name, status, discovered. |
| countOutput | boolean | Questi parametri sono descritti nella reference commentary. |
| editable | boolean | |
| excludeSearch | boolean | |
| filter | object | |
| limit | integer | |
| output | query | |
| preservekeys | boolean | |
| search | object | |
| searchByAny | boolean | |
| searchWildcardsEnabled | boolean | |
| sortorder | string/array | |
| startSearch | boolean |
Valori restituiti
(integer/array) Restituisce uno dei seguenti:
- un array di oggetti;
- il numero di oggetti recuperati, se è stato utilizzato il parametro
countOutput.
Esempi
Recupero dei prototipi di host da una regola LLD
Recupera tutti i prototipi di host, i relativi collegamenti ai gruppi, i prototipi di gruppo e i tag da una regola LLD.
{
"jsonrpc": "2.0",
"method": "hostprototype.get",
"params": {
"output": "extend",
"selectInterfaces": "extend",
"selectGroupLinks": "extend",
"selectGroupPrototypes": "extend",
"selectTags": "extend",
"discoveryids": "23554"
},
"id": 1
}
Risposta:
{
"jsonrpc": "2.0",
"result": [
{
"hostid": "10092",
"host": "{#HV.UUID}",
"name": "{#HV.UUID}",
"status": "0",
"templateid": "0",
"flags": "2",
"discover": "0",
"custom_interfaces": "1",
"inventory_mode": "-1",
"groupLinks": [
{
"group_prototypeid": "4",
"hostid": "10092",
"groupid": "7",
"templateid": "0"
}
],
"groupPrototypes": [
{
"group_prototypeid": "7",
"hostid": "10092",
"name": "{#CLUSTER.NAME}",
"templateid": "0"
}
],
"tags": [
{
"tag": "datacenter",
"value": "{#DATACENTER.NAME}"
},
{
"tag": "instance-type",
"value": "{#INSTANCE_TYPE}"
}
],
"interfaces": [
{
"main": "1",
"type": "2",
"useip": "1",
"ip": "127.0.0.1",
"dns": "",
"port": "161",
"details": {
"version": "2",
"bulk": "1",
"community": "{$SNMP_COMMUNITY}",
"max_repetitions": "10"
}
}
]
}
],
"id": 1
}
Vedi anche
Sorgente
CHostPrototype::get() in ui/include/classes/api/services/CHostPrototype.php.