"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/libs/zbxdbcache/dbconfig.c" between
zabbix-5.4.0.tar.gz and zabbix-5.4.1.tar.gz

About: ZABBIX is an enterprise-class distributed monitoring solution for servers and applications.

dbconfig.c  (zabbix-5.4.0):dbconfig.c  (zabbix-5.4.1)
skipping to change at line 2877 skipping to change at line 2877
ZBX_STR2UCHAR(value_type, row[4]); ZBX_STR2UCHAR(value_type, row[4]);
if (SUCCEED == DCstrpool_replace(found, &item->key, row[5])) if (SUCCEED == DCstrpool_replace(found, &item->key, row[5]))
flags |= ZBX_ITEM_KEY_CHANGED; flags |= ZBX_ITEM_KEY_CHANGED;
if (0 == found) if (0 == found)
{ {
item->triggers = NULL; item->triggers = NULL;
item->update_triggers = 0; item->update_triggers = 0;
item->nextcheck = 0; item->nextcheck = 0;
item->lastclock = 0;
item->state = (unsigned char)atoi(row[12]); item->state = (unsigned char)atoi(row[12]);
ZBX_STR2UINT64(item->lastlogsize, row[20]); ZBX_STR2UINT64(item->lastlogsize, row[20]);
item->mtime = atoi(row[21]); item->mtime = atoi(row[21]);
DCstrpool_replace(found, &item->error, row[27]); DCstrpool_replace(found, &item->error, row[27]);
item->data_expected_from = now; item->data_expected_from = now;
item->location = ZBX_LOC_NOWHERE; item->location = ZBX_LOC_NOWHERE;
item->poller_type = ZBX_NO_POLLER; item->poller_type = ZBX_NO_POLLER;
item->queue_priority = ZBX_QUEUE_PRIORITY_NORMAL; item->queue_priority = ZBX_QUEUE_PRIORITY_NORMAL;
item->schedulable = 1; item->schedulable = 1;
skipping to change at line 5170 skipping to change at line 5169
if (ZBX_DBSYNC_ROW_REMOVE == tag) if (ZBX_DBSYNC_ROW_REMOVE == tag)
break; break;
ZBX_STR2UINT64(triggerid, row[1]); ZBX_STR2UINT64(triggerid, row[1]);
if (NULL == (trigger = (ZBX_DC_TRIGGER *)zbx_hashset_search(&conf ig->triggers, &triggerid))) if (NULL == (trigger = (ZBX_DC_TRIGGER *)zbx_hashset_search(&conf ig->triggers, &triggerid)))
continue; continue;
ZBX_STR2UINT64(triggertagid, row[0]); ZBX_STR2UINT64(triggertagid, row[0]);
trigger_tag = (zbx_dc_trigger_tag_t *)DCfind_id(&config->trigger_ trigger_tag = (zbx_dc_trigger_tag_t *)DCfind_id(&config->trigger_
tags, triggertagid, sizeof(zbx_dc_trigger_tag_t), &found); tags, triggertagid,
sizeof(zbx_dc_trigger_tag_t), &found);
DCstrpool_replace(found, &trigger_tag->tag, row[2]); DCstrpool_replace(found, &trigger_tag->tag, row[2]);
DCstrpool_replace(found, &trigger_tag->value, row[3]); DCstrpool_replace(found, &trigger_tag->value, row[3]);
if (0 == found) if (0 == found)
{ {
trigger_tag->triggerid = triggerid; trigger_tag->triggerid = triggerid;
zbx_vector_ptr_append(&trigger->tags, trigger_tag); zbx_vector_ptr_append(&trigger->tags, trigger_tag);
} }
} }
skipping to change at line 6199 skipping to change at line 6199
/* relies on items, must be after DCsync_items() */ /* relies on items, must be after DCsync_items() */
sec = zbx_time(); sec = zbx_time();
DCsync_item_preproc(&itempp_sync, sec); DCsync_item_preproc(&itempp_sync, sec);
itempp_sec2 = zbx_time() - sec; itempp_sec2 = zbx_time() - sec;
/* relies on items, must be after DCsync_items() */ /* relies on items, must be after DCsync_items() */
sec = zbx_time(); sec = zbx_time();
DCsync_itemscript_param(&itemscrp_sync); DCsync_itemscript_param(&itemscrp_sync);
itemscrp_sec2 = zbx_time() - sec; itemscrp_sec2 = zbx_time() - sec;
/* relies on items, must be after DCsync_items() */
sec = zbx_time();
if (FAIL == zbx_dbsync_compare_item_tags(&item_tag_sync))
goto out;
item_tag_sec = zbx_time() - sec;
config->item_sync_ts = time(NULL); config->item_sync_ts = time(NULL);
FINISH_SYNC; FINISH_SYNC;
dc_flush_history(); /* misconfigured items generate pseudo-historic v alues to become notsupported */ dc_flush_history(); /* misconfigured items generate pseudo-historic v alues to become notsupported */
/* sync function data to support function lookups when resolving macros d uring configuration sync */ /* sync function data to support function lookups when resolving macros d uring configuration sync */
/* relies on items, must be after DCsync_items() */
sec = zbx_time();
if (FAIL == zbx_dbsync_compare_item_tags(&item_tag_sync))
goto out;
item_tag_sec = zbx_time() - sec;
sec = zbx_time(); sec = zbx_time();
if (FAIL == zbx_dbsync_compare_functions(&func_sync)) if (FAIL == zbx_dbsync_compare_functions(&func_sync))
goto out; goto out;
fsec = zbx_time() - sec; fsec = zbx_time() - sec;
START_SYNC; START_SYNC;
sec = zbx_time(); sec = zbx_time();
DCsync_functions(&func_sync); DCsync_functions(&func_sync);
fsec2 = zbx_time() - sec; fsec2 = zbx_time() - sec;
FINISH_SYNC; FINISH_SYNC;
skipping to change at line 7237 skipping to change at line 7237
if (MAINTENANCE_TYPE_NODATA != maintenance_type) if (MAINTENANCE_TYPE_NODATA != maintenance_type)
return FAIL; return FAIL;
if (ITEM_TYPE_INTERNAL == type) if (ITEM_TYPE_INTERNAL == type)
return FAIL; return FAIL;
return SUCCEED; return SUCCEED;
} }
static void DCget_host(DC_HOST *dst_host, const ZBX_DC_HOST *src_host) static void DCget_host(DC_HOST *dst_host, const ZBX_DC_HOST *src_host, unsign ed int mode)
{ {
const ZBX_DC_IPMIHOST *ipmihost; const ZBX_DC_IPMIHOST *ipmihost;
const ZBX_DC_HOST_INVENTORY *host_inventory; const ZBX_DC_HOST_INVENTORY *host_inventory;
dst_host->hostid = src_host->hostid; dst_host->hostid = src_host->hostid;
dst_host->proxy_hostid = src_host->proxy_hostid; dst_host->proxy_hostid = src_host->proxy_hostid;
strscpy(dst_host->host, src_host->host);
zbx_strlcpy_utf8(dst_host->name, src_host->name, sizeof(dst_host->name));
dst_host->maintenance_status = src_host->maintenance_status;
dst_host->maintenance_type = src_host->maintenance_type;
dst_host->maintenance_from = src_host->maintenance_from;
dst_host->status = src_host->status; dst_host->status = src_host->status;
dst_host->tls_connect = src_host->tls_connect;
dst_host->tls_accept = src_host->tls_accept;
#if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
strscpy(dst_host->tls_issuer, src_host->tls_issuer);
strscpy(dst_host->tls_subject, src_host->tls_subject);
if (NULL == src_host->tls_dc_psk) strscpy(dst_host->host, src_host->host);
{
*dst_host->tls_psk_identity = '\0'; if (ZBX_ITEM_GET_HOSTNAME & mode)
*dst_host->tls_psk = '\0'; zbx_strlcpy_utf8(dst_host->name, src_host->name, sizeof(dst_host-
} >name));
else
if (ZBX_ITEM_GET_MAINTENANCE & mode)
{ {
strscpy(dst_host->tls_psk_identity, src_host->tls_dc_psk->tls_psk dst_host->maintenance_status = src_host->maintenance_status;
_identity); dst_host->maintenance_type = src_host->maintenance_type;
strscpy(dst_host->tls_psk, src_host->tls_dc_psk->tls_psk); dst_host->maintenance_from = src_host->maintenance_from;
} }
#endif
if (NULL != (ipmihost = (ZBX_DC_IPMIHOST *)zbx_hashset_search(&config->ip if (ZBX_ITEM_GET_HOSTINFO & mode)
mihosts, &src_host->hostid)))
{ {
dst_host->ipmi_authtype = ipmihost->ipmi_authtype; dst_host->tls_connect = src_host->tls_connect;
dst_host->ipmi_privilege = ipmihost->ipmi_privilege; dst_host->tls_accept = src_host->tls_accept;
strscpy(dst_host->ipmi_username, ipmihost->ipmi_username); #if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
strscpy(dst_host->ipmi_password, ipmihost->ipmi_password); strscpy(dst_host->tls_issuer, src_host->tls_issuer);
strscpy(dst_host->tls_subject, src_host->tls_subject);
if (NULL == src_host->tls_dc_psk)
{
*dst_host->tls_psk_identity = '\0';
*dst_host->tls_psk = '\0';
}
else
{
strscpy(dst_host->tls_psk_identity, src_host->tls_dc_psk-
>tls_psk_identity);
strscpy(dst_host->tls_psk, src_host->tls_dc_psk->tls_psk)
;
}
#endif
if (NULL != (ipmihost = (ZBX_DC_IPMIHOST *)zbx_hashset_search(&co
nfig->ipmihosts, &src_host->hostid)))
{
dst_host->ipmi_authtype = ipmihost->ipmi_authtype;
dst_host->ipmi_privilege = ipmihost->ipmi_privilege;
strscpy(dst_host->ipmi_username, ipmihost->ipmi_username)
;
strscpy(dst_host->ipmi_password, ipmihost->ipmi_password)
;
}
else
{
dst_host->ipmi_authtype = ZBX_IPMI_DEFAULT_AUTHTYPE;
dst_host->ipmi_privilege = ZBX_IPMI_DEFAULT_PRIVILEGE;
*dst_host->ipmi_username = '\0';
*dst_host->ipmi_password = '\0';
}
} }
else
if (ZBX_ITEM_GET_INVENTORY & mode)
{ {
dst_host->ipmi_authtype = ZBX_IPMI_DEFAULT_AUTHTYPE; if (NULL != (host_inventory = (ZBX_DC_HOST_INVENTORY *)zbx_hashse
dst_host->ipmi_privilege = ZBX_IPMI_DEFAULT_PRIVILEGE; t_search(&config->host_inventories, &src_host->hostid)))
*dst_host->ipmi_username = '\0'; dst_host->inventory_mode = (char)host_inventory->inventor
*dst_host->ipmi_password = '\0'; y_mode;
else
dst_host->inventory_mode = HOST_INVENTORY_DISABLED;
} }
if (NULL != (host_inventory = (ZBX_DC_HOST_INVENTORY *)zbx_hashset_search
(&config->host_inventories, &src_host->hostid)))
dst_host->inventory_mode = (char)host_inventory->inventory_mode;
else
dst_host->inventory_mode = HOST_INVENTORY_DISABLED;
} }
/****************************************************************************** /******************************************************************************
* * * *
* Function: DCget_host_by_hostid * * Function: DCget_host_by_hostid *
* * * *
* Purpose: Locate host in configuration cache * * Purpose: Locate host in configuration cache *
* * * *
* Parameters: host - [OUT] pointer to DC_HOST structure * * Parameters: host - [OUT] pointer to DC_HOST structure *
* hostid - [IN] host ID from database * * hostid - [IN] host ID from database *
skipping to change at line 7311 skipping to change at line 7325
******************************************************************************/ ******************************************************************************/
int DCget_host_by_hostid(DC_HOST *host, zbx_uint64_t hostid) int DCget_host_by_hostid(DC_HOST *host, zbx_uint64_t hostid)
{ {
int ret = FAIL; int ret = FAIL;
const ZBX_DC_HOST *dc_host; const ZBX_DC_HOST *dc_host;
RDLOCK_CACHE; RDLOCK_CACHE;
if (NULL != (dc_host = (ZBX_DC_HOST *)zbx_hashset_search(&config->hosts, &hostid))) if (NULL != (dc_host = (ZBX_DC_HOST *)zbx_hashset_search(&config->hosts, &hostid)))
{ {
DCget_host(host, dc_host); DCget_host(host, dc_host, ZBX_ITEM_GET_ALL);
ret = SUCCEED; ret = SUCCEED;
} }
UNLOCK_CACHE; UNLOCK_CACHE;
return ret; return ret;
} }
/****************************************************************************** /******************************************************************************
* * * *
skipping to change at line 7591 skipping to change at line 7605
dst_interface->available = INTERFACE_AVAILABLE_UNKNOWN; dst_interface->available = INTERFACE_AVAILABLE_UNKNOWN;
dst_interface->disable_until = 0; dst_interface->disable_until = 0;
dst_interface->errors_from = 0; dst_interface->errors_from = 0;
*dst_interface->error = '\0'; *dst_interface->error = '\0';
} }
dst_interface->addr = (1 == dst_interface->useip ? dst_interface->ip_orig : dst_interface->dns_orig); dst_interface->addr = (1 == dst_interface->useip ? dst_interface->ip_orig : dst_interface->dns_orig);
dst_interface->port = 0; dst_interface->port = 0;
} }
static void DCget_item(DC_ITEM *dst_item, const ZBX_DC_ITEM *src_item) static void DCget_item(DC_ITEM *dst_item, const ZBX_DC_ITEM *src_item, unsign ed int mode)
{ {
const ZBX_DC_NUMITEM *numitem; const ZBX_DC_NUMITEM *numitem;
const ZBX_DC_LOGITEM *logitem; const ZBX_DC_LOGITEM *logitem;
const ZBX_DC_SNMPITEM *snmpitem; const ZBX_DC_SNMPITEM *snmpitem;
const ZBX_DC_SNMPINTERFACE *snmp; const ZBX_DC_SNMPINTERFACE *snmp;
const ZBX_DC_TRAPITEM *trapitem; const ZBX_DC_TRAPITEM *trapitem;
const ZBX_DC_IPMIITEM *ipmiitem; const ZBX_DC_IPMIITEM *ipmiitem;
const ZBX_DC_DBITEM *dbitem; const ZBX_DC_DBITEM *dbitem;
const ZBX_DC_SSHITEM *sshitem; const ZBX_DC_SSHITEM *sshitem;
const ZBX_DC_TELNETITEM *telnetitem; const ZBX_DC_TELNETITEM *telnetitem;
const ZBX_DC_SIMPLEITEM *simpleitem; const ZBX_DC_SIMPLEITEM *simpleitem;
const ZBX_DC_JMXITEM *jmxitem; const ZBX_DC_JMXITEM *jmxitem;
const ZBX_DC_CALCITEM *calcitem; const ZBX_DC_CALCITEM *calcitem;
const ZBX_DC_INTERFACE *dc_interface; const ZBX_DC_INTERFACE *dc_interface;
const ZBX_DC_HTTPITEM *httpitem; const ZBX_DC_HTTPITEM *httpitem;
const ZBX_DC_SCRIPTITEM *scriptitem; const ZBX_DC_SCRIPTITEM *scriptitem;
dst_item->itemid = src_item->itemid;
dst_item->type = src_item->type; dst_item->type = src_item->type;
dst_item->value_type = src_item->value_type; dst_item->value_type = src_item->value_type;
strscpy(dst_item->key_orig, src_item->key);
dst_item->key = NULL;
dst_item->delay = zbx_strdup(NULL, src_item->delay);
dst_item->nextcheck = src_item->nextcheck;
dst_item->state = src_item->state; dst_item->state = src_item->state;
dst_item->lastclock = src_item->lastclock;
dst_item->flags = src_item->flags;
dst_item->lastlogsize = src_item->lastlogsize; dst_item->lastlogsize = src_item->lastlogsize;
dst_item->mtime = src_item->mtime; dst_item->mtime = src_item->mtime;
dst_item->history = src_item->history; dst_item->history = src_item->history;
dst_item->inventory_link = src_item->inventory_link; dst_item->inventory_link = src_item->inventory_link;
dst_item->valuemapid = src_item->valuemapid; dst_item->valuemapid = src_item->valuemapid;
dst_item->status = src_item->status; dst_item->status = src_item->status;
dst_item->history_sec = src_item->history_sec; dst_item->history_sec = src_item->history_sec;
strscpy(dst_item->key_orig, src_item->key);
if (ZBX_ITEM_GET_MISC & mode)
{
dst_item->itemid = src_item->itemid; /* set af
ter lock */
dst_item->flags = src_item->flags;
dst_item->key = NULL; /* set du
ring initialization */
}
dst_item->error = zbx_strdup(NULL, src_item->error); if (ZBX_ITEM_GET_DELAY & mode)
dst_item->delay = zbx_strdup(NULL, src_item->delay); /* not us
ed, should be initialized */
if ((ZBX_ITEM_GET_EMPTY_ERROR & mode) || '\0' != *src_item->error)
/* allocate after lock */
dst_item->error = zbx_strdup(NULL, src_item->error);
switch (src_item->value_type) switch (src_item->value_type)
{ {
case ITEM_VALUE_TYPE_FLOAT: case ITEM_VALUE_TYPE_FLOAT:
case ITEM_VALUE_TYPE_UINT64: case ITEM_VALUE_TYPE_UINT64:
numitem = (ZBX_DC_NUMITEM *)zbx_hashset_search(&config->n if (0 != (ZBX_ITEM_GET_NUM & mode))
umitems, &src_item->itemid); {
numitem = (ZBX_DC_NUMITEM *)zbx_hashset_search(&c
onfig->numitems, &src_item->itemid);
dst_item->trends = numitem->trends; dst_item->trends = numitem->trends;
dst_item->trends_sec = numitem->trends_sec; dst_item->trends_sec = numitem->trends_sec;
dst_item->units = zbx_strdup(NULL, numitem->units);
/* allocate after lock */
if (0 != (ZBX_ITEM_GET_EMPTY_UNITS & mode) || '\0
' != *numitem->units)
dst_item->units = zbx_strdup(NULL, numite
m->units);
}
break; break;
case ITEM_VALUE_TYPE_LOG: case ITEM_VALUE_TYPE_LOG:
if (NULL != (logitem = (ZBX_DC_LOGITEM *)zbx_hashset_sear if (ZBX_ITEM_GET_LOGTIMEFMT & mode)
ch(&config->logitems, &src_item->itemid))) {
strscpy(dst_item->logtimefmt, logitem->logtimefmt if (NULL != (logitem = (ZBX_DC_LOGITEM *)zbx_hash
); set_search(&config->logitems,
else &src_item->itemid)))
*dst_item->logtimefmt = '\0'; {
strscpy(dst_item->logtimefmt, logitem->lo
gtimefmt);
}
else
*dst_item->logtimefmt = '\0';
}
break; break;
} }
if (ZBX_ITEM_GET_INTERFACE & mode) /* not used by history syncer */
{
dc_interface = (ZBX_DC_INTERFACE *)zbx_hashset_search(&config->in
terfaces, &src_item->interfaceid);
DCget_interface(&dst_item->interface, dc_interface);
}
if (0 == (ZBX_ITEM_GET_POLLINFO & mode)) /* not used by history sy
ncer */
return;
switch (src_item->type) switch (src_item->type)
{ {
case ITEM_TYPE_SNMP: case ITEM_TYPE_SNMP:
snmpitem = (ZBX_DC_SNMPITEM *)zbx_hashset_search(&config- >snmpitems, &src_item->itemid); snmpitem = (ZBX_DC_SNMPITEM *)zbx_hashset_search(&config- >snmpitems, &src_item->itemid);
snmp = (ZBX_DC_SNMPINTERFACE *)zbx_hashset_search(&config ->interfaces_snmp, &src_item->interfaceid); snmp = (ZBX_DC_SNMPINTERFACE *)zbx_hashset_search(&config ->interfaces_snmp, &src_item->interfaceid);
if (NULL != snmpitem && NULL != snmp) if (NULL != snmpitem && NULL != snmp)
{ {
strscpy(dst_item->snmp_community_orig, snmp->comm unity); strscpy(dst_item->snmp_community_orig, snmp->comm unity);
strscpy(dst_item->snmp_oid_orig, snmpitem->snmp_o id); strscpy(dst_item->snmp_oid_orig, snmpitem->snmp_o id);
skipping to change at line 7898 skipping to change at line 7943
else else
{ {
dst_item->params = zbx_strdup(NULL, ""); dst_item->params = zbx_strdup(NULL, "");
dst_item->formula_bin = NULL; dst_item->formula_bin = NULL;
} }
break; break;
default: default:
/* nothing to do */; /* nothing to do */;
} }
dc_interface = (ZBX_DC_INTERFACE *)zbx_hashset_search(&config->interfaces
, &src_item->interfaceid);
DCget_interface(&dst_item->interface, dc_interface);
} }
void DCconfig_clean_items(DC_ITEM *items, int *errcodes, size_t num) void DCconfig_clean_items(DC_ITEM *items, int *errcodes, size_t num)
{ {
size_t i; size_t i;
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
{ {
if (NULL != errcodes && SUCCEED != errcodes[i]) if (NULL != errcodes && SUCCEED != errcodes[i])
continue; continue;
skipping to change at line 8088 skipping to change at line 8129
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
{ {
if (NULL == (dc_host = DCfind_host(keys[i].host)) || if (NULL == (dc_host = DCfind_host(keys[i].host)) ||
NULL == (dc_item = DCfind_item(dc_host->hostid, k eys[i].key))) NULL == (dc_item = DCfind_item(dc_host->hostid, k eys[i].key)))
{ {
errcodes[i] = FAIL; errcodes[i] = FAIL;
continue; continue;
} }
DCget_host(&items[i].host, dc_host); DCget_host(&items[i].host, dc_host, ZBX_ITEM_GET_ALL);
DCget_item(&items[i], dc_item); DCget_item(&items[i], dc_item, ZBX_ITEM_GET_ALL);
errcodes[i] = SUCCEED; errcodes[i] = SUCCEED;
} }
UNLOCK_CACHE; UNLOCK_CACHE;
} }
int DCconfig_get_hostid_by_name(const char *host, zbx_uint64_t *hostid) int DCconfig_get_hostid_by_name(const char *host, zbx_uint64_t *hostid)
{ {
const ZBX_DC_HOST *dc_host; const ZBX_DC_HOST *dc_host;
int ret; int ret;
skipping to change at line 8147 skipping to change at line 8188
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
{ {
if (NULL == (dc_item = (ZBX_DC_ITEM *)zbx_hashset_search(&config- >items, &itemids[i])) || if (NULL == (dc_item = (ZBX_DC_ITEM *)zbx_hashset_search(&config- >items, &itemids[i])) ||
NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_sea rch(&config->hosts, &dc_item->hostid))) NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_sea rch(&config->hosts, &dc_item->hostid)))
{ {
errcodes[i] = FAIL; errcodes[i] = FAIL;
continue; continue;
} }
DCget_host(&items[i].host, dc_host); DCget_host(&items[i].host, dc_host, ZBX_ITEM_GET_ALL);
DCget_item(&items[i], dc_item); DCget_item(&items[i], dc_item, ZBX_ITEM_GET_ALL);
errcodes[i] = SUCCEED; errcodes[i] = SUCCEED;
} }
UNLOCK_CACHE; UNLOCK_CACHE;
} }
void DCconfig_get_items_by_itemids_partial(DC_ITEM *items, const zbx_uint64_t
*itemids, int *errcodes, size_t num,
unsigned int mode)
{
size_t i;
const ZBX_DC_ITEM *dc_item;
const ZBX_DC_HOST *dc_host = NULL;
memset(items, 0, sizeof(DC_ITEM) * (size_t)num);
memset(errcodes, 0, sizeof(int) * (size_t)num);
RDLOCK_CACHE;
for (i = 0; i < num; i++)
{
if (NULL == (dc_item = (ZBX_DC_ITEM *)zbx_hashset_search(&config-
>items, &itemids[i])))
{
errcodes[i] = FAIL;
continue;
}
if (NULL == dc_host || dc_host->hostid != dc_item->hostid)
{
if (NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_search(
&config->hosts, &dc_item->hostid)))
{
errcodes[i] = FAIL;
continue;
}
}
DCget_host(&items[i].host, dc_host, mode);
DCget_item(&items[i], dc_item, mode);
}
UNLOCK_CACHE;
/* avoid unnecessary allocations inside lock if there are no error or uni
ts */
for (i = 0; i < num; i++)
{
if (FAIL == errcodes[i])
continue;
items[i].itemid = itemids[i];
if (NULL == items[i].error)
items[i].error = zbx_strdup(NULL, "");
if (ITEM_VALUE_TYPE_FLOAT == items[i].value_type || ITEM_VALUE_TY
PE_UINT64 == items[i].value_type)
{
if (NULL == items[i].units)
items[i].units = zbx_strdup(NULL, "");
}
}
}
/****************************************************************************** /******************************************************************************
* * * *
* Function: dc_preproc_item_init * * Function: dc_preproc_item_init *
* * * *
* Purpose: initialize new preprocessor item from configuration cache * * Purpose: initialize new preprocessor item from configuration cache *
* * * *
* Parameters: item - [OUT] the item to initialize * * Parameters: item - [OUT] the item to initialize *
* itemid - [IN] the item identifier * * itemid - [IN] the item identifier *
* * * *
* Return value: SUCCEED - the item was initialized successfully * * Return value: SUCCEED - the item was initialized successfully *
skipping to change at line 8322 skipping to change at line 8417
for (i = 0; i < num; i++) for (i = 0; i < num; i++)
{ {
if (NULL == (dc_item = (ZBX_DC_ITEM *)zbx_hashset_search(&config- >items, &itemids[i])) || if (NULL == (dc_item = (ZBX_DC_ITEM *)zbx_hashset_search(&config- >items, &itemids[i])) ||
NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_sea rch(&config->hosts, &dc_item->hostid))) NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_sea rch(&config->hosts, &dc_item->hostid)))
{ {
errcodes[i] = FAIL; errcodes[i] = FAIL;
continue; continue;
} }
DCget_host(&hosts[i], dc_host); DCget_host(&hosts[i], dc_host, ZBX_ITEM_GET_ALL);
errcodes[i] = SUCCEED; errcodes[i] = SUCCEED;
} }
UNLOCK_CACHE; UNLOCK_CACHE;
} }
void DCconfig_get_triggers_by_triggerids(DC_TRIGGER *triggers, const zbx_uint6 4_t *triggerids, int *errcode, void DCconfig_get_triggers_by_triggerids(DC_TRIGGER *triggers, const zbx_uint6 4_t *triggerids, int *errcode,
size_t num) size_t num)
{ {
size_t i; size_t i;
skipping to change at line 8557 skipping to change at line 8652
* Function: DCconfig_unlock_triggers * * Function: DCconfig_unlock_triggers *
* * * *
* Author: Aleksandrs Saveljevs * * Author: Aleksandrs Saveljevs *
* * * *
******************************************************************************/ ******************************************************************************/
void DCconfig_unlock_triggers(const zbx_vector_uint64_t *triggerids) void DCconfig_unlock_triggers(const zbx_vector_uint64_t *triggerids)
{ {
int i; int i;
ZBX_DC_TRIGGER *dc_trigger; ZBX_DC_TRIGGER *dc_trigger;
WRLOCK_CACHE; /* no other process can modify already locked triggers without write lock
*/
RDLOCK_CACHE;
for (i = 0; i < triggerids->values_num; i++) for (i = 0; i < triggerids->values_num; i++)
{ {
if (NULL == (dc_trigger = (ZBX_DC_TRIGGER *)zbx_hashset_search(&c onfig->triggers, &triggerids->values[i]))) if (NULL == (dc_trigger = (ZBX_DC_TRIGGER *)zbx_hashset_search(&c onfig->triggers, &triggerids->values[i])))
continue; continue;
dc_trigger->locked = 0; dc_trigger->locked = 0;
} }
UNLOCK_CACHE; UNLOCK_CACHE;
skipping to change at line 8847 skipping to change at line 8943
* hard_limit - [IN] the maximum number of timers to return * * hard_limit - [IN] the maximum number of timers to return *
* * * *
* Comments: This function locks corresponding triggers in configuration * * Comments: This function locks corresponding triggers in configuration *
* cache. * * cache. *
* If the returned timer has lock field set, then trigger is * * If the returned timer has lock field set, then trigger is *
* already being processed and should not be recalculated. * * already being processed and should not be recalculated. *
* * * *
******************************************************************************/ ******************************************************************************/
void zbx_dc_get_trigger_timers(zbx_vector_ptr_t *timers, int now, int soft_lim it, int hard_limit) void zbx_dc_get_trigger_timers(zbx_vector_ptr_t *timers, int now, int soft_lim it, int hard_limit)
{ {
zbx_trigger_timer_t *first_timer = NULL; zbx_trigger_timer_t *first_timer = NULL, *timer;
int found = 0;
zbx_binary_heap_elem_t *elem;
RDLOCK_CACHE;
if (SUCCEED != zbx_binary_heap_empty(&config->trigger_queue))
{
elem = zbx_binary_heap_find_min(&config->trigger_queue);
timer = (zbx_trigger_timer_t *)elem->data;
if (timer->exec_ts.sec <= now)
found = 1;
}
UNLOCK_CACHE;
if (0 == found)
return;
WRLOCK_CACHE; WRLOCK_CACHE;
while (SUCCEED != zbx_binary_heap_empty(&config->trigger_queue) && timers ->values_num < hard_limit) while (SUCCEED != zbx_binary_heap_empty(&config->trigger_queue) && timers ->values_num < hard_limit)
{ {
zbx_binary_heap_elem_t *elem;
zbx_trigger_timer_t *timer;
ZBX_DC_TRIGGER *dc_trigger; ZBX_DC_TRIGGER *dc_trigger;
elem = zbx_binary_heap_find_min(&config->trigger_queue); elem = zbx_binary_heap_find_min(&config->trigger_queue);
timer = (zbx_trigger_timer_t *)elem->data; timer = (zbx_trigger_timer_t *)elem->data;
if (timer->exec_ts.sec > now) if (timer->exec_ts.sec > now)
break; break;
/* first_timer stores the first timer from a list of timers of th e same trigger with the same */ /* first_timer stores the first timer from a list of timers of th e same trigger with the same */
/* evaluation timestamp. Reset first_timer if the conditions do n ot apply. */ /* evaluation timestamp. Reset first_timer if the conditions do n ot apply. */
skipping to change at line 9477 skipping to change at line 9589
max_items = DCconfig_get_suggested_snmp_v ars_nolock(dc_item->interfaceid, NULL); max_items = DCconfig_get_suggested_snmp_v ars_nolock(dc_item->interfaceid, NULL);
} }
} }
if (1 < max_items) if (1 < max_items)
*items = zbx_malloc(NULL, sizeof(DC_ITEM) * max_i tems); *items = zbx_malloc(NULL, sizeof(DC_ITEM) * max_i tems);
} }
dc_item_prev = dc_item; dc_item_prev = dc_item;
dc_item->location = ZBX_LOC_POLLER; dc_item->location = ZBX_LOC_POLLER;
DCget_host(&(*items)[num].host, dc_host); DCget_host(&(*items)[num].host, dc_host, ZBX_ITEM_GET_ALL);
DCget_item(&(*items)[num], dc_item); DCget_item(&(*items)[num], dc_item, ZBX_ITEM_GET_ALL);
num++; num++;
} }
UNLOCK_CACHE; UNLOCK_CACHE;
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%d", __func__, num); zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%d", __func__, num);
return num; return num;
} }
skipping to change at line 9570 skipping to change at line 9682
dc_requeue_item(dc_item, dc_host, dc_inte rface, dc_requeue_item(dc_item, dc_host, dc_inte rface,
ZBX_ITEM_COLLECTED | ZBX_ HOST_UNREACHABLE, now); ZBX_ITEM_COLLECTED | ZBX_ HOST_UNREACHABLE, now);
continue; continue;
} }
DCincrease_disable_until(dc_interface, now); DCincrease_disable_until(dc_interface, now);
} }
} }
dc_item->location = ZBX_LOC_POLLER; dc_item->location = ZBX_LOC_POLLER;
DCget_host(&items[num].host, dc_host); DCget_host(&items[num].host, dc_host, ZBX_ITEM_GET_ALL);
DCget_item(&items[num], dc_item); DCget_item(&items[num], dc_item, ZBX_ITEM_GET_ALL);
num++; num++;
} }
*nextcheck = dc_config_get_queue_nextcheck(&config->queues[ZBX_POLLER_TYP E_IPMI]); *nextcheck = dc_config_get_queue_nextcheck(&config->queues[ZBX_POLLER_TYP E_IPMI]);
UNLOCK_CACHE; UNLOCK_CACHE;
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%d", __func__, num); zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%d", __func__, num);
return num; return num;
skipping to change at line 9679 skipping to change at line 9791
if (SUCCEED == DCin_maintenance_without_data_collection(dc_host, dc_item)) if (SUCCEED == DCin_maintenance_without_data_collection(dc_host, dc_item))
continue; continue;
if (items_num == items_alloc) if (items_num == items_alloc)
{ {
items_alloc += 8; items_alloc += 8;
*items = (DC_ITEM *)zbx_realloc(*items, items_alloc * siz eof(DC_ITEM)); *items = (DC_ITEM *)zbx_realloc(*items, items_alloc * siz eof(DC_ITEM));
} }
DCget_host(&(*items)[items_num].host, dc_host); DCget_host(&(*items)[items_num].host, dc_host, ZBX_ITEM_GET_ALL);
DCget_item(&(*items)[items_num], dc_item); DCget_item(&(*items)[items_num], dc_item, ZBX_ITEM_GET_ALL);
items_num++; items_num++;
} }
unlock: unlock:
UNLOCK_CACHE; UNLOCK_CACHE;
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():" ZBX_FS_SIZE_T, __func__, (zbx_ fs_size_t)items_num); zabbix_log(LOG_LEVEL_DEBUG, "End of %s():" ZBX_FS_SIZE_T, __func__, (zbx_ fs_size_t)items_num);
return items_num; return items_num;
} }
skipping to change at line 11967 skipping to change at line 12079
{ {
if (NULL == (dc_function = (const ZBX_DC_FUNCTION *)zbx_hashset_s earch(&config->functions, &functionids[i]))) if (NULL == (dc_function = (const ZBX_DC_FUNCTION *)zbx_hashset_s earch(&config->functions, &functionids[i])))
continue; continue;
if (NULL == (dc_item = (const ZBX_DC_ITEM *)zbx_hashset_search(&c onfig->items, &dc_function->itemid))) if (NULL == (dc_item = (const ZBX_DC_ITEM *)zbx_hashset_search(&c onfig->items, &dc_function->itemid)))
continue; continue;
if (NULL == (dc_host = (const ZBX_DC_HOST *)zbx_hashset_search(&c onfig->hosts, &dc_item->hostid))) if (NULL == (dc_host = (const ZBX_DC_HOST *)zbx_hashset_search(&c onfig->hosts, &dc_item->hostid)))
continue; continue;
DCget_host(&host, dc_host); DCget_host(&host, dc_host, ZBX_ITEM_GET_ALL);
zbx_hashset_insert(hosts, &host, sizeof(host)); zbx_hashset_insert(hosts, &host, sizeof(host));
} }
} }
/****************************************************************************** /******************************************************************************
* * * *
* Function: DCget_hosts_by_functionids * * Function: DCget_hosts_by_functionids *
* * * *
* Purpose: get hosts for the specified list of functions * * Purpose: get hosts for the specified list of functions *
* * * *
skipping to change at line 12986 skipping to change at line 13098
* errcodes arrays * * errcodes arrays *
* * * *
******************************************************************************/ ******************************************************************************/
void zbx_dc_items_update_nextcheck(DC_ITEM *items, zbx_agent_value_t *values, int *errcodes, size_t values_num) void zbx_dc_items_update_nextcheck(DC_ITEM *items, zbx_agent_value_t *values, int *errcodes, size_t values_num)
{ {
size_t i; size_t i;
ZBX_DC_ITEM *dc_item; ZBX_DC_ITEM *dc_item;
ZBX_DC_HOST *dc_host; ZBX_DC_HOST *dc_host;
ZBX_DC_INTERFACE *dc_interface; ZBX_DC_INTERFACE *dc_interface;
WRLOCK_CACHE; RDLOCK_CACHE;
for (i = 0; i < values_num; i++) for (i = 0; i < values_num; i++)
{ {
if (FAIL == errcodes[i]) if (FAIL == errcodes[i])
continue; continue;
/* update nextcheck for items that are counted in queue for monit
oring purposes */
if (FAIL == zbx_is_counted_in_item_queue(items[i].type, items[i].
key_orig))
continue;
if (NULL == (dc_item = (ZBX_DC_ITEM *)zbx_hashset_search(&config- >items, &items[i].itemid))) if (NULL == (dc_item = (ZBX_DC_ITEM *)zbx_hashset_search(&config- >items, &items[i].itemid)))
continue; continue;
if (ITEM_STATUS_ACTIVE != dc_item->status) if (ITEM_STATUS_ACTIVE != dc_item->status)
continue; continue;
if (NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_search(&config- >hosts, &dc_item->hostid))) if (NULL == (dc_host = (ZBX_DC_HOST *)zbx_hashset_search(&config- >hosts, &dc_item->hostid)))
continue; continue;
if (HOST_STATUS_MONITORED != dc_host->status) if (HOST_STATUS_MONITORED != dc_host->status)
continue; continue;
if (ZBX_LOC_NOWHERE != dc_item->location) if (ZBX_LOC_NOWHERE != dc_item->location)
continue; continue;
dc_interface = (ZBX_DC_INTERFACE *)zbx_hashset_search(&config->in terfaces, &dc_item->interfaceid); dc_interface = (ZBX_DC_INTERFACE *)zbx_hashset_search(&config->in terfaces, &dc_item->interfaceid);
/* update nextcheck for items that are counted in queue for monit oring purposes */ /* update nextcheck for items that are counted in queue for monit oring purposes */
if (SUCCEED == zbx_is_counted_in_item_queue(dc_item->type, dc_ite DCitem_nextcheck_update(dc_item, dc_interface, ZBX_ITEM_COLLECTED
m->key)) , values[i].ts.sec,
DCitem_nextcheck_update(dc_item, dc_interface, ZBX_ITEM_C NULL);
OLLECTED, values[i].ts.sec,
NULL);
} }
UNLOCK_CACHE; UNLOCK_CACHE;
} }
/****************************************************************************** /******************************************************************************
* * * *
* Function: zbx_dc_get_host_interfaces * * Function: zbx_dc_get_host_interfaces *
* * * *
* Purpose: get data of all network interfaces for a host in configuration * * Purpose: get data of all network interfaces for a host in configuration *
skipping to change at line 13135 skipping to change at line 13250
dc_item->lastlogsize = diff->lastlogsize; dc_item->lastlogsize = diff->lastlogsize;
if (0 != (ZBX_FLAGS_ITEM_DIFF_UPDATE_MTIME & diff->flags)) if (0 != (ZBX_FLAGS_ITEM_DIFF_UPDATE_MTIME & diff->flags))
dc_item->mtime = diff->mtime; dc_item->mtime = diff->mtime;
if (0 != (ZBX_FLAGS_ITEM_DIFF_UPDATE_ERROR & diff->flags)) if (0 != (ZBX_FLAGS_ITEM_DIFF_UPDATE_ERROR & diff->flags))
DCstrpool_replace(1, &dc_item->error, diff->error); DCstrpool_replace(1, &dc_item->error, diff->error);
if (0 != (ZBX_FLAGS_ITEM_DIFF_UPDATE_STATE & diff->flags)) if (0 != (ZBX_FLAGS_ITEM_DIFF_UPDATE_STATE & diff->flags))
dc_item->state = diff->state; dc_item->state = diff->state;
if (0 != (ZBX_FLAGS_ITEM_DIFF_UPDATE_LASTCLOCK & diff->flags))
dc_item->lastclock = diff->lastclock;
} }
UNLOCK_CACHE; UNLOCK_CACHE;
} }
/****************************************************************************** /******************************************************************************
* * * *
* Function: DCconfig_update_inventory_values * * Function: DCconfig_update_inventory_values *
* * * *
* Purpose: update automatic inventory in configuration cache * * Purpose: update automatic inventory in configuration cache *
 End of changes. 44 change blocks. 
98 lines changed or deleted 229 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)