这篇教程C++ zbx_strdup函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中zbx_strdup函数的典型用法代码示例。如果您正苦于以下问题:C++ zbx_strdup函数的具体用法?C++ zbx_strdup怎么用?C++ zbx_strdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了zbx_strdup函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: web_curl_set_urlstatic int web_curl_set_url(struct web *opt){ const char *__function_name = "web_curl_set_url"; char *url = NULL; char *curl_err_str = NULL; int curl_err; size_t alloc; size_t offset; if (opt->is_https) url = zbx_strdup(url, "https://"); else url = zbx_strdup(url, "http://"); offset = strlen(url); alloc = sizeof(char) * offset + 1; if (opt->is_ip_hostname) { zbx_strncpy_alloc(&url, &alloc, &offset, opt->host, strlen(opt->host)); } else { if (opt->is_ipv6) { zbx_strncpy_alloc(&url, &alloc, &offset, "[", 1); zbx_strncpy_alloc(&url, &alloc, &offset, opt->ip, strlen(opt->ip)); zbx_strncpy_alloc(&url, &alloc, &offset, "]", 1); } else { zbx_strncpy_alloc(&url, &alloc, &offset, opt->ip, strlen(opt->ip)); } } zbx_strncpy_alloc(&url, &alloc, &offset, ":", 1); zbx_strncpy_alloc(&url, &alloc, &offset, opt->port, strlen(opt->port)); if (*opt->uri != '/') zbx_strncpy_alloc(&url, &alloc, &offset, "/", 1); zbx_strncpy_alloc(&url, &alloc, &offset, opt->uri, strlen(opt->uri)); if ((curl_err = curl_easy_setopt(opt->curl->handler, CURLOPT_URL, url))) { curl_err_str = zbx_strdup(curl_err_str, curl_easy_strerror(curl_err)); zabbix_log(LOG_LEVEL_ERR, "%s(): Could not set cURL option [%d]: %s for key %s", __function_name, CURLOPT_URL, curl_err_str, opt->item->key); zbx_free(curl_err_str); zbx_free(url); return FAIL; } zbx_free(url); return SUCCEED;}
开发者ID:dojci,项目名称:zabbix-2.2.6_webcheck,代码行数:50,
示例2: web_curl_set_headerstatic int web_curl_set_header(struct web *opt){ const char *__function_name = "web_curl_set_header"; char *host = NULL; char *curl_err_str = NULL; int curl_err; int i; size_t offset; size_t alloc; if (opt->host) { host = zbx_strdup(host, "Host: "); offset = strlen(host); alloc = sizeof(char) * offset + 1; zbx_strncpy_alloc(&host, &alloc, &offset, opt->host, strlen(opt->host)); if (!(opt->curl->header_lst = curl_slist_append(opt->curl->header_lst, host))) { zabbix_log(LOG_LEVEL_ERR, "%s(): Could not append to curl header list for key %s", __function_name, opt->item->key); goto failed; } } for (i = 0; i < opt->header_count; i++) { if (!(opt->curl->header_lst = curl_slist_append(opt->curl->header_lst, opt->header[i]))) { zabbix_log(LOG_LEVEL_ERR, "%s(): Could not append to curl header list for key %s", __function_name, opt->item->key); goto failed; } } if (opt->curl->header_lst) { if ((curl_err = curl_easy_setopt(opt->curl->handler, CURLOPT_HTTPHEADER, opt->curl->header_lst))) { curl_err_str = zbx_strdup(curl_err_str, curl_easy_strerror(curl_err)); zabbix_log(LOG_LEVEL_ERR, "%s(): Could not set cURL option [%d]: %s for key %s", __function_name, CURLOPT_HTTPHEADER, curl_err_str, opt->item->key); goto failed; } } zbx_free(host); return SUCCEED;failed: zbx_free(host); zbx_free(curl_err_str); return FAIL;}
开发者ID:dojci,项目名称:zabbix-2.2.6_webcheck,代码行数:50,
示例3: SYSTEM_SWAP_SIZEint SYSTEM_SWAP_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result){#ifdef HAVE_LIBPERFSTAT perfstat_memory_total_t mem; char *swapdev, *mode; if (2 < request->nparam) { SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters.")); return SYSINFO_RET_FAIL; } swapdev = get_rparam(request, 0); mode = get_rparam(request, 1); if (NULL != swapdev && '/0' != *swapdev && 0 != strcmp(swapdev, "all")) { SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid first parameter.")); return SYSINFO_RET_FAIL; } if (1 != perfstat_memory_total(NULL, &mem, sizeof(perfstat_memory_total_t), 1)) { SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno))); return SYSINFO_RET_FAIL; } if (NULL == mode || '/0' == *mode || 0 == strcmp(mode, "free")) SET_UI64_RESULT(result, mem.pgsp_free << ZBX_PERFSTAT_PAGE_SHIFT); else if (0 == strcmp(mode, "total")) SET_UI64_RESULT(result, mem.pgsp_total << ZBX_PERFSTAT_PAGE_SHIFT); else if (0 == strcmp(mode, "used")) SET_UI64_RESULT(result, (mem.pgsp_total - mem.pgsp_free) << ZBX_PERFSTAT_PAGE_SHIFT); else if (0 == strcmp(mode, "pfree")) SET_DBL_RESULT(result, mem.pgsp_total ? 100.0 * (mem.pgsp_free / (double)mem.pgsp_total) : 0.0); else if (0 == strcmp(mode, "pused")) SET_DBL_RESULT(result, mem.pgsp_total ? 100.0 - 100.0 * (mem.pgsp_free / (double)mem.pgsp_total) : 0.0); else { SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid second parameter.")); return SYSINFO_RET_FAIL; } return SYSINFO_RET_OK;#else SET_MSG_RESULT(result, zbx_strdup(NULL, "Agent was compiled without support for Perfstat API.")); return SYSINFO_RET_FAIL;#endif}
开发者ID:zabbix,项目名称:zabbix,代码行数:49,
示例4: set_defaults/****************************************************************************** * * * Function: set_defaults * * * * Purpose: set configuration defaults * * * * Author: Vladimir Levijev, Rudolfs Kreicbergs * * * ******************************************************************************/static void set_defaults(void){ AGENT_RESULT result; char **value = NULL; if (NULL == CONFIG_HOSTNAME) { if (NULL == CONFIG_HOSTNAME_ITEM) CONFIG_HOSTNAME_ITEM = zbx_strdup(CONFIG_HOSTNAME_ITEM, "system.hostname"); init_result(&result); if (SUCCEED == process(CONFIG_HOSTNAME_ITEM, PROCESS_LOCAL_COMMAND, &result) && NULL != (value = GET_STR_RESULT(&result))) { assert(*value); if (MAX_ZBX_HOSTNAME_LEN < strlen(*value)) { (*value)[MAX_ZBX_HOSTNAME_LEN] = '/0'; zabbix_log(LOG_LEVEL_WARNING, "hostname truncated to [%s])", *value); } CONFIG_HOSTNAME = zbx_strdup(CONFIG_HOSTNAME, *value); } else zabbix_log(LOG_LEVEL_WARNING, "failed to get system hostname from [%s])", CONFIG_HOSTNAME_ITEM); free_result(&result); } else if (NULL != CONFIG_HOSTNAME_ITEM) zabbix_log(LOG_LEVEL_WARNING, "both Hostname and HostnameItem defined, using [%s]", CONFIG_HOSTNAME); if (NULL != CONFIG_HOST_METADATA && NULL != CONFIG_HOST_METADATA_ITEM) { zabbix_log(LOG_LEVEL_WARNING, "both HostMetadata and HostMetadataItem defined, using [%s]", CONFIG_HOST_METADATA); }#ifndef _WINDOWS if (NULL == CONFIG_LOAD_MODULE_PATH) CONFIG_LOAD_MODULE_PATH = zbx_strdup(CONFIG_LOAD_MODULE_PATH, LIBDIR "/modules");#endif#ifdef USE_PID_FILE if (NULL == CONFIG_PID_FILE) CONFIG_PID_FILE = "/tmp/zabbix_agentd.pid";#endif}
开发者ID:Metalaria,项目名称:Zabbix_,代码行数:58,
示例5: switchstatic char *zbx_get_snmp_type_error(u_char type){ switch (type) { case SNMP_NOSUCHOBJECT: return zbx_strdup(NULL, "No Such Object available on this agent at this OID"); case SNMP_NOSUCHINSTANCE: return zbx_strdup(NULL, "No Such Instance currently exists at this OID"); case SNMP_ENDOFMIBVIEW: return zbx_strdup(NULL, "No more variables left in this MIB View" " (it is past the end of the MIB tree)"); default: return zbx_dsprintf(NULL, "Value has unknown type 0x%02X", type); }}
开发者ID:aries4,项目名称:MIRACLE-ZBX-2.0.3-NoSQL,代码行数:15,
示例6: VM_MEMORY_SIZEint VM_MEMORY_SIZE(AGENT_REQUEST *request, AGENT_RESULT *result){ char *mode; int ret = SYSINFO_RET_FAIL; if (1 < request->nparam) { SET_MSG_RESULT(result, zbx_strdup(NULL, "Too many parameters.")); return SYSINFO_RET_FAIL; } if (0 == pagesize) { if (KERN_SUCCESS != host_page_size(mach_host_self(), &pagesize)) { SET_MSG_RESULT(result, zbx_strdup(NULL, "Cannot obtain host page size.")); return SYSINFO_RET_FAIL; } } mode = get_rparam(request, 0); if (NULL == mode || '/0' == *mode || 0 == strcmp(mode, "total")) ret = VM_MEMORY_TOTAL(result); else if (0 == strcmp(mode, "active")) ret = VM_MEMORY_ACTIVE(result); else if (0 == strcmp(mode, "inactive")) ret = VM_MEMORY_INACTIVE(result); else if (0 == strcmp(mode, "wired")) ret = VM_MEMORY_WIRED(result); else if (0 == strcmp(mode, "free")) ret = VM_MEMORY_FREE(result); else if (0 == strcmp(mode, "used")) ret = VM_MEMORY_USED(result); else if (0 == strcmp(mode, "pused")) ret = VM_MEMORY_PUSED(result); else if (0 == strcmp(mode, "available")) ret = VM_MEMORY_AVAILABLE(result); else if (0 == strcmp(mode, "pavailable")) ret = VM_MEMORY_PAVAILABLE(result); else { SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid first parameter.")); return SYSINFO_RET_FAIL; } return ret;}
开发者ID:HupuInc,项目名称:zabbix,代码行数:48,
示例7: VFS_FS_DISCOVERYint VFS_FS_DISCOVERY(AGENT_REQUEST *request, AGENT_RESULT *result){ int i, rc; struct statvfs *mntbuf; struct zbx_json j; if (0 == (rc = getmntinfo(&mntbuf, MNT_WAIT))) { SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Cannot obtain system information: %s", zbx_strerror(errno))); return SYSINFO_RET_FAIL; } zbx_json_init(&j, ZBX_JSON_STAT_BUF_LEN); zbx_json_addarray(&j, ZBX_PROTO_TAG_DATA); for (i = 0; i < rc; i++) { zbx_json_addobject(&j, NULL); zbx_json_addstring(&j, "{#FSNAME}", mntbuf[i].f_mntonname, ZBX_JSON_TYPE_STRING); zbx_json_addstring(&j, "{#FSTYPE}", mntbuf[i].f_fstypename, ZBX_JSON_TYPE_STRING); zbx_json_close(&j); } zbx_json_close(&j); SET_STR_RESULT(result, zbx_strdup(NULL, j.buffer)); zbx_json_free(&j); return SYSINFO_RET_OK;}
开发者ID:HupuInc,项目名称:zabbix,代码行数:32,
示例8: web_set_loginstatic int web_set_login(AGENT_RESULT *result, struct web *opt, const char *params, int param_id){ char login_tmp[MAX_STRING_LEN] = {0}; char *passwd_ptr = NULL; size_t user_lenght; if (get_param(params, param_id, login_tmp, MAX_STRING_LEN)) goto failed; zbx_remove_whitespace(login_tmp); if (!(passwd_ptr = strchr(login_tmp, ':'))) goto failed; if (!(user_lenght = strlen(login_tmp) - strlen(passwd_ptr))) goto failed; opt->username = strndup(login_tmp, user_lenght); opt->passwd = zbx_strdup(opt->passwd, ++passwd_ptr); return SUCCEED;failed: SET_MSG_RESULT(result, zbx_dsprintf(NULL, "Invalid LOGIN parameter", NULL)); return FAIL;}
开发者ID:dojci,项目名称:zabbix-2.2.6_webcheck,代码行数:25,
示例9: VFS_FS_DISCOVERYint VFS_FS_DISCOVERY(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result){ int i, rc, ret = SYSINFO_RET_FAIL; struct statfs *mntbuf; struct zbx_json j; zbx_json_init(&j, ZBX_JSON_STAT_BUF_LEN); zbx_json_addarray(&j, ZBX_PROTO_TAG_DATA); if (0 != (rc = getmntinfo(&mntbuf, MNT_WAIT))) { for (i = 0; i < rc; i++) { zbx_json_addobject(&j, NULL); zbx_json_addstring(&j, "{#FSNAME}", mntbuf[i].f_mntonname, ZBX_JSON_TYPE_STRING); zbx_json_addstring(&j, "{#FSTYPE}", mntbuf[i].f_fstypename, ZBX_JSON_TYPE_STRING); zbx_json_close(&j); } ret = SYSINFO_RET_OK; } zbx_json_close(&j); SET_STR_RESULT(result, zbx_strdup(NULL, j.buffer)); zbx_json_free(&j); return ret;}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,
示例10: SYSTEM_HW_CHASSISint SYSTEM_HW_CHASSIS(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result){ char tmp[8], buf[MAX_STRING_LEN]; int ret = SYSINFO_RET_FAIL; if (1 < num_param(param)) return ret; if (0 != get_param(param, 1, tmp, sizeof(tmp))) *tmp = '/0'; if ('/0' == *tmp || 0 == strcmp(tmp, "full")) /* show full info by default */ ret = get_dmi_info(buf, sizeof(buf), DMI_GET_TYPE | DMI_GET_VENDOR | DMI_GET_MODEL | DMI_GET_SERIAL); else if (0 == strcmp(tmp, "type")) ret = get_dmi_info(buf, sizeof(buf), DMI_GET_TYPE); else if (0 == strcmp(tmp, "vendor")) ret = get_dmi_info(buf, sizeof(buf), DMI_GET_VENDOR); else if (0 == strcmp(tmp, "model")) ret = get_dmi_info(buf, sizeof(buf), DMI_GET_MODEL); else if (0 == strcmp(tmp, "serial")) ret = get_dmi_info(buf, sizeof(buf), DMI_GET_SERIAL); if (SYSINFO_RET_OK == ret) SET_STR_RESULT(result, zbx_strdup(NULL, buf + 1)); /* buf has a leading space */ return ret;}
开发者ID:nabnut,项目名称:zabbix2.0-cookies,代码行数:27,
示例11: DCadd_nextcheck/****************************************************************************** * * * Function: DCadd_nextcheck * * * * Purpose: add item nextcheck to the array * * * ******************************************************************************/void DCadd_nextcheck(zbx_uint64_t itemid, const zbx_timespec_t *ts, const char *error_msg){ const char *__function_name = "DCadd_nextcheck"; int i; zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name); if (NULL == error_msg) return; i = get_nearestindex(nextchecks, sizeof(ZBX_DC_NEXTCHECK), nextcheck_num, itemid); if (i < nextcheck_num && nextchecks[i].itemid == itemid) /* an item found */ return; if (nextcheck_alloc == nextcheck_num) { nextcheck_alloc += 64; nextchecks = zbx_realloc(nextchecks, sizeof(ZBX_DC_NEXTCHECK) * nextcheck_alloc); } /* insert a new item */ memmove(&nextchecks[i + 1], &nextchecks[i], sizeof(ZBX_DC_NEXTCHECK) * (nextcheck_num - i)); nextchecks[i].itemid = itemid; nextchecks[i].ts = *ts; nextchecks[i].error_msg = zbx_strdup(NULL, error_msg); nextcheck_num++; zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name);}
开发者ID:maxh2010,项目名称:zabbix-trunk,代码行数:40,
示例12: SYSTEM_HW_CHASSISint SYSTEM_HW_CHASSIS(AGENT_REQUEST *request, AGENT_RESULT *result){ char *mode, buf[MAX_STRING_LEN]; int ret = SYSINFO_RET_FAIL; if (1 < request->nparam) return ret; mode = get_rparam(request, 0); if (NULL == mode || '/0' == *mode || 0 == strcmp(mode, "full")) /* show full info by default */ ret = get_dmi_info(buf, sizeof(buf), DMI_GET_TYPE | DMI_GET_VENDOR | DMI_GET_MODEL | DMI_GET_SERIAL); else if (0 == strcmp(mode, "type")) ret = get_dmi_info(buf, sizeof(buf), DMI_GET_TYPE); else if (0 == strcmp(mode, "vendor")) ret = get_dmi_info(buf, sizeof(buf), DMI_GET_VENDOR); else if (0 == strcmp(mode, "model")) ret = get_dmi_info(buf, sizeof(buf), DMI_GET_MODEL); else if (0 == strcmp(mode, "serial")) ret = get_dmi_info(buf, sizeof(buf), DMI_GET_SERIAL); if (SYSINFO_RET_OK == ret) SET_STR_RESULT(result, zbx_strdup(NULL, buf + 1)); /* buf has a leading space */ return ret;}
开发者ID:Metalaria,项目名称:Zabbix_,代码行数:26,
示例13: read_ipmi_controlstatic void read_ipmi_control(zbx_ipmi_host_t *h, zbx_ipmi_control_t *c){ const char *__function_name = "read_ipmi_control"; int ret; struct timeval tv; zabbix_log(LOG_LEVEL_DEBUG, "In %s() control:'%[email C++ zbx_strerror函数代码示例 C++ zbx_strcpy_alloc函数代码示例
|