Skip to content

Instantly share code, notes, and snippets.

@higebu
Created March 28, 2014 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save higebu/9826313 to your computer and use it in GitHub Desktop.
Save higebu/9826313 to your computer and use it in GitHub Desktop.
diff -u -r zabbix-2.2.2.orig/src/zabbix_server/vmware/vmware.c zabbix-2.2.2/src/zabbix_server/vmware/vmware.c
--- zabbix-2.2.2.orig/src/zabbix_server/vmware/vmware.c 2014-02-12 18:04:36.000000000 +0900
+++ zabbix-2.2.2/src/zabbix_server/vmware/vmware.c 2014-03-28 13:51:08.285732065 +0900
@@ -1944,9 +1944,22 @@
"</ns0:RetrievePropertiesEx>" \
ZBX_POST_VSPHERE_FOOTER
+# define ZBX_POST_VCENTER_HV_LIST_CONTINUE \
+ ZBX_POST_VSPHERE_HEADER \
+ "<ns0:ContinueRetrievePropertiesEx xsi:type=\"ns0:ContinueRetrievePropertiesExRequestType\">" \
+ "<ns0:_this type=\"PropertyCollector\">propertyCollector</ns0:_this>" \
+ "<ns0:token>%s</ns0:token>" \
+ "</ns0:ContinueRetrievePropertiesEx>" \
+ ZBX_POST_VSPHERE_FOOTER
+
+# define ZBX_XPATH_RETRIEVE_PROPERTIES_TOKEN \
+ "/*[local-name()='Envelope']/*[local-name()='Body']/*[local-name()='RetrievePropertiesExResponse']" \
+ "/*[local-name()='returnval']/*[local-name()='token']"
+
const char *__function_name = "vmware_service_get_hv_list";
int err, opt, ret = FAIL;
+ char tmp[MAX_STRING_LEN], *token;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);
@@ -1972,6 +1985,37 @@
goto out;
zbx_xml_read_values(page.data, "//*[@type='HostSystem']", hvs);
+
+ if (NULL != (token = zbx_xml_read_value(page.data, ZBX_XPATH_RETRIEVE_PROPERTIES_TOKEN)))
+ {
+ zabbix_log(LOG_LEVEL_DEBUG, "%s() token: %s", __function_name, token);
+ do
+ {
+ zbx_snprintf(tmp, sizeof(tmp), ZBX_POST_VCENTER_HV_LIST_CONTINUE, token);
+
+ if (CURLE_OK != (err = curl_easy_setopt(easyhandle, opt = CURLOPT_POSTFIELDS, tmp)))
+ {
+ *error = zbx_dsprintf(*error, "Cannot set cURL option [%d]: %s", opt, curl_easy_strerror(err));
+ goto out;
+ }
+
+ page.offset = 0;
+
+ if (CURLE_OK != (err = curl_easy_perform(easyhandle)))
+ {
+ *error = zbx_strdup(*error, curl_easy_strerror(err));
+ goto out;
+ }
+
+ zabbix_log(LOG_LEVEL_DEBUG, "%s() page.data:'%s'", __function_name, page.data);
+ if (NULL != (*error = zbx_xml_read_value(page.data, ZBX_XPATH_LN1("faultstring"))))
+ goto out;
+
+ zbx_xml_read_values(page.data, "//*[@type='HostSystem']", hvs);
+
+ token = zbx_xml_read_value(page.data, ZBX_XPATH_RETRIEVE_PROPERTIES_TOKEN);
+ } while (NULL != token);
+ }
}
else
{
@higebu
Copy link
Author

higebu commented Mar 28, 2014

wget http://downloads.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.2/zabbix-2.2.2.tar.gz
tar xf zabbix-2.2.2.tar.gz
patch -p1 -d zabbix-2.2.2 < ZBX-7721-zabbix-2.2.2.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment