Fabrice Gabolde

NAME

Zabbix2::API::Host -- Zabbix host objects

SYNOPSIS

  use Zabbix2::API::Host;
  # fetch a single host by ID
  my $host = $zabbix->fetch_single('Host', params => { hostids => [ 10105 ] });
  
  # and delete it
  $host->delete;
  
  # helpers -- these all fire an API call
  my $items = $host->items;
  my $hostgroups = $host->hostgroups;
  my $graphs = $host->graphs;
  
  # this one doesn't
  my $interfaces = $host->interfaces;
  
  # create a new host and its interfaces in one fell swoop
  my $new_host = Zabbix2::API::Host->new(
      root => $zabbix,
      data => {
          host => 'the internal zabbix hostname',
          name => 'the name displayed in most places',
          groups => [ { groupid => 4 } ],
          interfaces => [
              { dns => 'some hostname',
                ip => '',
                useip => 0,
                main => 1,
                port => 10000,
                type => Zabbix2::API::HostInterface::INTERFACE_TYPE_AGENT,
              } ] });
  $new_host->create;

DESCRIPTION

Handles CRUD for Zabbix host 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 with the host's graphs from the server.

hostgroups

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

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

interfaces

(read-write arrayref of Zabbix2::API::HostInterface instances)

This attribute is populated automatically when the Perl object is updated from the "interfaces" server property (i.e. when the pull method is called).

Likewise, it is automatically used to populate the "interfaces" property before either create or update are called.

Note that "interfaces" is a required property as far as the server is concerned, so you must define it one way or another.

items

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

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

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.