Source
xxxxxxxxxx
['if' => static fn(array $_data): bool => (array_key_exists('tls_connect', $_data) && $_data['tls_connect'] == HOST_ENCRYPTION_PSK) || (array_key_exists('tls_accept', $_data) && ($_data['tls_accept'] & HOST_ENCRYPTION_PSK) != 0), 'type' => API_STRING_UTF8, 'flags' => API_REQUIRED | API_NOT_EMPTY, 'length' => DB::getFieldLength('hosts', 'tls_psk_identity')],
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
/**
* Class containing methods for operations with hosts.
*/
class CHost extends CHostGeneral {
protected $sortColumns = ['hostid', 'host', 'name', 'status'];
public const OUTPUT_FIELDS = ['hostid', 'host', 'monitored_by', 'proxyid', 'proxy_groupid', 'assigned_proxyid',
'status', 'ipmi_authtype', 'ipmi_privilege', 'ipmi_username', 'ipmi_password', 'maintenanceid',
'maintenance_status', 'maintenance_type', 'maintenance_from', 'name', 'flags', 'description', 'tls_connect',
'tls_accept', 'tls_issuer', 'tls_subject', 'inventory_mode', 'active_available'
];
/**
* Get host data.
*
* @param array $options
* @param array $options['groupids'] Select hosts by group IDs.
* @param array $options['hostids'] Select hosts by host IDs.
* @param array $options['proxyids'] Select hosts by proxy IDs.
* @param array $options['proxy_groupids'] Select hosts by proxy group IDs.
* @param array $options['templateids'] Select hosts by template IDs.
* @param array $options['interfaceids'] Select hosts by interface IDs.
* @param array $options['itemids'] Select hosts by item IDs.
* @param array $options['triggerids'] Select hosts by trigger IDs.
* @param array $options['maintenanceids'] Select hosts by maintenance IDs.
* @param array $options['graphids'] Select hosts by graph IDs.
* @param array $options['dserviceids'] Select hosts by discovery service IDs.
* @param array $options['httptestids'] Select hosts by web scenario IDs.
* @param bool $options['monitored_hosts'] Return only monitored hosts.
* @param bool $options['templated_hosts'] Include templates in result.
* @param bool $options['with_items'] Select hosts only with items.
* @param bool $options['with_item_prototypes'] Select hosts only with item prototypes.
* @param bool $options['with_simple_graph_items'] Select hosts only with items suitable for graphs.
* @param bool $options['with_simple_graph_item_prototypes'] Select hosts only with item prototypes suitable for graphs.
* @param bool $options['with_monitored_items'] Select hosts only with monitored items.
* @param bool $options['with_triggers'] Select hosts only with triggers.
* @param bool $options['with_monitored_triggers'] Select hosts only with monitored triggers.
* @param bool $options['with_httptests'] Select hosts only with http tests.
* @param bool $options['with_monitored_httptests'] Select hosts only with monitored http tests.
* @param bool $options['with_graphs'] Select hosts only with graphs.
* @param bool $options['with_graph_prototypes'] Select hosts only with graph prototypes.
* @param bool $options['withProblemsSuppressed'] Select hosts that have suppressed problems. (null - all, true - only suppressed, false - unsuppressed)
* @param bool $options['editable'] Select hosts only with read-write permission. Ignored for Super admins.
* @param bool $options['nopermissions'] Select hosts by ignoring all permissions. Only available inside API calls.
* @param bool $options['evaltype'] Operator for tag filter 0 - AND/OR; 2 - OR.
* @param bool $options['tags'] Select hosts by given tags.
* @param bool $options['severities'] Select hosts that have only problems with given severities.
* @param bool $options['inheritedTags'] Select hosts that have given tags also in their linked templates.
* @param string|array $options['selectHostGroups'] Return a "hostgroups" property with host groups data that the host belongs to.
* @param string|array $options['selectParentTemplates'] Return a "parentTemplates" property with templates that the host is linked to.
* @param string|array $options['selectItems'] Return an "items" property with host items.
* @param string|array $options['selectDiscoveries'] Return a "discoveries" property with host low-level discovery rules.
* @param string|array $options['selectTriggers'] Return a "triggers" property with host triggers.
* @param string|array $options['selectGraphs'] Return a "graphs" property with host graphs.
* @param string|array $options['selectMacros'] Return a "macros" property with host macros.
* @param string|array $options['selectDashboards'] Return a "dashboards" property with host dashboards.
* @param string|array $options['selectInterfaces'] Return an "interfaces" property with host interfaces.
* @param string|array $options['selectInventory'] Return an "inventory" property with host inventory data.
* @param string|array $options['selectHttpTests'] Return an "httpTests" property with host web scenarios.
* @param string|array $options['selectDiscoveryRule'] Return a "discoveryRule" property with the low-level discovery rule that created the host (from host prototype in VMware monitoring).
* @param string|array $options['selectHostDiscovery'] Return a "hostDiscovery" property with host discovery object data.
* @param string|array $options['selectTags'] Return a "tags" property with host tags.
* @param string|array $options['selectInheritedTags'] Return an "inheritedTags" property with tags that are on templates which are linked to host.
* @param bool $options['countOutput'] Return host count as output.
* @param bool $options['groupCount'] Group the host count.
* @param bool $options['preservekeys'] Return host IDs as array keys.
* @param string $options['sortfield'] Field to sort by.
* @param string $options['sortorder'] Sort order.
* @param int $options['limit'] Limit selection.
* @param int $options['limitSelects'] Limits the number of records returned by subselects.
*
* @return array|boolean Host data as array or false if error
*/
public function get($options = []) {