本文整理汇总了C++中DBfree_result函数的典型用法代码示例。如果您正苦于以下问题:C++ DBfree_result函数的具体用法?C++ DBfree_result怎么用?C++ DBfree_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DBfree_result函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ja_get_zbxsnd_on
/******************************************************************************
* *
* Function: ja_get_zbxsnd_on *
* *
* Purpose: gets the zabbix notification existence *
* *
* Parameters: *
* *
* Return value: value of Zabbix notification existence that get *
* *
* Comments: *
* *
******************************************************************************/
int ja_get_zbxsnd_on()
{
DB_RESULT result;
DB_ROW row;
int vl;
const char *__function_name = "ja_get_zbxsnd_on";
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);
result = DBselect("select value from ja_parameter_table where parameter_name = '%s'", ZBXSND_ON);
if (NULL == (row = DBfetch(result)))
{
DBfree_result(result);
return ZBXSND_NOTICE_ON;
}
if (strlen(row[0]) != 1)
{
DBfree_result(result);
return ZBXSND_NOTICE_ON;
}
vl = atoi(row[0]);
DBfree_result(result);
if (vl == ZBXSND_NOTICE_OFF || vl == ZBXSND_NOTICE_ON)
{
return vl;
}
return ZBXSND_NOTICE_ON;
}
示例2: delete_history
/******************************************************************************
* *
* Function: delete_history *
* *
* Purpose: remove outdated information from historical table *
* *
* Parameters: now - current timestamp *
* *
* Return value: number of rows deleted *
* *
* Author: Alexei Vladishev *
* *
* Comments: *
* *
******************************************************************************/
static int delete_history(const char *table, zbx_uint64_t itemid, int keep_history, int now)
{
const char *__function_name = "delete_history";
DB_RESULT result;
DB_ROW row;
int min_clock, deleted;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() table:'%s' itemid:" ZBX_FS_UI64 " keep_history:%d now:%d",
__function_name, table, itemid, keep_history, now);
result = DBselect("select min(clock) from %s where itemid=" ZBX_FS_UI64, table, itemid);
if (NULL == (row = DBfetch(result)) || SUCCEED == DBis_null(row[0]))
{
DBfree_result(result);
return 0;
}
min_clock = atoi(row[0]);
min_clock = MIN(now - keep_history * SEC_PER_DAY, min_clock + 4 * CONFIG_HOUSEKEEPING_FREQUENCY * SEC_PER_HOUR);
DBfree_result(result);
deleted = DBexecute("delete from %s where itemid=" ZBX_FS_UI64 " and clock<%d", table, itemid, min_clock);
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%d", __function_name, deleted);
return deleted;
}
示例3: DBpatch_3020001
int DBpatch_3020001(void)
{
DB_RESULT result;
zbx_vector_uint64_t eventids;
DB_ROW row;
zbx_uint64_t eventid;
int sources[] = {EVENT_SOURCE_TRIGGERS, EVENT_SOURCE_INTERNAL};
int objects[] = {EVENT_OBJECT_ITEM, EVENT_OBJECT_LLDRULE}, i;
zbx_vector_uint64_create(&eventids);
for (i = 0; i < (int)ARRSIZE(sources); i++)
{
result = DBselect(
"select p.eventid"
" from problem p"
" where p.source=%d and p.object=%d and not exists ("
"select null"
" from triggers t"
" where t.triggerid=p.objectid"
")",
sources[i], EVENT_OBJECT_TRIGGER);
while (NULL != (row = DBfetch(result)))
{
ZBX_STR2UINT64(eventid, row[0]);
zbx_vector_uint64_append(&eventids, eventid);
}
DBfree_result(result);
}
for (i = 0; i < (int)ARRSIZE(objects); i++)
{
result = DBselect(
"select p.eventid"
" from problem p"
" where p.source=%d and p.object=%d and not exists ("
"select null"
" from items i"
" where i.itemid=p.objectid"
")",
EVENT_SOURCE_INTERNAL, objects[i]);
while (NULL != (row = DBfetch(result)))
{
ZBX_STR2UINT64(eventid, row[0]);
zbx_vector_uint64_append(&eventids, eventid);
}
DBfree_result(result);
}
zbx_vector_uint64_sort(&eventids, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
if (0 != eventids.values_num)
DBexecute_multiple_query("delete from problem where", "eventid", &eventids);
zbx_vector_uint64_destroy(&eventids);
return SUCCEED;
}
示例4: jarun_icon_info_get_status
/******************************************************************************
* *
* Function: *
* *
* Purpose: *
* *
* Parameters: *
* *
* Return value: *
* *
* Comments: *
* *
******************************************************************************/
int jarun_icon_info_get_status(const zbx_uint64_t inner_jobnet_id,
char *get_job_id, const zbx_uint64_t inner_job_id)
{
char *tp;
DB_RESULT result;
DB_ROW row;
int status;
zbx_uint64_t sub_inner_job_id, sub_inner_jobnet_id;
const char *__function_name = "jarun_icon_info_get_status";
zabbix_log(LOG_LEVEL_DEBUG,
"In %s() inner_jobnet_id: " ZBX_FS_UI64 " get_job_id: %s",
__function_name, inner_jobnet_id, get_job_id);
status = -1;
sub_inner_job_id = 0;
sub_inner_jobnet_id = inner_jobnet_id;
tp = strtok(get_job_id, "/");
while (tp != NULL) {
if (sub_inner_job_id > 0) {
result =
DBselect
("select link_inner_jobnet_id from ja_run_icon_jobnet_table"
" where inner_job_id = " ZBX_FS_UI64, sub_inner_job_id);
if (NULL != (row = DBfetch(result))) {
ZBX_STR2UINT64(sub_inner_jobnet_id, row[0]);
} else {
ja_log("JARUNICONINFO200001", 0, NULL, inner_job_id,
__function_name, sub_inner_job_id);
status = -1;
DBfree_result(result);
break;
}
DBfree_result(result);
}
result =
DBselect
("select inner_job_id, status from ja_run_job_table"
" where inner_jobnet_id = " ZBX_FS_UI64
" and job_id = '%s'", sub_inner_jobnet_id, tp);
if (NULL != (row = DBfetch(result))) {
ZBX_STR2UINT64(sub_inner_job_id, row[0]);
status = atoi(row[1]);
} else {
ja_log("JARUNICONINFO200002", 0, NULL, inner_job_id,
__function_name, tp, inner_job_id);
status = -1;
DBfree_result(result);
break;
}
DBfree_result(result);
tp = strtok(NULL, "/");
}
return status;
}
示例5: zbx_db_insert_id
/*
* Get value of autoincrement field for last insert or update statement
*/
zbx_uint64_t zbx_db_insert_id(int exec_result, const char *table, const char *field)
{
#ifdef HAVE_MYSQL
zabbix_log(LOG_LEVEL_DEBUG, "In DBinsert_id()" );
if(exec_result == FAIL) return 0;
return mysql_insert_id(conn);
#endif
#ifdef HAVE_POSTGRESQL
DB_RESULT tmp_res;
zbx_uint64_t id_res = FAIL;
zabbix_log(LOG_LEVEL_DEBUG, "In DBinsert_id()" );
if(exec_result < 0) return 0;
if(exec_result == FAIL) return 0;
if((Oid)exec_result == InvalidOid) return 0;
tmp_res = zbx_db_select("select %s from %s where oid=%i", field, table, exec_result);
ZBX_STR2UINT64(id_res, PQgetvalue(tmp_res->pg_result, 0, 0));
/* id_res = atoi(PQgetvalue(tmp_res->pg_result, 0, 0));*/
DBfree_result(tmp_res);
return id_res;
#endif
#ifdef HAVE_ORACLE
DB_ROW row;
char sql[MAX_STRING_LEN];
DB_RESULT result;
zbx_uint64_t id;
zabbix_log(LOG_LEVEL_DEBUG, "In DBinsert_id()" );
if(exec_result == FAIL) return 0;
zbx_snprintf(sql, sizeof(sql), "select %s_%s.currval from dual", table, field);
result=DBselect("%s", sql);
row = DBfetch(result);
ZBX_STR2UINT64(id, row[0]);
/* id = atoi(row[0]);*/
DBfree_result(result);
return id;
#endif
#ifdef HAVE_SQLITE3
return (zbx_uint64_t)sqlite3_last_insert_rowid(conn);
#endif
}
示例6: jarun_icon_info
/******************************************************************************
* *
* Function: *
* *
* Purpose: *
* *
* Parameters: *
* *
* Return value: *
* *
* Comments: *
* *
******************************************************************************/
int jarun_icon_info(const zbx_uint64_t inner_job_id)
{
DB_RESULT result;
DB_ROW row;
int status;
char str_status[4];
zbx_uint64_t inner_jobnet_id;
int info_flag;
char *get_job_id, *get_calendar_id;
const char *__function_name = "jarun_icon_info";
zabbix_log(LOG_LEVEL_DEBUG, "In %s() inner_job_id: " ZBX_FS_UI64,
__function_name, inner_job_id);
result =
DBselect
("select inner_jobnet_id, info_flag, get_job_id, get_calendar_id"
" from ja_run_icon_info_table" " where inner_job_id = "
ZBX_FS_UI64, inner_job_id);
status = -1;
if (NULL != (row = DBfetch(result))) {
ZBX_STR2UINT64(inner_jobnet_id, row[0]);
info_flag = atoi(row[1]);
get_job_id = row[2];
get_calendar_id = row[3];
switch (info_flag) {
case 0:
status = jarun_icon_info_get_status(inner_jobnet_id, get_job_id, inner_job_id);
break;
case 3:
status = jarun_icon_info_get_calendar(get_calendar_id, inner_job_id);
break;
default:
break;
}
} else {
ja_log("JARUNICONINFO200003", inner_jobnet_id, NULL, inner_job_id,
__function_name, inner_job_id);
DBfree_result(result);
return FAIL;
}
DBfree_result(result);
if (status < 0)
return ja_set_runerr(inner_job_id, 2);
zbx_snprintf(str_status, sizeof(str_status), "%d", status);
ja_set_value_after(inner_job_id, inner_jobnet_id, "LAST_STATUS",
str_status);
return ja_flow(inner_job_id, JA_FLOW_TYPE_NORMAL, 1);
}
示例7: check_script_permissions
static int check_script_permissions(zbx_uint64_t groupid, zbx_uint64_t hostid, char *error, size_t max_error_len)
{
const char *__function_name = "check_script_permissions";
DB_RESULT result;
int ret = SUCCEED;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() groupid:" ZBX_FS_UI64 " hostid:" ZBX_FS_UI64,
__function_name, groupid, hostid);
if (0 == groupid)
goto exit;
result = DBselect(
"select hostid"
" from hosts_groups"
" where hostid=" ZBX_FS_UI64
" and groupid=" ZBX_FS_UI64,
hostid, groupid);
if (NULL == DBfetch(result))
{
zbx_strlcpy(error, "Insufficient permissions. Host is not in an allowed host group.", max_error_len);
ret = FAIL;
}
DBfree_result(result);
exit:
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(ret));
return ret;
}
示例8: DBget_script_by_scriptid
static int DBget_script_by_scriptid(zbx_uint64_t scriptid, zbx_script_t *script, zbx_uint64_t *groupid)
{
const char *__function_name = "DBget_script_by_scriptid";
DB_RESULT result;
DB_ROW row;
int ret = FAIL;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);
result = DBselect(
"select type,execute_on,command,groupid"
" from scripts"
" where scriptid=" ZBX_FS_UI64,
scriptid);
if (NULL != (row = DBfetch(result)))
{
script->type = (unsigned char)atoi(row[0]);
script->execute_on = (unsigned char)atoi(row[1]);
script->command = zbx_strdup(script->command, row[2]);
ZBX_DBROW2UINT64(*groupid, row[3]);
ret = SUCCEED;
}
DBfree_result(result);
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(ret));
return ret;
}
示例9: get_proxy_id
/******************************************************************************
* *
* Function: get_proxy_id *
* *
* Purpose: *
* *
* Parameters: *
* *
* Return value: SUCCEED - processed successfully *
* FAIL - an error occurred *
* *
* Author: Aleksander Vladishev *
* *
* Comments: *
* *
******************************************************************************/
int get_proxy_id(struct zbx_json_parse *jp, zbx_uint64_t *hostid)
{
DB_RESULT result;
DB_ROW row;
char host[HOST_HOST_LEN_MAX], host_esc[MAX_STRING_LEN];
int res = FAIL;
if (SUCCEED == zbx_json_value_by_name(jp, ZBX_PROTO_TAG_HOST, host, sizeof(host))) {
DBescape_string(host, host_esc, sizeof(host_esc));
result = DBselect("select hostid from hosts where host='%s'"
" and status in (%d)" DB_NODE,
host_esc,
HOST_STATUS_PROXY,
DBnode_local("hostid"));
if (NULL != (row = DBfetch(result)) && FAIL == DBis_null(row[0])) {
*hostid = zbx_atoui64(row[0]);
res = SUCCEED;
} else
zabbix_log(LOG_LEVEL_WARNING, "Unknown proxy \"%s\"",
host);
DBfree_result(result);
} else {
zabbix_log(LOG_LEVEL_WARNING, "Incorrect data. %s",
zbx_json_strerror());
zabbix_syslog("Incorrect data. %s",
zbx_json_strerror());
}
return res;
}
示例10: housekeeping_events
static int housekeeping_events(int now)
{
const char *__function_name = "housekeeping_events";
int event_history, deleted = 0;
DB_RESULT result;
DB_ROW row;
zbx_uint64_t eventid;
zabbix_log(LOG_LEVEL_DEBUG, "In %s() now:%d", __function_name, now);
result = DBselect("select eventid from events where clock<%d",
now - *(int *)DCconfig_get_config_data(&event_history, CONFIG_EVENT_HISTORY) * SEC_PER_DAY);
while (NULL != (row = DBfetch(result)))
{
ZBX_STR2UINT64(eventid, row[0]);
DBexecute("delete from acknowledges where eventid=" ZBX_FS_UI64, eventid);
deleted += DBexecute("delete from events where eventid=" ZBX_FS_UI64, eventid);
}
DBfree_result(result);
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%d", __function_name, deleted);
return deleted;
}
示例11: connect_to_node
int connect_to_node(int nodeid, zbx_sock_t *sock)
{
DB_RESULT result;
DB_ROW row;
unsigned short port;
int res = FAIL;
zabbix_log(LOG_LEVEL_DEBUG, "In connect_to_node(nodeid:%d)", nodeid);
result = DBselect("select ip,port from nodes where nodeid=%d", nodeid);
if (NULL != (row = DBfetch(result)))
{
port = (unsigned short)atoi(row[1]);
if (SUCCEED == zbx_tcp_connect(sock, CONFIG_SOURCE_IP, row[0], port, 0))
res = SUCCEED;
else
zabbix_log(LOG_LEVEL_ERR, "NODE %d: Unable to connect to Node [%d] error: %s",
CONFIG_NODEID, nodeid, zbx_tcp_strerror());
}
else
zabbix_log(LOG_LEVEL_ERR, "NODE %d: Node [%d] is unknown", CONFIG_NODEID, nodeid);
DBfree_result(result);
return res;
}
示例12: process_recovery_msg
static void process_recovery_msg(DB_ESCALATION *escalation, DB_EVENT *r_event, DB_ACTION *action)
{
const char *__function_name = "process_recovery_msg";
DB_RESULT result;
DB_ROW row;
zbx_uint64_t userid, mediatypeid;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);
if (1 == action->recovery_msg)
{
result = DBselect("select distinct userid,mediatypeid from alerts where actionid=" ZBX_FS_UI64
" and eventid=" ZBX_FS_UI64 " and mediatypeid is not null and alerttype=%d",
action->actionid,
escalation->eventid,
ALERT_TYPE_MESSAGE);
while (NULL != (row = DBfetch(result)))
{
ZBX_DBROW2UINT64(userid, row[0]);
ZBX_STR2UINT64(mediatypeid, row[1]);
escalation->esc_step = 0;
add_message_alert(escalation, r_event, action, userid, mediatypeid, action->shortdata, action->longdata);
}
DBfree_result(result);
}
else
zabbix_log(LOG_LEVEL_DEBUG, "escalation stopped: recovery message not defined",
escalation->actionid);
escalation->status = ESCALATION_STATUS_COMPLETED;
zabbix_log(LOG_LEVEL_DEBUG, "End of %s()", __function_name);
}
示例13: get_trigger_permission
/******************************************************************************
* *
* Function: get_trigger_permission *
* *
* Purpose: Return user permissions for access to trigger *
* *
* Parameters: *
* *
* Return value: PERM_DENY - if host or user not found, *
* or permission otherwise *
* *
* Author: *
* *
* Comments: *
* *
******************************************************************************/
static int get_trigger_permission(zbx_uint64_t userid, zbx_uint64_t triggerid)
{
const char *__function_name = "get_trigger_permission";
DB_RESULT result;
DB_ROW row;
int perm = PERM_DENY, host_perm;
zbx_uint64_t hostid;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);
result = DBselect(
"select distinct i.hostid"
" from items i,functions f"
" where i.itemid=f.itemid"
" and f.triggerid=" ZBX_FS_UI64,
triggerid);
while (NULL != (row = DBfetch(result)))
{
ZBX_STR2UINT64(hostid, row[0]);
host_perm = get_host_permission(userid, hostid);
if (perm < host_perm)
perm = host_perm;
}
DBfree_result(result);
zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_permission_string(perm));
return perm;
}
示例14: ja_host_lock
/******************************************************************************
* *
* Function: *
* *
* Purpose: *
* *
* Parameters: *
* *
* Return value: *
* *
* Comments: *
* *
******************************************************************************/
int ja_host_lock(const char *host, const zbx_uint64_t inner_job_id)
{
int db_ret;
char *host_esc;
const char *__function_name = "ja_host_lock";
zabbix_log(LOG_LEVEL_DEBUG, "In %s() host: %s", __function_name, host);
if (ja_host_getip(host, NULL, inner_job_id, NULL, JA_TXN_ON) == 0)
return FAIL;
DBfree_result(DBselect
("select lock_host_name from ja_host_lock_table where lock_host_name = 'HOST_LOCK_RECORD' for update"));
host_esc = DBdyn_escape_string(host);
db_ret =
DBexecute
("insert into ja_host_lock_table (lock_host_name) values ('%s')",
host_esc);
zbx_free(host_esc);
if (db_ret < ZBX_DB_OK) {
ja_log("JAHOST200005", 0, NULL, inner_job_id, __function_name, host, inner_job_id);
return FAIL;
} else {
return SUCCEED;
}
}
示例15: ja_host_getport
/******************************************************************************
* *
* Function: ja_host_getport *
* *
* Purpose: get the port that is specified in the host macro *
* *
* Parameters: hostid (in) - host id *
* macro_flag (in) - macro flag *
* 0: job agent listen port *
* 1: ssh connect port *
* *
* *
* Return value: return the port number *
* *
* Comments: *
* *
******************************************************************************/
int ja_host_getport(zbx_uint64_t hostid, int macro_flag)
{
DB_RESULT result;
DB_ROW row;
int port;
char *macro_name;
const char *__function_name = "ja_host_getport";
zabbix_log(LOG_LEVEL_DEBUG, "In %s() hostid: " ZBX_FS_UI64, __function_name, hostid);
if (macro_flag == 0) {
port = CONFIG_AGENT_LISTEN_PORT;
macro_name = JA_AGENT_PORT;
}
else {
port = JA_SSH_CONNECT_PORT;
macro_name = JA_SSH_PORT;
}
result = DBselect("select value from hostmacro where hostid = " ZBX_FS_UI64
" and macro = '%s'", hostid, macro_name);
row = DBfetch(result);
if (row != NULL) {
port = atoi(row[0]);
}
DBfree_result(result);
return port;
}