item.update

Description

object item.update(object/array **items**)

This method allows to update existing items.

Web items cannot be updated via the Zabbix API.

Parameters

(object/array) Item properties to be updated.

The itemid property must be defined for each item, all other properties are optional. Only the passed properties will be updated, all others will remain unchanged.

Additionally to the standard item properties, the method accepts the following parameters.

ParameterTypeDescription
applicationsarrayIDs of the applications to replace the current applications.
preprocessingarrayItem preprocessing options to replace the current preprocessing options.

Return values

(object) Returns an object containing the IDs of the updated items under the itemids property.

Examples

Enabling an item

Enable an item, that is, set its status to “0”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "item.update",
  4. "params": {
  5. "itemid": "10092",
  6. "status": 0
  7. },
  8. "auth": "700ca65537074ec963db7efabda78259",
  9. "id": 1
  10. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "itemids": [
  5. "10092"
  6. ]
  7. },
  8. "id": 1
  9. }

Update dependent item

Update Dependent item name and Master item ID. Only dependencies on same host are allowed, therefore Master and Dependent item should have same hostid.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "item.update",
  4. "params": {
  5. "name": "Dependent item updated name",
  6. "master_itemid": "25562",
  7. "itemid": "189019"
  8. },
  9. "auth": "700ca65537074ec963db7efabda78259",
  10. "id": 1
  11. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "itemids": [
  5. "189019"
  6. ]
  7. },
  8. "id": 1
  9. }

Update HTTP agent item

Enable item value trapping.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "item.update",
  4. "params": {
  5. "itemid": "23856",
  6. "allow_traps": "1"
  7. },
  8. "auth": "700ca65537074ec963db7efabda78259",
  9. "id": 1
  10. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "itemids": [
  5. "23856"
  6. ]
  7. },
  8. "id": 1
  9. }

Updating an item with preprocessing

Update an item with item preprocessing rule “In range”.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "item.update",
  4. "params": {
  5. "itemid": "23856",
  6. "preprocessing": [
  7. {
  8. "type": "13",
  9. "params": "\n100",
  10. "error_handler": "1",
  11. "error_handler_params": ""
  12. }
  13. ]
  14. },
  15. "auth": "700ca65537074ec963db7efabda78259",
  16. "id": 1
  17. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "itemids": [
  5. "23856"
  6. ]
  7. },
  8. "id": 1
  9. }

Source

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