"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/zabbix_server/vmware/vmware.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.

vmware.c  (zabbix-5.4.0):vmware.c  (zabbix-5.4.1)
skipping to change at line 297 skipping to change at line 297
#define ZBX_XPATH_EVT_INFO(param) \ #define ZBX_XPATH_EVT_INFO(param) \
"*[local-name()='" param "']/*[local-name()='name']" "*[local-name()='" param "']/*[local-name()='name']"
#define ZBX_XPATH_EVT_ARGUMENT(key) \ #define ZBX_XPATH_EVT_ARGUMENT(key) \
"*[local-name()='arguments'][*[local-name()='key'][text()='" key "']]/*[l ocal-name()='value']" "*[local-name()='arguments'][*[local-name()='key'][text()='" key "']]/*[l ocal-name()='value']"
#define ZBX_XPATH_VMWARE_ABOUT(property) \ #define ZBX_XPATH_VMWARE_ABOUT(property) \
"/*/*/*/*/*[local-name()='about']/*[local-name()='" property "']" "/*/*/*/*/*[local-name()='about']/*[local-name()='" property "']"
#define ZBX_XPATH_HV_SCSI_TOPOLOGY
\
"/*/*/*/*/*/*[local-name()='propSet'][*[local-name()='name']"
\
"[text()='config.storageDevice.scsiTopology']][1]"
\
"/*[local-name()='val']/*[local-name()='adapter']/*[local-name()=
'target']" \
"/*[local-name()='lun']/*[local-name()='scsiLun']"
#define ZBX_XPATH_HV_LUN()
\
"substring-before(substring-after(/*/*/*/*/*/*[local-name()='prop
Set']" \
"[*[local-name()='val'][text()='%s']][1]/*[local-name()='name'],'
\"'),'\"')"
#define ZBX_XPATH_HV_MULTIPATH(state)
\
"count(/*/*/*/*/*/*[local-name()='propSet'][1]/*[local-name()='va
l']" \
"/*[local-name()='lun'][*[local-name()='lun'][text()='%s']][1]"
\
"/*[local-name()='path']" state ")"
#define ZBX_XPATH_HV_MULTIPATH_PATHS() ZBX_XPATH_HV_MULTIPATH("")
#define ZBX_XPATH_HV_MULTIPATH_ACTIVE_PATHS() \ #define ZBX_XPATH_HV_MULTIPATH_ACTIVE_PATHS() \
"count(/*/*/*/*/*/*/*[local-name()='val']/*[local-name()='lun']" ZBX_XPATH_HV_MULTIPATH("[*[local-name()='state'][text()='active']
\ ]")
"/*[local-name()='path'][*[local-name()='state'][text()='active']
and " \
"../*[local-name()='id']=../../../../*[local-name()='propSet']/*[
local-name()='val']" \
"/*[local-name()='ScsiLun']/*[local-name()='uuid'][../*[local-nam
e()='canonicalName']" \
"[text()='%s']]])"
#define ZBX_XPATH_HV_MULTIPATH_PATHS()
\
"count(/*/*/*/*/*/*/*[local-name()='val']/*[local-name()='lun']"
\
"/*[local-name()='path'][../*[local-name()='id']=../../../../*[lo
cal-name()='propSet']" \
"/*[local-name()='val']/*[local-name()='ScsiLun']/*[local-name()=
'uuid']" \
"[../*[local-name()='canonicalName'][text()='%s']]])"
#define ZBX_XPATH_DS_INFO_EXTENT() \ #define ZBX_XPATH_DS_INFO_EXTENT() \
ZBX_XPATH_PROP_NAME("info") "/*/*[local-name()='extent']" ZBX_XPATH_PROP_NAME("info") "/*/*[local-name()='extent']"
# define ZBX_XPATH_NN(NN) "*[local-name()='" NN "']" # define ZBX_XPATH_NN(NN) "*[local-name()='" NN "']"
# define ZBX_XPATH_LN(LN) "/" ZBX_XPATH_NN(LN) # define ZBX_XPATH_LN(LN) "/" ZBX_XPATH_NN(LN)
# define ZBX_XPATH_LN1(LN1) "/" ZBX_XPATH_LN(LN1) # define ZBX_XPATH_LN1(LN1) "/" ZBX_XPATH_LN(LN1)
# define ZBX_XPATH_LN2(LN1, LN2) "/" ZBX_XPATH_LN(LN1) ZBX_XPATH_L N(LN2) # define ZBX_XPATH_LN2(LN1, LN2) "/" ZBX_XPATH_LN(LN1) ZBX_XPATH_L N(LN2)
# define ZBX_XPATH_LN3(LN1, LN2, LN3) "/" ZBX_XPATH_LN(LN1) ZBX_XPATH_L N(LN2) ZBX_XPATH_LN(LN3) # define ZBX_XPATH_LN3(LN1, LN2, LN3) "/" ZBX_XPATH_LN(LN1) ZBX_XPATH_L N(LN2) ZBX_XPATH_LN(LN3)
skipping to change at line 545 skipping to change at line 551
{ {
char *data; char *data;
size_t alloc; size_t alloc;
size_t offset; size_t offset;
} }
ZBX_HTTPPAGE; ZBX_HTTPPAGE;
static int zbx_xml_read_values(xmlDoc *xdoc, const char *xpath, zbx_vector_s tr_t *values); static int zbx_xml_read_values(xmlDoc *xdoc, const char *xpath, zbx_vector_s tr_t *values);
static int zbx_xml_try_read_value(const char *data, size_t len, const char * xpath, xmlDoc **xdoc, char **value, static int zbx_xml_try_read_value(const char *data, size_t len, const char * xpath, xmlDoc **xdoc, char **value,
char **error); char **error);
static int zbx_xml_read_doc_num(xmlDoc *xdoc, const char *xpath, int *num);
static char *zbx_xml_read_node_value(xmlDoc *doc, xmlNode *node, const char * xpath); static char *zbx_xml_read_node_value(xmlDoc *doc, xmlNode *node, const char * xpath);
static char *zbx_xml_read_doc_value(xmlDoc *xdoc, const char *xpath); static char *zbx_xml_read_doc_value(xmlDoc *xdoc, const char *xpath);
static size_t curl_write_cb(void *ptr, size_t size, size_t nmemb, void *userdat a) static size_t curl_write_cb(void *ptr, size_t size, size_t nmemb, void *userdat a)
{ {
size_t r_size = size * nmemb; size_t r_size = size * nmemb;
ZBX_HTTPPAGE *page_http = (ZBX_HTTPPAGE *)userdata; ZBX_HTTPPAGE *page_http = (ZBX_HTTPPAGE *)userdata;
zbx_strncpy_alloc(&page_http->data, &page_http->alloc, &page_http->offset , (const char *)ptr, r_size); zbx_strncpy_alloc(&page_http->data, &page_http->alloc, &page_http->offset , (const char *)ptr, r_size);
skipping to change at line 2873 skipping to change at line 2880
if (NULL == doc) if (NULL == doc)
return ret; return ret;
xpathCtx = xmlXPathNewContext(doc); xpathCtx = xmlXPathNewContext(doc);
if (NULL == (xpathObj = xmlXPathEvalExpression((xmlChar *) ZBX_XPATH_DS_I NFO_EXTENT(), xpathCtx))) if (NULL == (xpathObj = xmlXPathEvalExpression((xmlChar *) ZBX_XPATH_DS_I NFO_EXTENT(), xpathCtx)))
goto out; goto out;
if (0 != xmlXPathNodeSetIsEmpty(xpathObj->nodesetval)) if (0 != xmlXPathNodeSetIsEmpty(xpathObj->nodesetval))
{
xmlXPathFreeObject(xpathObj);
goto out; goto out;
}
nodeset = xpathObj->nodesetval; nodeset = xpathObj->nodesetval;
for (i = 0; i < nodeset->nodeNr; i++) for (i = 0; i < nodeset->nodeNr; i++)
{ {
if (NULL == (name = zbx_xml_read_node_value(doc, nodeset->nodeTab [i], ZBX_XPATH_NN("diskName")))) if (NULL == (name = zbx_xml_read_node_value(doc, nodeset->nodeTab [i], ZBX_XPATH_NN("diskName"))))
{ {
zabbix_log(LOG_LEVEL_DEBUG, "%s(): Cannot get diskName.", __func__); zabbix_log(LOG_LEVEL_DEBUG, "%s(): Cannot get diskName.", __func__);
continue; continue;
} }
skipping to change at line 2902 skipping to change at line 2906
{ {
diskextent->partitionid = (unsigned int) atoi(partition); diskextent->partitionid = (unsigned int) atoi(partition);
zbx_free(partition); zbx_free(partition);
} }
else else
diskextent->partitionid = 0; diskextent->partitionid = 0;
zbx_vector_vmware_diskextent_append(diskextents, diskextent); zbx_vector_vmware_diskextent_append(diskextents, diskextent);
} }
zbx_vector_vmware_diskextent_sort(diskextents, ZBX_DEFAULT_UINT64_PTR_COM
PARE_FUNC);
ret = SUCCEED; ret = SUCCEED;
xmlXPathFreeObject(xpathObj);
out: out:
if (NULL != xpathObj)
xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx); xmlXPathFreeContext(xpathCtx);
return ret; return ret;
} }
/****************************************************************************** /******************************************************************************
* * * *
* Function: vmware_service_create_datastore * * Function: vmware_service_create_datastore *
* * * *
* Purpose: create vmware hypervisor datastore object * * Purpose: create vmware hypervisor datastore object *
skipping to change at line 3070 skipping to change at line 3078
ZBX_POST_VSPHERE_HEADER \ ZBX_POST_VSPHERE_HEADER \
"<ns0:RetrievePropertiesEx>" \ "<ns0:RetrievePropertiesEx>" \
"<ns0:_this type=\"PropertyCollector\">%s</ns0:_this>" \ "<ns0:_this type=\"PropertyCollector\">%s</ns0:_this>" \
"<ns0:specSet>" \ "<ns0:specSet>" \
"<ns0:propSet>" \ "<ns0:propSet>" \
"<ns0:type>HostSystem</ns0:type>" \ "<ns0:type>HostSystem</ns0:type>" \
"<ns0:pathSet>vm</ns0:pathSet>" \ "<ns0:pathSet>vm</ns0:pathSet>" \
"<ns0:pathSet>parent</ns0:pathSet>" \ "<ns0:pathSet>parent</ns0:pathSet>" \
"<ns0:pathSet>datastore</ns0:pathSet>" \ "<ns0:pathSet>datastore</ns0:pathSet>" \
"<ns0:pathSet>config.virtualNicManagerInf o.netConfig</ns0:pathSet>"\ "<ns0:pathSet>config.virtualNicManagerInf o.netConfig</ns0:pathSet>"\
"<ns0:pathSet>config.storageDevice.scsiLu "<ns0:pathSet>config.storageDevice.scsiTo
n</ns0:pathSet>" \ pology</ns0:pathSet>" \
"<ns0:pathSet>config.storageDevice.multip
athInfo</ns0:pathSet>" \
"%s" \ "%s" \
"</ns0:propSet>" \ "</ns0:propSet>" \
"<ns0:propSet>" \ "<ns0:propSet>" \
"<ns0:type>Datastore</ns0:type>" \ "<ns0:type>Datastore</ns0:type>" \
"<ns0:pathSet>host[\"%s\"].mountInfo.moun ted</ns0:pathSet>" \ "<ns0:pathSet>host[\"%s\"].mountInfo.moun ted</ns0:pathSet>" \
"<ns0:pathSet>host[\"%s\"].mountInfo.acce ssible</ns0:pathSet>" \ "<ns0:pathSet>host[\"%s\"].mountInfo.acce ssible</ns0:pathSet>" \
"<ns0:pathSet>host[\"%s\"].mountInfo.acce ssMode</ns0:pathSet>" \ "<ns0:pathSet>host[\"%s\"].mountInfo.acce ssMode</ns0:pathSet>" \
"</ns0:propSet>" \ "</ns0:propSet>" \
"<ns0:objectSet>" \ "<ns0:objectSet>" \
"<ns0:obj type=\"HostSystem\">%s</ns0:obj >" \ "<ns0:obj type=\"HostSystem\">%s</ns0:obj >" \
skipping to change at line 3125 skipping to change at line 3132
zabbix_log(LOG_LEVEL_TRACE, "%s() SOAP request: %s", __func__, tmp); zabbix_log(LOG_LEVEL_TRACE, "%s() SOAP request: %s", __func__, tmp);
if (SUCCEED != zbx_soap_post(__func__, easyhandle, tmp, xdoc, error)) if (SUCCEED != zbx_soap_post(__func__, easyhandle, tmp, xdoc, error))
goto out; goto out;
ret = SUCCEED; ret = SUCCEED;
out: out:
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __func__, zbx_result_string (ret)); zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __func__, zbx_result_string (ret));
return ret; return ret;
# undef ZBX_POST_HV_DETAILS
} }
/****************************************************************************** /******************************************************************************
* * * *
* Function: vmware_hv_get_parent_data * * Function: vmware_hv_get_parent_data *
* * * *
* Purpose: gets the vmware hypervisor datacenter, parent folder or cluster * * Purpose: gets the vmware hypervisor datacenter, parent folder or cluster *
* name * * name *
* * * *
* Parameters: service - [IN] the vmware service * * Parameters: service - [IN] the vmware service *
skipping to change at line 3262 skipping to change at line 3271
hv->parent_name = zbx_strdup(NULL, ZBX_VMWARE_TYPE_VCENTER == ser vice->type ? "Vcenter" : "ESXi"); hv->parent_name = zbx_strdup(NULL, ZBX_VMWARE_TYPE_VCENTER == ser vice->type ? "Vcenter" : "ESXi");
hv->parent_type = zbx_strdup(NULL, ZBX_VMWARE_SOAP_DEFAULT); hv->parent_type = zbx_strdup(NULL, ZBX_VMWARE_SOAP_DEFAULT);
} }
ret = SUCCEED; ret = SUCCEED;
out: out:
zbx_xml_free_doc(doc); zbx_xml_free_doc(doc);
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __func__, zbx_result_string (ret)); zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __func__, zbx_result_string (ret));
return ret; return ret;
# undef ZBX_POST_HV_DATACENTER_NAME
# undef ZBX_POST_SOAP_FOLDER
# undef ZBX_POST_SOAP_CUSTER
}
/******************************************************************************
* *
* Function: vmware_service_hv_get_multipath_data *
* *
* Purpose: gets the vmware hypervisor data about ds multipath *
* *
* Parameters: service - [IN] the vmware service *
* easyhandle - [IN] the CURL handle *
* hv_data - [IN] the hv data with scsi topology info *
* hvid - [IN] the vmware hypervisor id *
* xdoc - [OUT] a reference to output xml document *
* error - [OUT] the error message in the case of failure *
* *
* Return value: SUCCEED - the operation has completed successfully *
* FAIL - the operation has failed *
* *
******************************************************************************/
static int vmware_service_hv_get_multipath_data(const zbx_vmware_service_t *
service, CURL *easyhandle,
xmlDoc *hv_data, const char *hvid, xmlDoc **xdoc, char **error)
{
# define ZBX_POST_HV_MP_DETAILS
\
ZBX_POST_VSPHERE_HEADER
\
"<ns0:RetrievePropertiesEx>"
\
"<ns0:_this type=\"PropertyCollector\">%s</ns0:_this>"
\
"<ns0:specSet>"
\
"<ns0:propSet>"
\
"<ns0:type>HostSystem</ns0:type>"
\
"<ns0:pathSet>config.storageDevice.multip
athInfo</ns0:pathSet>" \
"%s"
\
"</ns0:propSet>"
\
"<ns0:objectSet>"
\
"<ns0:obj type=\"HostSystem\">%s</ns0:obj
>" \
"<ns0:skip>false</ns0:skip>"
\
"</ns0:objectSet>"
\
"</ns0:specSet>"
\
"<ns0:options/>"
\
"</ns0:RetrievePropertiesEx>"
\
ZBX_POST_VSPHERE_FOOTER
# define ZBX_POST_SCSI_INFO
\
"<ns0:pathSet>config.storageDevice.scsiLun[\"%s\"].canonicalName<
/ns0:pathSet>"
zbx_vector_str_t scsi_luns;
char *tmp = NULL, *scsi_req = NULL, *hvid_esc;
int i, ret;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() hvid:'%s'", __func__, hvid);
zbx_vector_str_create(&scsi_luns);
zbx_xml_read_values(hv_data, ZBX_XPATH_HV_SCSI_TOPOLOGY, &scsi_luns);
zabbix_log(LOG_LEVEL_DEBUG, "%s() count of scsiLun:%d", __func__, scsi_lu
ns.values_num);
if (0 == scsi_luns.values_num)
{
ret = SUCCEED;
goto out;
}
for (i = 0; i < scsi_luns.values_num; i++)
{
scsi_req = zbx_strdcatf(scsi_req , ZBX_POST_SCSI_INFO, scsi_luns.
values[i]);
}
zbx_vector_str_clear_ext(&scsi_luns, zbx_str_free);
hvid_esc = xml_escape_dyn(hvid);
tmp = zbx_dsprintf(tmp, ZBX_POST_HV_MP_DETAILS,
vmware_service_objects[service->type].property_collector,
scsi_req, hvid_esc);
zbx_free(hvid_esc);
zbx_free(scsi_req);
ret = zbx_soap_post(__func__, easyhandle, tmp, xdoc, error);
out:
zbx_free(tmp);
zbx_vector_str_destroy(&scsi_luns);
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __func__, zbx_result_string
(ret));
return ret;
# undef ZBX_POST_SCSI_INFO
# undef ZBX_POST_HV_MP_DETAILS
} }
/****************************************************************************** /******************************************************************************
* * * *
* Function: vmware_ds_name_compare * * Function: vmware_ds_name_compare *
* * * *
* Purpose: sorting function to sort Datastore vector by name * * Purpose: sorting function to sort Datastore vector by name *
* * * *
******************************************************************************/ ******************************************************************************/
int vmware_ds_name_compare(const void *d1, const void *d2) int vmware_ds_name_compare(const void *d1, const void *d2)
skipping to change at line 3394 skipping to change at line 3489
xmlXPathFreeObject(xpathObj); xmlXPathFreeObject(xpathObj);
xmlXPathFreeContext(xpathCtx); xmlXPathFreeContext(xpathCtx);
zabbix_log(LOG_LEVEL_DEBUG, "End of %s() mountinfo:" ZBX_FS_UI64, __func_ _, mi_access); zabbix_log(LOG_LEVEL_DEBUG, "End of %s() mountinfo:" ZBX_FS_UI64, __func_ _, mi_access);
return mi_access; return mi_access;
} }
/****************************************************************************** /******************************************************************************
* * * *
* Function: vmware_get_multipath_count *
* *
* Purpose: retrieves multipath count *
* *
* Parameters: xdoc - [IN] xml document *
* xpath - [IN] xpath *
* multipath_num - [OUT] count *
* *
* Return value: SUCCEED - the count was retrieved successfully *
* FAIL - otherwise *
* *
******************************************************************************/
static int vmware_get_multipath_count(xmlDoc *xdoc, const char *xpath, int *
multipath_num)
{
xmlXPathContext *xpathCtx;
xmlXPathObject *xpathObj;
int ret = FAIL;
xpathCtx = xmlXPathNewContext(xdoc);
if (NULL == (xpathObj = xmlXPathEvalExpression((xmlChar *)xpath, xpathCtx
)))
goto out;
if (XPATH_NUMBER == xpathObj->type)
{
*multipath_num = (int)xpathObj->floatval;
ret = SUCCEED;
}
xmlXPathFreeObject(xpathObj);
out:
xmlXPathFreeContext(xpathCtx);
return ret;
}
/******************************************************************************
* *
* Function: vmware_dsname_compare * * Function: vmware_dsname_compare *
* * * *
* Purpose: sorting function to sort Datastore names vector by name * * Purpose: sorting function to sort Datastore names vector by name *
* * * *
******************************************************************************/ ******************************************************************************/
int vmware_dsname_compare(const void *d1, const void *d2) int vmware_dsname_compare(const void *d1, const void *d2)
{ {
const zbx_vmware_dsname_t *ds1 = *(const zbx_vmware_dsname_t **)d1; const zbx_vmware_dsname_t *ds1 = *(const zbx_vmware_dsname_t **)d1;
const zbx_vmware_dsname_t *ds2 = *(const zbx_vmware_dsname_t **)d2; const zbx_vmware_dsname_t *ds2 = *(const zbx_vmware_dsname_t **)d2;
skipping to change at line 3466 skipping to change at line 3523
* error - [OUT] the error message in the case of failure * * error - [OUT] the error message in the case of failure *
* * * *
* Return value: SUCCEED - the hypervisor object was initialized successfully * * Return value: SUCCEED - the hypervisor object was initialized successfully *
* FAIL - otherwise * * FAIL - otherwise *
* * * *
******************************************************************************/ ******************************************************************************/
static int vmware_service_init_hv(zbx_vmware_service_t *service, CURL *easyh andle, const char *id, static int vmware_service_init_hv(zbx_vmware_service_t *service, CURL *easyh andle, const char *id,
zbx_vector_vmware_datastore_t *dss, zbx_vmware_hv_t *hv, char **e rror) zbx_vector_vmware_datastore_t *dss, zbx_vmware_hv_t *hv, char **e rror)
{ {
char *value; char *value;
xmlDoc *details = NULL; xmlDoc *details = NULL, *multipath_data = NULL;
zbx_vector_str_t datastores, vms; zbx_vector_str_t datastores, vms;
int i, j, ret = FAIL; int i, j, ret = FAIL;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() hvid:'%s'", __func__, id); zabbix_log(LOG_LEVEL_DEBUG, "In %s() hvid:'%s'", __func__, id);
memset(hv, 0, sizeof(zbx_vmware_hv_t)); memset(hv, 0, sizeof(zbx_vmware_hv_t));
zbx_vector_vmware_dsname_create(&hv->dsnames); zbx_vector_vmware_dsname_create(&hv->dsnames);
zbx_vector_ptr_create(&hv->vms); zbx_vector_ptr_create(&hv->vms);
skipping to change at line 3509 skipping to change at line 3566
NULL != (value = zbx_xml_read_doc_value(details, ZBX_XPAT H_HV_IPV6("management")))) NULL != (value = zbx_xml_read_doc_value(details, ZBX_XPAT H_HV_IPV6("management"))))
{ {
hv->ip = value; hv->ip = value;
} }
if (SUCCEED != vmware_hv_get_parent_data(service, easyhandle, hv, error)) if (SUCCEED != vmware_hv_get_parent_data(service, easyhandle, hv, error))
goto out; goto out;
zbx_xml_read_values(details, ZBX_XPATH_HV_DATASTORES(), &datastores); zbx_xml_read_values(details, ZBX_XPATH_HV_DATASTORES(), &datastores);
zbx_vector_vmware_dsname_reserve(&hv->dsnames, datastores.values_num); zbx_vector_vmware_dsname_reserve(&hv->dsnames, datastores.values_num);
zabbix_log(LOG_LEVEL_DEBUG, "%s(): %d datastores are connected to hypervi
sor \"%s\"", __func__,
datastores.values_num, hv->id);
if (SUCCEED != vmware_service_hv_get_multipath_data(service, easyhandle,
details, id, &multipath_data, error))
goto out;
for (i = 0; i < datastores.values_num; i++) for (i = 0; i < datastores.values_num; i++)
{ {
zbx_vmware_datastore_t *ds, ds_cmp; zbx_vmware_datastore_t *ds, ds_cmp;
zbx_str_uint64_pair_t hv_ds_access; zbx_str_uint64_pair_t hv_ds_access;
zbx_vmware_dsname_t *dsname; zbx_vmware_dsname_t *dsname;
ds_cmp.id = datastores.values[i]; ds_cmp.id = datastores.values[i];
if (FAIL == (j = zbx_vector_vmware_datastore_bsearch(dss, &ds_cmp , vmware_ds_id_compare))) if (FAIL == (j = zbx_vector_vmware_datastore_bsearch(dss, &ds_cmp , vmware_ds_id_compare)))
skipping to change at line 3532 skipping to change at line 3594
continue; continue;
} }
ds = dss->values[j]; ds = dss->values[j];
hv_ds_access.name = zbx_strdup(NULL, hv->uuid); hv_ds_access.name = zbx_strdup(NULL, hv->uuid);
hv_ds_access.value = vmware_hv_get_ds_access(details, ds->id); hv_ds_access.value = vmware_hv_get_ds_access(details, ds->id);
zbx_vector_str_uint64_pair_append_ptr(&ds->hv_uuids_access, &hv_d s_access); zbx_vector_str_uint64_pair_append_ptr(&ds->hv_uuids_access, &hv_d s_access);
dsname = (zbx_vmware_dsname_t *)zbx_malloc(NULL, sizeof(zbx_vmwar e_dsname_t)); dsname = (zbx_vmware_dsname_t *)zbx_malloc(NULL, sizeof(zbx_vmwar e_dsname_t));
dsname->name = zbx_strdup(NULL, ds->name); dsname->name = zbx_strdup(NULL, ds->name);
zbx_vector_vmware_hvdisk_create(&dsname->hvdisks); zbx_vector_vmware_hvdisk_create(&dsname->hvdisks);
zabbix_log(LOG_LEVEL_DEBUG, "%s(): for %d diskextents check multi
path at ds:\"%s\"", __func__,
ds->diskextents.values_num, ds->name);
for (j = 0; j < ds->diskextents.values_num; j++) for (j = 0; NULL != multipath_data && j < ds->diskextents.values_ num; j++)
{ {
zbx_vmware_diskextent_t *diskextent = ds->diskextents.val ues[j]; zbx_vmware_diskextent_t *diskextent = ds->diskextents.val ues[j];
zbx_vmware_hvdisk_t hvdisk; zbx_vmware_hvdisk_t hvdisk;
char tmp[MAX_STRING_LEN]; char tmp[MAX_STRING_LEN], *lun;
zbx_snprintf(tmp, sizeof(tmp), ZBX_XPATH_HV_LUN(), diskex
tent->diskname);
if (NULL == (lun = zbx_xml_read_doc_value(multipath_data,
tmp)))
{
zabbix_log(LOG_LEVEL_DEBUG, "%s(): not found disk
extent: %s",
__func__, diskextent->diskname);
continue;
}
zbx_snprintf(tmp, sizeof(tmp), ZBX_XPATH_HV_MULTIPATH_PAT HS(), diskextent->diskname); zbx_snprintf(tmp, sizeof(tmp), ZBX_XPATH_HV_MULTIPATH_PAT HS(), lun);
if (SUCCEED != vmware_get_multipath_count(details, tmp, & if (SUCCEED != zbx_xml_read_doc_num(multipath_data, tmp,
hvdisk.multipath_total)) &hvdisk.multipath_total) ||
0 == hvdisk.multipath_total)
{
zabbix_log(LOG_LEVEL_DEBUG, "%s(): for diskextent
: %s and lun: %s"
" multipath data is not found", _
_func__, diskextent->diskname, lun);
zbx_free(lun);
continue; continue;
}
zbx_snprintf(tmp, sizeof(tmp), ZBX_XPATH_HV_MULTIPATH_ACT IVE_PATHS(), diskextent->diskname); zbx_snprintf(tmp, sizeof(tmp), ZBX_XPATH_HV_MULTIPATH_ACT IVE_PATHS(), lun);
if (SUCCEED != vmware_get_multipath_count(details, tmp, & hvdisk.multipath_active)) if (SUCCEED != zbx_xml_read_doc_num(multipath_data, tmp, &hvdisk.multipath_active))
hvdisk.multipath_active = 0; hvdisk.multipath_active = 0;
hvdisk.partitionid = diskextent->partitionid; hvdisk.partitionid = diskextent->partitionid;
zbx_vector_vmware_hvdisk_append(&dsname->hvdisks, hvdisk) ; zbx_vector_vmware_hvdisk_append(&dsname->hvdisks, hvdisk) ;
zbx_free(lun);
} }
zbx_vector_vmware_hvdisk_sort(&dsname->hvdisks, ZBX_DEFAULT_UINT6 4_COMPARE_FUNC); zbx_vector_vmware_hvdisk_sort(&dsname->hvdisks, ZBX_DEFAULT_UINT6 4_COMPARE_FUNC);
zbx_vector_vmware_dsname_append(&hv->dsnames, dsname); zbx_vector_vmware_dsname_append(&hv->dsnames, dsname);
} }
zbx_vector_vmware_dsname_sort(&hv->dsnames, vmware_dsname_compare); zbx_vector_vmware_dsname_sort(&hv->dsnames, vmware_dsname_compare);
zbx_xml_read_values(details, ZBX_XPATH_HV_VMS(), &vms); zbx_xml_read_values(details, ZBX_XPATH_HV_VMS(), &vms);
zbx_vector_ptr_reserve(&hv->vms, vms.values_num + hv->vms.values_alloc); zbx_vector_ptr_reserve(&hv->vms, vms.values_num + hv->vms.values_alloc);
skipping to change at line 3579 skipping to change at line 3659
else if (NULL != *error) else if (NULL != *error)
{ {
zabbix_log(LOG_LEVEL_DEBUG, "Unable initialize vm %s: %s. ", vms.values[i], *error); zabbix_log(LOG_LEVEL_DEBUG, "Unable initialize vm %s: %s. ", vms.values[i], *error);
zbx_free(*error); zbx_free(*error);
} }
} }
ret = SUCCEED; ret = SUCCEED;
out: out:
zbx_xml_free_doc(multipath_data);
zbx_xml_free_doc(details); zbx_xml_free_doc(details);
zbx_vector_str_clear_ext(&vms, zbx_str_free); zbx_vector_str_clear_ext(&vms, zbx_str_free);
zbx_vector_str_destroy(&vms); zbx_vector_str_destroy(&vms);
zbx_vector_str_clear_ext(&datastores, zbx_str_free); zbx_vector_str_clear_ext(&datastores, zbx_str_free);
zbx_vector_str_destroy(&datastores); zbx_vector_str_destroy(&datastores);
if (SUCCEED != ret) if (SUCCEED != ret)
vmware_hv_clean(hv); vmware_hv_clean(hv);
skipping to change at line 5184 skipping to change at line 5265
zbx_vector_vmware_datastore_sort(&data->datastores, vmware_ds_id_compare) ; zbx_vector_vmware_datastore_sort(&data->datastores, vmware_ds_id_compare) ;
if (SUCCEED != zbx_hashset_reserve(&data->hvs, hvs.values_num)) if (SUCCEED != zbx_hashset_reserve(&data->hvs, hvs.values_num))
{ {
THIS_SHOULD_NEVER_HAPPEN; THIS_SHOULD_NEVER_HAPPEN;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
for (i = 0; i < hvs.values_num; i++) for (i = 0; i < hvs.values_num; i++)
{ {
zbx_vmware_hv_t hv_local; zbx_vmware_hv_t hv_local, *hv;
if (SUCCEED == vmware_service_init_hv(service, easyhandle, hvs.va lues[i], &data->datastores, &hv_local, if (SUCCEED == vmware_service_init_hv(service, easyhandle, hvs.va lues[i], &data->datastores, &hv_local,
&data->error)) &data->error))
{ {
if (NULL != (hv = zbx_hashset_search(&data->hvs, &hv_loca
l)))
{
zabbix_log(LOG_LEVEL_DEBUG, "Duplicate uuid of ne
w hv id:%s name:%s uuid:%s and"
" discovered hv with id:%s name:%s", hv_l
ocal.id,
ZBX_NULL2EMPTY_STR(hv_local.props[ZBX_VMW
ARE_HVPROP_NAME]), hv_local.uuid,
hv->id, ZBX_NULL2EMPTY_STR(hv->props[ZBX_
VMWARE_HVPROP_NAME]));
vmware_hv_clean(&hv_local);
continue;
}
zbx_hashset_insert(&data->hvs, &hv_local, sizeof(hv_local )); zbx_hashset_insert(&data->hvs, &hv_local, sizeof(hv_local ));
} }
else if (NULL != data->error) else if (NULL != data->error)
{ {
zabbix_log(LOG_LEVEL_DEBUG, "Unable initialize hv %s: %s. ", hvs.values[i], data->error); zabbix_log(LOG_LEVEL_DEBUG, "Unable initialize hv %s: %s. ", hvs.values[i], data->error);
zbx_free(data->error); zbx_free(data->error);
} }
} }
for (i = 0; i < data->datastores.values_num; i++) for (i = 0; i < data->datastores.values_num; i++)
skipping to change at line 6551 skipping to change at line 6642
xmlChar *val; xmlChar *val;
char *value = NULL; char *value = NULL;
xpathCtx = xmlXPathNewContext(doc); xpathCtx = xmlXPathNewContext(doc);
xpathCtx->node = node; xpathCtx->node = node;
if (NULL == (xpathObj = xmlXPathEvalExpression((const xmlChar *)xpath, xp athCtx))) if (NULL == (xpathObj = xmlXPathEvalExpression((const xmlChar *)xpath, xp athCtx)))
goto clean; goto clean;
if (XPATH_STRING == xpathObj->type)
{
value = zbx_strdup(NULL, (const char *)xpathObj->stringval);
goto clean;
}
if (0 != xmlXPathNodeSetIsEmpty(xpathObj->nodesetval)) if (0 != xmlXPathNodeSetIsEmpty(xpathObj->nodesetval))
goto clean; goto clean;
nodeset = xpathObj->nodesetval; nodeset = xpathObj->nodesetval;
if (NULL != (val = xmlNodeListGetString(doc, nodeset->nodeTab[0]->xmlChil drenNode, 1))) if (NULL != (val = xmlNodeListGetString(doc, nodeset->nodeTab[0]->xmlChil drenNode, 1)))
{ {
value = zbx_strdup(NULL, (const char *)val); value = zbx_strdup(NULL, (const char *)val);
xmlFree(val); xmlFree(val);
} }
skipping to change at line 6593 skipping to change at line 6690
static char *zbx_xml_read_doc_value(xmlDoc *xdoc, const char *xpath) static char *zbx_xml_read_doc_value(xmlDoc *xdoc, const char *xpath)
{ {
xmlNode *root_element; xmlNode *root_element;
root_element = xmlDocGetRootElement(xdoc); root_element = xmlDocGetRootElement(xdoc);
return zbx_xml_read_node_value(xdoc, root_element, xpath); return zbx_xml_read_node_value(xdoc, root_element, xpath);
} }
/****************************************************************************** /******************************************************************************
* * * *
* Function: zbx_xml_read_doc_num *
* *
* Purpose: retrieves numeric xpath value *
* *
* Parameters: xdoc - [IN] xml document *
* xpath - [IN] xpath *
* num - [OUT] numeric value *
* *
* Return value: SUCCEED - the count was retrieved successfully *
* FAIL - otherwise *
* *
******************************************************************************/
static int zbx_xml_read_doc_num(xmlDoc *xdoc, const char *xpath, int *num)
{
int ret = FAIL;
xmlXPathContext *xpathCtx;
xmlXPathObject *xpathObj;
xpathCtx = xmlXPathNewContext(xdoc);
if (NULL == (xpathObj = xmlXPathEvalExpression((const xmlChar *)xpath, xp
athCtx)))
goto out;
if (XPATH_NUMBER == xpathObj->type)
{
*num = (int)xpathObj->floatval;
ret = SUCCEED;
}
xmlXPathFreeObject(xpathObj);
out:
xmlXPathFreeContext(xpathCtx);
return ret;
}
/******************************************************************************
* *
* Function: zbx_xml_read_values * * Function: zbx_xml_read_values *
* * * *
* Purpose: populate array of values from a xml data * * Purpose: populate array of values from a xml data *
* * * *
* Parameters: xdoc - [IN] XML document * * Parameters: xdoc - [IN] XML document *
* xpath - [IN] XML XPath * * xpath - [IN] XML XPath *
* values - [OUT] list of requested values * * values - [OUT] list of requested values *
* * * *
* Return: Upon successful completion the function return SUCCEED. * * Return: Upon successful completion the function return SUCCEED. *
* Otherwise, FAIL is returned. * * Otherwise, FAIL is returned. *
skipping to change at line 6618 skipping to change at line 6753
xmlXPathObject *xpathObj; xmlXPathObject *xpathObj;
xmlNodeSetPtr nodeset; xmlNodeSetPtr nodeset;
xmlChar *val; xmlChar *val;
int i, ret = FAIL; int i, ret = FAIL;
if (NULL == xdoc) if (NULL == xdoc)
goto out; goto out;
xpathCtx = xmlXPathNewContext(xdoc); xpathCtx = xmlXPathNewContext(xdoc);
if (NULL == (xpathObj = xmlXPathEvalExpression((xmlChar *)xpath, xpathCtx ))) if (NULL == (xpathObj = xmlXPathEvalExpression((const xmlChar *)xpath, xp athCtx)))
goto clean; goto clean;
if (0 != xmlXPathNodeSetIsEmpty(xpathObj->nodesetval)) if (0 != xmlXPathNodeSetIsEmpty(xpathObj->nodesetval))
goto clean; goto clean;
nodeset = xpathObj->nodesetval; nodeset = xpathObj->nodesetval;
for (i = 0; i < nodeset->nodeNr; i++) for (i = 0; i < nodeset->nodeNr; i++)
{ {
if (NULL != (val = xmlNodeListGetString(xdoc, nodeset->nodeTab[i] ->xmlChildrenNode, 1))) if (NULL != (val = xmlNodeListGetString(xdoc, nodeset->nodeTab[i] ->xmlChildrenNode, 1)))
 End of changes. 29 change blocks. 
77 lines changed or deleted 251 lines changed or added

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