On this page
graph.get
Descrizione
integer/array graph.get(object parameters)
Il metodo consente di recuperare i grafici in base ai parametri specificati.
Questo metodo è disponibile per utenti di qualsiasi tipo. Le autorizzazioni per chiamare il metodo possono essere revocate nelle impostazioni del ruolo utente. Vedere User roles per ulteriori informazioni.
Parametri
(object) Parametri che definiscono l'output desiderato.
Il metodo supporta i seguenti parametri.
| Parameter | Type | Description |
|---|---|---|
| graphids | ID/array | Restituisce solo i graph con gli ID specificati. |
| groupids | ID/array | Restituisce solo i graph che appartengono a host o template nei gruppi host o nei gruppi template specificati. |
| templateids | ID/array | Restituisce solo i graph che appartengono ai template specificati. |
| hostids | ID/array | Restituisce solo i graph che appartengono agli host specificati. |
| itemids | ID/array | Restituisce solo i graph che contengono gli item specificati. |
| templated | boolean | Se impostato su true, restituisce solo i graph che appartengono ai template. |
| inherited | boolean | Se impostato su true, restituisce solo i graph ereditati da un template. |
| expandName | flag | Espande le macro nel nome del graph. |
| selectHostGroups | query | Restituisce una proprietà hostgroups con i gruppi host a cui appartiene il graph. |
| selectTemplateGroups | query | Restituisce una proprietà templategroups con i gruppi template a cui appartiene il graph. |
| selectTemplates | query | Restituisce una proprietà templates con i template a cui appartiene il graph. |
| selectHosts | query | Restituisce una proprietà hosts con gli host a cui appartiene il graph. |
| selectItems | query | Restituisce una proprietà items con gli item usati nel graph. |
| selectGraphDiscovery | query | Restituisce una proprietà graphDiscovery con l'oggetto di discovery del graph. Gli oggetti di discovery del graph collegano il graph a un graph prototype da cui è stato creato.Ha le seguenti proprietà: graphid - (ID) ID del graph;parent_graphid - (ID) ID del graph prototype da cui il graph è stato creato;lastcheck - (timestamp) momento in cui il graph è stato rilevato l'ultima volta;status - (int) stato della discovery del graph:0 - (default) il graph è stato rilevato, 1 - il graph non è più rilevato; ts_delete - (timestamp) momento in cui un graph non più rilevato verrà eliminato. |
| selectGraphItems | query | Restituisce una proprietà gitems con gli item usati nel graph. |
| selectDiscoveryRule | query | Restituisce una proprietà discoveryRule con la regola di low-level discovery che ha creato il graph. |
| filter | object | Restituisce solo i risultati che corrispondono esattamente al filtro specificato. Accetta un oggetto in cui le chiavi sono nomi di proprietà e i valori sono un singolo valore o un array di valori da confrontare. Non supporta le proprietà di tipo data type text.Supporta proprietà aggiuntive: host - nome tecnico dell'host a cui appartiene il graph;hostid - ID dell'host a cui appartiene il graph. |
| sortfield | string/array | Ordina il risultato in base alle proprietà specificate. Valori possibili: graphid, name, graphtype. |
| countOutput | boolean | Questi parametri sono descritti nel commento di riferimento. |
| editable | boolean | |
| excludeSearch | boolean | |
| limit | integer | |
| output | query | |
| preservekeys | boolean | |
| search | object | |
| searchByAny | boolean | |
| searchWildcardsEnabled | boolean | |
| sortorder | string/array | |
| startSearch | boolean | |
| selectGroups (deprecated) |
query | Questo parametro è deprecato, usare invece selectHostGroups o selectTemplateGroups.Restituisce una proprietà groups con i gruppi host e i gruppi template a cui appartiene il graph. |
Valori restituiti
(integer/array) Restituisce o:
- una matrice di oggetti;
- il conteggio degli oggetti recuperati, se il parametro
countOutputè stato usato.
Esempi
Recupero dei grafici dagli host
Recupera tutti i grafici dall'host "10107" e ordinali per nome.
{
"jsonrpc": "2.0",
"method": "graph.get",
"params": {
"output": "extend",
"hostids": 10107,
"sortfield": "name"
},
"id": 1
}
Risposta:
{
"jsonrpc": "2.0",
"result": [
{
"graphid": "612",
"name": "CPU jumps",
"width": "900",
"height": "200",
"yaxismin": "0",
"yaxismax": "100",
"templateid": "439",
"show_work_period": "1",
"show_triggers": "1",
"graphtype": "0",
"show_legend": "1",
"show_3d": "0",
"percent_left": "0",
"percent_right": "0",
"ymin_type": "0",
"ymax_type": "0",
"ymin_itemid": "0",
"ymax_itemid": "0",
"flags": "0"
},
{
"graphid": "613",
"name": "CPU load",
"width": "900",
"height": "200",
"yaxismin": "0",
"yaxismax": "100",
"templateid": "433",
"show_work_period": "1",
"show_triggers": "1",
"graphtype": "0",
"show_legend": "1",
"show_3d": "0",
"percent_left": "0",
"percent_right": "0",
"ymin_type": "1",
"ymax_type": "0",
"ymin_itemid": "0",
"ymax_itemid": "0",
"flags": "0"
},
{
"graphid": "614",
"name": "CPU utilization",
"width": "900",
"height": "200",
"yaxismin": "0",
"yaxismax": "100",
"templateid": "387",
"show_work_period": "1",
"show_triggers": "0",
"graphtype": "1",
"show_legend": "1",
"show_3d": "0",
"percent_left": "0",
"percent_right": "0",
"ymin_type": "1",
"ymax_type": "1",
"ymin_itemid": "0",
"ymax_itemid": "0",
"flags": "0"
},
{
"graphid": "645",
"name": "Disk space usage /",
"width": "600",
"height": "340",
"yaxismin": "0",
"yaxismax": "0",
"templateid": "0",
"show_work_period": "0",
"show_triggers": "0",
"graphtype": "2",
"show_legend": "1",
"show_3d": "1",
"percent_left": "0",
"percent_right": "0",
"ymin_type": "0",
"ymax_type": "0",
"ymin_itemid": "0",
"ymax_itemid": "0",
"flags": "4"
}
],
"id": 1
}
Vedi anche
Fonte
CGraph::get() in ui/include/classes/api/services/CGraph.php.