Source
xxxxxxxxxx
static void discovery_update_service_status(zbx_db_dhost *dhost, const DB_DSERVICE *dservice, int service_status,
/*
** Zabbix
** Copyright (C) 2001-2023 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
typedef struct
{
zbx_uint64_t dserviceid;
int status;
int lastup;
int lastdown;
char *value;
}
DB_DSERVICE;
static zbx_db_result_t discovery_get_dhost_by_value(zbx_uint64_t dcheckid, const char *value)
{
zbx_db_result_t result;
char *value_esc;
value_esc = zbx_db_dyn_escape_field("dservices", "value", value);
result = zbx_db_select(
"select dh.dhostid,dh.status,dh.lastup,dh.lastdown"
" from dhosts dh,dservices ds"
" where ds.dhostid=dh.dhostid"
" and ds.dcheckid=" ZBX_FS_UI64
" and ds.value" ZBX_SQL_STRCMP
" order by dh.dhostid",
dcheckid, ZBX_SQL_STRVAL_EQ(value_esc));
zbx_free(value_esc);
return result;
}
static zbx_db_result_t discovery_get_dhost_by_ip_port(zbx_uint64_t druleid, const char *ip, int port)
{
zbx_db_result_t result;
char *ip_esc;
ip_esc = zbx_db_dyn_escape_field("dservices", "ip", ip);
result = zbx_db_select(
"select dh.dhostid,dh.status,dh.lastup,dh.lastdown"
" from dhosts dh,dservices ds"
" where ds.dhostid=dh.dhostid"
" and dh.druleid=" ZBX_FS_UI64
" and ds.ip" ZBX_SQL_STRCMP
" and ds.port=%d"
" order by dh.dhostid",
druleid, ZBX_SQL_STRVAL_EQ(ip_esc), port);
zbx_free(ip_esc);
return result;
}
/******************************************************************************
* *
* Purpose: separate multiple-IP hosts *
* *
* Parameters: host ip address *
* *
******************************************************************************/
static void discovery_separate_host(zbx_uint64_t druleid, zbx_db_dhost *dhost, const char *ip)
{
zbx_db_result_t result;
char *ip_esc, *sql = NULL;
zbx_uint64_t dhostid;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() ip:'%s'", __func__, ip);