[comment]: # ({58fbd3bc-58fbd3bc})
# item.get

[comment]: # ({/58fbd3bc-58fbd3bc})

[comment]: # ({14484745-673edf7f})
### Descrizione

`integer/array item.get(object parameters)`

Il metodo consente di recuperare gli item in base ai parametri specificati.

::: noteclassic
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](/manual/web_interface/frontend_sections/users/user_roles)
.
:::

[comment]: # ({/14484745-673edf7f})

[comment]: # ({641397fb-cc946363})
### Parametri

`(object)` Parametri che definiscono l'output desiderato.

Il metodo supporta i seguenti parametri.

|Parameter|[Type](/manual/api/reference_commentary#data-types)|Description|
|--|--|------|
|itemids|ID/array|Restituisce solo gli item con gli ID specificati.|
|groupids|ID/array|Restituisce solo gli item che appartengono agli host dei gruppi specificati.|
|templateids|ID/array|Restituisce solo gli item che appartengono ai template specificati.|
|hostids|ID/array|Restituisce solo gli item che appartengono agli host specificati.|
|proxyids|ID/array|Restituisce solo gli item monitorati dai proxy specificati.|
|interfaceids|ID/array|Restituisce solo gli item che usano le interfacce host specificate.|
|graphids|ID/array|Restituisce solo gli item utilizzati nei grafici specificati.|
|triggerids|ID/array|Restituisce solo gli item utilizzati nei trigger specificati.|
|webitems|flag|Include gli web item nel risultato.|
|inherited|boolean|Se impostato su `true`, restituisce solo gli item ereditati da un template.|
|templated|boolean|Se impostato su `true`, restituisce solo gli item che appartengono ai template.|
|monitored|boolean|Se impostato su `true`, restituisce solo gli item abilitati che appartengono a host monitorati.|
|group|string|Restituisce solo gli item che appartengono a un gruppo con il nome specificato.|
|host|string|Restituisce solo gli item che appartengono a un host con il nome specificato.|
|evaltype|integer|Metodo di [valutazione dei tag](/manual/web_interface/frontend_sections/data_collection/hosts/items#using-filter).<br><br>Valori possibili:<br>0 - *(default)* And/Or;<br>2 - Or.|
|tags|array|Restituisce solo gli item con i tag specificati.<br>Formato: `[{"tag": "<tag>", "value": "<value>", "operator": "<operator>"}, ...]`.<br>Un array vuoto restituisce tutti gli item.<br><br>Valori possibili di [operator](/manual/web_interface/frontend_sections/data_collection/hosts/items#using-filter):<br>0 - *(default)* Contains;<br>1 - Equals;<br>2 - Does not contain;<br>3 - Does not equal;<br>4 - Exists;<br>5 - Does not exist.|
|with\_triggers|boolean|Se impostato su `true`, restituisce solo gli item utilizzati nei trigger.|
|selectHosts|query|Restituisce una proprietà [`hosts`](/manual/api/reference/host/object) con un array di host a cui appartiene l'item.|
|selectInterfaces|query|Restituisce una proprietà [`interfaces`](/manual/api/reference/hostinterface/object) con un array di interfacce host usate dall'item.|
|selectTriggers|query|Restituisce una proprietà [`triggers`](/manual/api/reference/trigger/object) con i trigger in cui l'item è utilizzato.<br><br>Supporta `count`.|
|selectGraphs|query|Restituisce una proprietà [`graphs`](/manual/api/reference/graph/object) con i grafici che contengono l'item.<br><br>Supporta `count`.|
|selectDiscoveryData|query|Restituisce una proprietà `discoveryData` con i dati dell'oggetto di discovery dell'item. L'oggetto di discovery dell'item collega un item scoperto a un item prototype da cui è stato scoperto.<br><br>Ha le seguenti proprietà:<br>`parent_itemid` - `(string)` ID dell'item prototype da cui è stato creato l'item;<br>`key_` - `(string)` chiave dell'item prototype;<br>`status` - `(int)` stato di discovery dell'item:<br>0 - *(default)* l'item è scoperto,<br>1 - l'item non è più scoperto;<br>`ts_delete` - `(timestamp)` momento in cui un item non più scoperto verrà eliminato;<br>`ts_disable` - `(timestamp)` momento in cui un item non più scoperto verrà disabilitato;<br>`disable_source` - `(int)` indicatore che specifica se l'item è stato disabilitato da una regola LLD o manualmente:<br>0 - *(default)* disabilitato automaticamente,<br>1 - disabilitato da una regola LLD.|
|selectDiscoveryRule|query|Restituisce una proprietà [`discoveryRule`](/manual/api/reference/discoveryrule/object) con la regola LLD che ha creato l'item.|
|selectPreprocessing|query|Restituisce una proprietà [`preprocessing`](/manual/api/reference/item/object#item-preprocessing) con le opzioni di preprocessing dell'item.|
|selectTags|query|Restituisce i tag dell'item nella proprietà [`tags`](/manual/api/reference/item/object#item-tag).|
|selectValueMap|query|Restituisce una proprietà [`valuemap`](/manual/api/reference/valuemap/object) con la value map dell'item.|
|filter|object|Restituisce solo i risultati che corrispondono esattamente al filtro specificato.<br><br>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.<br><br>Non supporta le proprietà di tipo dati `text` [data type](/manual/api/reference_commentary#data-types).<br><br>Supporta proprietà aggiuntive:<br>`host` - nome tecnico dell'host a cui appartiene l'item.|
|limitSelects|integer|Limita il numero di record restituiti dalle sotto-selezioni.<br><br>Si applica alle seguenti sotto-selezioni:<br>`selectGraphs` - i risultati saranno ordinati per `name`;<br>`selectTriggers` - i risultati saranno ordinati per `description`.|
|sortfield|string/array|Ordina il risultato in base alle proprietà specificate.<br><br>Valori possibili: `itemid`, `name`, `key_`, `delay`, `history`, `trends`, `type`, `status`.|
|countOutput|boolean|Questi parametri sono descritti nella [reference commentary](/manual/api/reference_commentary#common-get-method-parameters).|
|editable|boolean|^|
|excludeSearch|boolean|^|
|limit|integer|^|
|output|query|^|
|preservekeys|boolean|^|
|search|object|^|
|searchByAny|boolean|^|
|searchWildcardsEnabled|boolean|^|
|sortorder|string/array|^|
|startSearch|boolean|^|
|selectItemDiscovery|query|Restituisce una proprietà `itemDiscovery` con l'oggetto di discovery dell'item. L'oggetto di discovery dell'item collega l'item a un item prototype da cui è stato creato.<br><br>Questa query è **deprecata**; usare invece `selectDiscoveryData`.|

[comment]: # ({/641397fb-cc946363})

[comment]: # ({7223bab1-7223bab1})
### Valori restituiti

`(integer/array)` Restituisce uno dei seguenti:

-   un array di oggetti;
-   il numero di oggetti recuperati, se è stato utilizzato il parametro `countOutput`.

[comment]: # ({/7223bab1-7223bab1})

[comment]: # ({b41637d2-b41637d2})
### Esempi

[comment]: # ({/b41637d2-b41637d2})

[comment]: # ({1a09225b-59b84d93})
#### Trovare gli item per chiave

Recupera tutti gli item usati nei trigger per uno specifico ID host che contengono la parola "system.cpu" nella chiave dell'item e ordina i risultati per nome.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "item.get",
    "params": {
        "output": "extend",
        "hostids": "10084",
        "with_triggers": true,
        "search": {
            "key_": "system.cpu"
        },
        "sortfield": "name"
    },
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "itemid": "42269",
            "type": "18",
            "snmp_oid": "",
            "hostid": "10084",
            "name": "CPU utilization",
            "key_": "system.cpu.util",
            "delay": "0",
            "history": "7d",
            "trends": "365d",
            "status": "0",
            "value_type": "0",
            "trapper_hosts": "",
            "units": "%",
            "logtimefmt": "",
            "templateid": "42267",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "0",
            "interfaceid": "0",
            "description": "CPU utilization in %.",
            "inventory_link": "0",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "42264",
            "timeout": "",
            "url": "",
            "query_fields": [],
            "posts": "",
            "status_codes": "200",
            "follow_redirects": "1",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "0",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "uuid": "",
            "state": "0",
            "error": "",
            "parameters": [],
            "lastclock": "0",
            "lastns": "0",
            "lastvalue": "0",
            "prevvalue": "0",
            "name_resolved": "CPU utilization"
        },
        {
            "itemid": "42259",
            "type": "0",
            "snmp_oid": "",
            "hostid": "10084",
            "name": "Load average (15m avg)",
            "key_": "system.cpu.load[all,avg15]",
            "delay": "1m",
            "history": "7d",
            "trends": "365d",
            "status": "0",
            "value_type": "0",
            "trapper_hosts": "",
            "units": "",
            "logtimefmt": "",
            "templateid": "42219",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "0",
            "interfaceid": "1",
            "description": "",
            "inventory_link": "0",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "0",
            "timeout": "",
            "url": "",
            "query_fields": [],
            "posts": "",
            "status_codes": "200",
            "follow_redirects": "1",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "0",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "uuid": "",
            "state": "0",
            "error": "",
            "parameters": [],
            "lastclock": "0",
            "lastns": "0",
            "lastvalue": "0",
            "prevvalue": "0",
            "name_resolved": "Load average (15m avg)"
        },
        {
            "itemid": "42249",
            "type": "0",
            "snmp_oid": "",
            "hostid": "10084",
            "name": "Load average (1m avg)",
            "key_": "system.cpu.load[all,avg1]",
            "delay": "1m",
            "history": "7d",
            "trends": "365d",
            "status": "0",
            "value_type": "0",
            "trapper_hosts": "",
            "units": "",
            "logtimefmt": "",
            "templateid": "42209",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "0",
            "interfaceid": "1",
            "description": "",
            "inventory_link": "0",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "0",
            "timeout": "",
            "url": "",
            "query_fields": [],
            "posts": "",
            "status_codes": "200",
            "follow_redirects": "1",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "0",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "uuid": "",
            "state": "0",
            "error": "",
            "parameters": [],
            "lastclock": "0",
            "lastns": "0",
            "lastvalue": "0",
            "prevvalue": "0",
            "name_resolved": "Load average (1m avg)"
        },
        {
            "itemid": "42257",
            "type": "0",
            "snmp_oid": "",
            "hostid": "10084",
            "name": "Load average (5m avg)",
            "key_": "system.cpu.load[all,avg5]",
            "delay": "1m",
            "history": "7d",
            "trends": "365d",
            "status": "0",
            "value_type": "0",
            "trapper_hosts": "",
            "units": "",
            "logtimefmt": "",
            "templateid": "42217",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "0",
            "interfaceid": "1",
            "description": "",
            "inventory_link": "0",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "0",
            "timeout": "",
            "url": "",
            "query_fields": [],
            "posts": "",
            "status_codes": "200",
            "follow_redirects": "1",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "0",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "uuid": "",
            "state": "0",
            "error": "",
            "parameters": [],
            "lastclock": "0",
            "lastns": "0",
            "lastvalue": "0",
            "prevvalue": "0",
            "name_resolved": "Load average (5m avg)"
        },
        {
            "itemid": "42260",
            "type": "0",
            "snmp_oid": "",
            "hostid": "10084",
            "name": "Number of CPUs",
            "key_": "system.cpu.num",
            "delay": "1m",
            "history": "7d",
            "trends": "365d",
            "status": "0",
            "value_type": "3",
            "trapper_hosts": "",
            "units": "",
            "logtimefmt": "",
            "templateid": "42220",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "0",
            "interfaceid": "1",
            "description": "",
            "inventory_link": "0",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "0",
            "timeout": "",
            "url": "",
            "query_fields": [],
            "posts": "",
            "status_codes": "200",
            "follow_redirects": "1",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "0",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "uuid": "",
            "state": "0",
            "error": "",
            "parameters": [],
            "lastclock": "0",
            "lastns": "0",
            "lastvalue": "0",
            "prevvalue": "0",
            "name_resolved": "Number of CPUs"
        }
    ],
    "id": 1
}
```

[comment]: # ({/1a09225b-59b84d93})

[comment]: # ({a6ae1426-674b0856})
#### Trovare gli item dipendenti per chiave

Recupera tutti gli item dipendenti dall'host con ID "10116" che hanno la parola "apache" nella chiave.

[Request](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "item.get",
    "params": {
        "output": "extend",
        "hostids": "10116",
        "search": {
            "key_": "apache"
        },
        "filter": {
            "type": 18
        }
    },
    "id": 1
}
```

Response:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "itemid": "25550",
            "type": "18",
            "snmp_oid": "",
            "hostid": "10116",
            "name": "Days",
            "key_": "apache.status.uptime.days",
            "delay": "0",
            "history": "90d",
            "trends": "365d",
            "status": "0",
            "value_type": "3",
            "trapper_hosts": "",
            "units": "",
            "logtimefmt": "",
            "templateid": "0",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "0",
            "interfaceid": "0",
            "description": "",
            "inventory_link": "0",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "25545",
            "timeout": "",
            "url": "",
            "query_fields": [],
            "posts": "",
            "status_codes": "200",
            "follow_redirects": "1",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "0",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "uuid": "",
            "state": "0",
            "error": "",
            "parameters": [],
            "lastclock": "0",
            "lastns": "0",
            "lastvalue": "0",
            "prevvalue": "0",
            "name_resolved": "Days"
        },
        {
            "itemid": "25555",
            "type": "18",
            "snmp_oid": "",
            "hostid": "10116",
            "name": "Hours",
            "key_": "apache.status.uptime.hours",
            "delay": "0",
            "history": "90d",
            "trends": "365d",
            "status": "0",
            "value_type": "3",
            "trapper_hosts": "",
            "units": "",
            "logtimefmt": "",
            "templateid": "0",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "0",
            "interfaceid": "0",
            "description": "",
            "inventory_link": "0",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "25545",
            "timeout": "",
            "url": "",
            "query_fields": [],
            "posts": "",
            "status_codes": "200",
            "follow_redirects": "1",
            "post_type": "0",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "0",
            "request_method": "0",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "uuid": "",
            "state": "0",
            "error": "",
            "parameters": [],
            "lastclock": "0",
            "lastns": "0",
            "lastvalue": "0",
            "prevvalue": "0",
            "name_resolved": "Hours"
        }
    ],
    "id": 1
}
```

[comment]: # ({/a6ae1426-674b0856})

[comment]: # ({256e2a05-94dc4b21})
#### Trova item HTTP agent

Trova un item HTTP agent con tipo di corpo post XML per uno specifico ID host.

[Richiesta](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "item.get",
    "params": {
        "hostids": "10255",
        "filter": {
            "type": 19,
            "post_type": 3
        }
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": [
        {
            "itemid": "28252",
            "type": "19",
            "snmp_oid": "",
            "hostid": "10255",
            "name": "template item",
            "key_": "ti",
            "delay": "30s",
            "history": "90d",
            "trends": "365d",
            "status": "0",
            "value_type": "3",
            "trapper_hosts": "",
            "units": "",
            "logtimefmt": "",
            "templateid": "0",
            "valuemapid": "0",
            "params": "",
            "ipmi_sensor": "",
            "authtype": "0",
            "username": "",
            "password": "",
            "publickey": "",
            "privatekey": "",
            "flags": "0",
            "interfaceid": "0",
            "description": "",
            "inventory_link": "0",
            "evaltype": "0",
            "jmx_endpoint": "",
            "master_itemid": "0",
            "timeout": "",
            "url": "localhost",
            "query_fields": [
                {
                    "name": "mode",
                    "value": "xml"
                }
            ],
            "posts": "<body>\r\n<![CDATA[{$MACRO}<foo></bar>]]>\r\n</body>",
            "status_codes": "200",
            "follow_redirects": "0",
            "post_type": "3",
            "http_proxy": "",
            "headers": [],
            "retrieve_mode": "1",
            "request_method": "3",
            "output_format": "0",
            "ssl_cert_file": "",
            "ssl_key_file": "",
            "ssl_key_password": "",
            "verify_peer": "0",
            "verify_host": "0",
            "allow_traps": "0",
            "uuid": "",
            "state": "0",
            "error": "",
            "parameters": [],
            "lastclock": "0",
            "lastns": "0",
            "lastvalue": "",
            "prevvalue": "",
            "name_resolved": "template item"
        }
    ],
    "id": 1
}
```

[comment]: # ({/256e2a05-94dc4b21})

[comment]: # ({6697de6d-f4b01bbe})
#### Recupero degli item con regole di preprocessing

Recupera tutti gli item e le relative regole di preprocessing per uno specifico ID host.

[Richiesta](/manual/api#performing-requests):

```json
{
    "jsonrpc": "2.0",
    "method": "item.get",
    "params": {
        "output": ["itemid", "name", "key_"],
        "selectPreprocessing": "extend",
        "hostids": "10254"
    },
    "id": 1
}
```

Risposta:

```json
{
    "jsonrpc": "2.0",
    "result": {
        "itemid": "23865",
        "name": "HTTP agent example JSON",
        "key_": "json",
        "preprocessing": [
            {
                "type": "12",
                "params": "$.random",
                "error_handler": "1",
                "error_handler_params": ""
            }
        ]
    },
    "id": 1
}
```

[comment]: # ({/6697de6d-f4b01bbe})

[comment]: # ({8d9fbd3b-d3276b35})
### Vedi anche

-   [Regola di individuazione](/manual/api/reference/discoveryrule/object#discovery-rule)
-   [Grafico](/manual/api/reference/graph/object#graph)
-   [Host](/manual/api/reference/host/object#host)
-   [Interfaccia host](/manual/api/reference/hostinterface/object#host-interface)
-   [Trigger](/manual/api/reference/trigger/object#trigger)

[comment]: # ({/8d9fbd3b-d3276b35})

[comment]: # ({a6ef1d0f-a6ef1d0f})
### Fonte

CItem::get() in *ui/include/classes/api/services/CItem.php*.

[comment]: # ({/a6ef1d0f-a6ef1d0f})
