当前位置: 首页>>代码示例>>C++>>正文


C++ DBfetch函数代码示例

本文整理汇总了C++中DBfetch函数的典型用法代码示例。如果您正苦于以下问题:C++ DBfetch函数的具体用法?C++ DBfetch怎么用?C++ DBfetch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DBfetch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:zabbix,项目名称:zabbix,代码行数:60,代码来源:dbupgrade_3020.c

示例2: 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;
}
开发者ID:mastering-jaz,项目名称:jobarranger,代码行数:69,代码来源:jaruniconinfo.c

示例3: DBpatch_2010050

static int	DBpatch_2010050(void)
{
	char		*fields[] = {"ts_from", "ts_to", NULL};
	DB_RESULT	result;
	DB_ROW		row;
	int		i;
	time_t		ts;
	struct tm	*tm;

	for (i = 0; NULL != fields[i]; i++)
	{
		result = DBselect(
				"select timeid,%s"
				" from services_times"
				" where type in (%d,%d)"
					" and %s>%d",
				fields[i], 0 /* SERVICE_TIME_TYPE_UPTIME */, 1 /* SERVICE_TIME_TYPE_DOWNTIME */,
				fields[i], SEC_PER_WEEK);

		while (NULL != (row = DBfetch(result)))
		{
			if (SEC_PER_WEEK < (ts = (time_t)atoi(row[1])))
			{
				tm = localtime(&ts);
				ts = tm->tm_wday * SEC_PER_DAY + tm->tm_hour * SEC_PER_HOUR + tm->tm_min * SEC_PER_MIN;
				DBexecute("update services_times set %s=%d where timeid=%s",
						fields[i], (int)ts, row[0]);
			}
		}
		DBfree_result(result);
	}

	return SUCCEED;
}
开发者ID:HupuInc,项目名称:zabbix,代码行数:34,代码来源:dbupgrade_2010.c

示例4: 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;
}
开发者ID:nabnut,项目名称:zabbix2.0-cookies,代码行数:26,代码来源:housekeeper.c

示例5: 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;
}
开发者ID:baniuyao,项目名称:Zabbix_PPTV,代码行数:28,代码来源:nodecomms.c

示例6: 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);
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:35,代码来源:escalator.c

示例7: 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;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:47,代码来源:escalator.c

示例8: op_run_commands

/******************************************************************************
 *                                                                            *
 * Function: run_commands                                                     *
 *                                                                            *
 * Purpose: run remote commandlist for specific action                        *
 *                                                                            *
 * Parameters: trigger - trigger data                                         *
 *             action  - action data                                          *
 *                                                                            *
 * Author: Eugene Grigorjev                                                   *
 *                                                                            *
 * Comments: commands separated with newline                                  *
 *                                                                            *
 ******************************************************************************/
void	op_run_commands(char *cmd_list)
{
	DB_RESULT	result;
	DB_ROW		row;
	char		*alias, *alias_esc, *command;
	int		is_group;

	assert(cmd_list);

	zabbix_log(LOG_LEVEL_DEBUG, "In run_commands()");

	while (1 != get_next_command(&cmd_list, &alias, &is_group, &command))
	{
		if (!alias || *alias == '\0' || !command || *command == '\0')
			continue;

		if (is_group)
		{
			alias_esc = DBdyn_escape_string(alias);
			result = DBselect("select distinct h.host from hosts_groups hg,hosts h,groups g"
					" where hg.hostid=h.hostid and hg.groupid=g.groupid and g.name='%s'" DB_NODE,
					alias_esc,
					DBnode_local("h.hostid"));
			zbx_free(alias_esc);

			while (NULL != (row = DBfetch(result)))
				run_remote_command(row[0], command);

			DBfree_result(result);
		}
		else
			run_remote_command(alias, command);
	}
	zabbix_log( LOG_LEVEL_DEBUG, "End run_commands()");
}
开发者ID:baniuyao,项目名称:Zabbix_PPTV,代码行数:49,代码来源:operations.c

示例9: zbx_session_validate

/******************************************************************************
 *                                                                            *
 * Function: zbx_session_validate                                             *
 *                                                                            *
 * Purpose: validates active session by access level                          *
 *                                                                            *
 * Parameters:  sessionid    - [IN] the session id to validate                *
 *              access_level - [IN] the required access rights                *
 *                                                                            *
 * Return value:  SUCCEED - the session is active and user has the required   *
 *                          access rights.                                    *
 *                FAIL    - the session is not active or usr has not enough   *
 *                          access rights.                                    *
 *                                                                            *
 ******************************************************************************/
static int	zbx_session_validate(const char *sessionid, int access_level)
{
	char		*sessionid_esc;
	int		ret = FAIL;
	DB_RESULT	result;
	DB_ROW		row;

	sessionid_esc = DBdyn_escape_string(sessionid);

	result = DBselect(
			"select null"
			" from users u,sessions s"
			" where u.userid=s.userid"
				" and s.status=%d"
				" and s.sessionid='%s'"
				" and u.type>=%d",
			ZBX_SESSION_ACTIVE, sessionid_esc, access_level);

	if (NULL != (row = DBfetch(result)))
		ret = SUCCEED;
	DBfree_result(result);

	zbx_free(sessionid_esc);

	return ret;
}
开发者ID:HenryGeek,项目名称:auto_deploy,代码行数:41,代码来源:trapper.c

示例10: 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;
}
开发者ID:phedders,项目名称:zabbix,代码行数:49,代码来源:proxyconfig.c

示例11: housekeeping_history_and_trends

/******************************************************************************
 *                                                                            *
 * Function: housekeeping_history_and_trends                                  *
 *                                                                            *
 * Purpose: remove outdated information from history and trends               *
 *                                                                            *
 * Parameters: now - current timestamp                                        *
 *                                                                            *
 * Return value: SUCCEED - information removed succesfully                    *
 *               FAIL - otherwise                                             *
 *                                                                            *
 * Author: Alexei Vladishev                                                   *
 *                                                                            *
 * Comments:                                                                  *
 *                                                                            *
 ******************************************************************************/
static int housekeeping_history_and_trends(int now)
{
        DB_ITEM         item;

        DB_RESULT       result;
        DB_ROW          row;

        int             deleted = 0;

        zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_history_and_trends(%d)",
		now);

        result = DBselect("select itemid,history,trends from items");

        while((row=DBfetch(result)))
        {
		ZBX_STR2UINT64(item.itemid,row[0]);
                item.history=atoi(row[1]);
                item.trends=atoi(row[2]);

                deleted += delete_history("history", item.itemid, item.history, now);
                deleted += delete_history("history_uint", item.itemid, item.history, now);
                deleted += delete_history("history_str", item.itemid, item.history, now);
                deleted += delete_history("history_text", item.itemid, item.history, now);
                deleted += delete_history("history_log", item.itemid, item.history, now);
                deleted += delete_history("trends", item.itemid, item.trends, now);
        }
        DBfree_result(result);
        return deleted;
}
开发者ID:Shmuma,项目名称:z,代码行数:46,代码来源:housekeeper.c

示例12: housekeeping_events

static int housekeeping_events(int now)
{
	int		event_history;
	DB_RESULT	result;
	DB_ROW		row1;
	int		res = SUCCEED;

	zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_events(%d)",
		now);

	result = DBselect("select event_history from config");

	row1=DBfetch(result);
	
	if(!row1 || DBis_null(row1[0])==SUCCEED)
	{
		zabbix_log( LOG_LEVEL_ERR, "No records in table 'config'.");
		res = FAIL;
	}
	else
	{
		event_history=atoi(row1[0]);
		DBexecute ("delete from events where clock < %d", now-24*3600*event_history);
	}
	
	DBfree_result(result);
	return res;
}
开发者ID:Shmuma,项目名称:z,代码行数:28,代码来源:housekeeper.c

示例13: housekeeping_alerts

static int housekeeping_alerts(int now)
{
	int	alert_history;
	DB_RESULT	result;
	DB_ROW		row;
	int		res = SUCCEED;
	int		deleted;

	zabbix_log( LOG_LEVEL_DEBUG, "In housekeeping_alerts(%d)",
		now);

	result = DBselect("select alert_history from config");

	row=DBfetch(result);

	if(!row || DBis_null(row[0])==SUCCEED)
	{
		zabbix_log( LOG_LEVEL_ERR, "No records in table 'config'.");
		res = FAIL;
	}
	else
	{
		alert_history=atoi(row[0]);

		deleted = DBexecute("delete from alerts where clock<%d",
			now-24*3600*alert_history);
		zabbix_log( LOG_LEVEL_DEBUG, "Deleted [%ld] records from table [alerts]",
			deleted);
	}

	DBfree_result(result);
	return res;
}
开发者ID:Shmuma,项目名称:z,代码行数:33,代码来源:housekeeper.c

示例14: DBpatch_2010080

static int	DBpatch_2010080(void)
{
	DB_RESULT	result;
	DB_ROW		row;
	zbx_uint64_t	applicationid, templateid, application_templateid = 1;
	int		ret = FAIL;

	result = DBselect("select applicationid,templateid from applications where templateid is not null");

	while (NULL != (row = DBfetch(result)))
	{
		ZBX_STR2UINT64(applicationid, row[0]);
		ZBX_STR2UINT64(templateid, row[1]);

		if (ZBX_DB_OK > DBexecute(
				"insert into application_template"
					" (application_templateid,applicationid,templateid)"
					" values (" ZBX_FS_UI64 "," ZBX_FS_UI64 "," ZBX_FS_UI64 ")",
				application_templateid++, applicationid, templateid))
		{
			goto out;
		}
	}

	ret = SUCCEED;
out:
	DBfree_result(result);

	return ret;
}
开发者ID:HupuInc,项目名称:zabbix,代码行数:30,代码来源:dbupgrade_2010.c

示例15: 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;
}
开发者ID:abhilash07,项目名称:agent,代码行数:29,代码来源:scripts.c


注:本文中的DBfetch函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。