Source
/*
** 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/>.
**/
/******************************************************************************
* *
* Purpose: initialize proxy group manager *
* *
******************************************************************************/
static void pgm_init(zbx_pg_cache_t *cache)
{
zbx_db_row_t row;
zbx_db_result_t result;
zbx_uint64_t map_revision = 0;
result = zbx_db_select("select nextid from ids where table_name='host_proxy' and field_name='revision'");
if (NULL != (row = zbx_db_fetch(result)))
ZBX_DBROW2UINT64(map_revision, row[0]);
zbx_db_free_result(result);
pg_cache_init(cache, map_revision);
}
/******************************************************************************
* *
* Purpose: update hosts and host-proxy group assignments from database *
* *
******************************************************************************/
static void pgm_db_get_hosts(zbx_pg_cache_t *cache)
{
zbx_db_row_t row;
zbx_db_result_t result;
result = zbx_db_select("select h.hostid,hp.proxyid,hp.revision,hp.hostproxyid,h.monitored_by,h.proxy_groupid"
" from hosts h"
" left join host_proxy hp"