NAME

Zabbix2::API::Item -- Zabbix item objects

SYNOPSIS

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

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

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

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

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

# create a new item
my $new_item = Zabbix2::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',
              hostid => $host->id,
    });
$new_item->create;

DESCRIPTION

Handles CRUD for Zabbix item objects.

This is a subclass of Zabbix2::API::CRUDE; see there for inherited methods.

ATTRIBUTES

graphs

(read-only arrayref of Zabbix2::API::Graph objects)

This attribute is lazily populated from the server with the graphs containing the item.

host

(read-only Zabbix2::API::Host object)

This attribute is lazily populated with the item's host from the server.

METHODS

history

my $historical_data = $item->history(time_from => ...,
                                     ...);

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,
    ns => NANOSECONDS }, ... ]

The parameters should be suitable for the history.get method (see here). The itemids, output and history parameters are already set (to the item's ID, "extend" and the item's value type, respectively), but they can be overridden.

EXPORTS

Way too many constants, but for once they're documented (here: https://www.zabbix.com/documentation/2.2/manual/api/reference/item/object).

Nothing is exported by default; you can use the tags :item_types, :value_types, :data_types and :status_types (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_".

SEE ALSO

Zabbix2::API::CRUDE.

AUTHOR

Fabrice Gabolde <fga@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2011, 2014 SFR

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