The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

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;
  my $templates = $host->templates;
  
  # 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 from the "interfaces" server property when the Perl object is updated (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.

You can add interfaces by pushing new Zabbix2::API::HostInterface objects onto this arrayref and then calling $host->update, or by instantiating interface objects with the hostid property set and calling $interface->create.

items

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

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

templates

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

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

SEE ALSO

Zabbix2::API::CRUDE.

AUTHOR

Fabrice Gabolde <fga@cpan.org>, Sujit Sali <sali.sujit@gmail.com>

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.