SYNOPSIS

  use Zabbix::API::Item qw/:item_types/;

  # fetch a single item...
  my $item = $zabbix->fetch('Item', params => { filter => { itemid => 22379 } })->[0];

  # manipulate its properties...
  $item->data->{multiplier} = 3;

  # and update the properties on the server.
  $item->push;

  # fetch all items from a host
  my $host = $zabbix->fetch('Host', params => { filter => { hostid => 10105 } })->[0];
  my $items = $host->items;

  # create a new item
  my $new_item = Zabbix::API::Item->new(
      root => $zabbix,
      data => { type => ITEM_TYPE_SNMPV2C,
                value_type => ITEM_VALUE_TYPE_UINT64,
                snmp_oid => ...,
                snmp_community => ...,
                # that's right, key_
                key_ => 'mynewitem',
                # so far the following is the only way to create a "item belongs
                # to host" relationship
                hostid => $host->id,
      });

  # an itemid will be generated if the item does not already exist
  $new_item->push;

DESCRIPTION

Handles \s-1CRUD\s0 for Zabbix item objects.

This is a subclass of \*(C`Zabbix::API::CRUDE\*(C'; see there for inherited methods.

METHODS

collides()

Returns true if the item exists with this key on this hostid, false otherwise.

host()

Accessor for a local \*(C`host\*(C' attribute, which it also happens to set from the server data if it isn't set already. The host is an instance of \*(C`Zabbix::API::Host\*(C'.

graphs()

Like \*(C`host()\*(C', returning an arrayref of \*(C`Zabbix::API::Graph\*(C' instances in which this item is involved.

history(\s-1PARAMS\s0)

Accessor for the item's history data. Calling this method does not store the history data into the object, unlike other accessors. History data is an AoH: [ { itemid => ITEMID, clock => UNIX_TIMESTAMP, value => VALUE }, ... ] \*(C`PARAMS\*(C' should be a hash containing arguments for the \*(C`history.get\*(C' method (see here: <http://www.zabbix.com/documentation/1.8/api/history/get>). The time_from and time_till keys (with \s-1UNIX\s0 timestamps as values) are mandatory. The \*(C`itemids\*(C' and \*(C`output\*(C' parameters are already set and cannot be overwritten by the contents of \*(C`PARAMS\*(C'.

delay(\s-1NEW_DELAY\s0)

Mutator for the item's \*(C`delay\*(C' value; that is, the polling period in seconds. This is just a shortcut to set \*(C`delay\*(C' in the \*(C`data\*(C' hashref. The method doesn't call \*(C`pull()\*(C' or \*(C`push()\*(C', you need to do it manually. Returns the newly-set value.

EXPORTS

Way too many constants, but for once they're documented (here: <http://www.zabbix.com/documentation/1.8/api/item/constants>).

Nothing is exported by default; you can use the tags \*(C`:item_types\*(C', \*(C`:value_types\*(C', \*(C`:data_types\*(C' and \*(C`:status_types\*(C' (or import by name).

BUGS AND ODDITIES

This is probably because of the extremely smart way the Zabbix team has set up their database schema, but what you'd expect to be "key" in an item's data is actually "key_".

RELATED TO Zabbix::API::Item…

Zabbix::API::CRUDE.

AUTHOR

Fabrice Gabolde <[email protected]>

COPYRIGHT AND LICENSE

Copyright (C) 2011 \s-1SFR\s0

This library is free software; you can redistribute it and/or modify it under the terms of the GPLv3.