Source
xxxxxxxxxx
static int vmware_job_exec(zbx_vmware_job_t *job, const char *config_source_ip, int config_vmware_timeout,
/*
** 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: returns string value of vmware job types *
* *
* Parameters: job - [IN] *
* *
* Return value: job type string *
* *
******************************************************************************/
static const char *vmware_job_type_string(zbx_vmware_job_t *job)
{
switch (job->type)
{
case ZBX_VMWARE_UPDATE_CONF:
return "update_conf";
case ZBX_VMWARE_UPDATE_PERFCOUNTERS:
return "update_perf_counters";
case ZBX_VMWARE_UPDATE_REST_TAGS:
return "update_tags";
case ZBX_VMWARE_UPDATE_EVENTLOG:
return "update_eventlog";
default:
return "unknown_job";
}
}
/******************************************************************************
* *
* Purpose: picks next job from queue and service ttl check *
* *
* Parameters: vmw - [IN] vmware object *
* time_now - [IN] *
* *
* Return value: job for object or NULL *
* *
******************************************************************************/
static zbx_vmware_job_t *vmware_job_get(zbx_vmware_t *vmw, time_t time_now)
{
zbx_binary_heap_elem_t *elem;
zbx_vmware_job_t *job = NULL;
time_t lastaccess;
int revision;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() queue:%d", __func__, vmw->jobs_queue.elems_num);
zbx_vmware_lock();
if (SUCCEED == zbx_binary_heap_empty(&vmw->jobs_queue))
goto unlock;
elem = zbx_binary_heap_find_min(&vmw->jobs_queue);
job = (zbx_vmware_job_t *)elem->data;
if (time_now < job->nextcheck)
{
job = NULL;
goto unlock;
}
zbx_binary_heap_remove_min(&vmw->jobs_queue);
job->nextcheck = 0;
lastaccess = (ZBX_VMWARE_UPDATE_EVENTLOG == job->type) ? job->service->eventlog.lastaccess :