NAME

Zabbix7::API::Host -- Zabbix host objects

SYNOPSIS

use Zabbix7::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 = Zabbix7::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 => Zabbix7::API::HostInterface::INTERFACE_TYPE_AGENT,
            } ] });
$new_host->create;

DESCRIPTION

Handles CRUD for Zabbix host objects.

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

ATTRIBUTES

graphs

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

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

hostgroups

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

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

interfaces

(read-write arrayref of Zabbix7::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 Zabbix7::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 Zabbix7::API::Item objects)

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

templates

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

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

SEE ALSO

Zabbix7::API::CRUDE.

AUTHOR

SCOTTH

COPYRIGHT AND LICENSE

Copyright (C) 2011, 2012, 2013, 2014 SFR Copyright (C) 2020 Fabrice Gabolde Copyright (C) 2025 ScottH

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