Exemplo n.º 1
0
Stats *
add_new_stats(username_t username, Stats * st, long long tick_id) {
	User_stats *us = (User_stats *) g_hash_table_lookup(users, username);
    struct governor_config data_cfg;
    get_config_data( &data_cfg );
	//pthread_mutex_lock(&mtx_account);
	if (!us) {
		us = add_user_stats(username, accounts, users);
	}

	if(data_cfg.debug_user && !us->account->need_dbg){
		int len = strlen(data_cfg.debug_user);
		if(!strncmp(data_cfg.debug_user, us->account->id, len)){
			us->account->need_dbg = 1;
		}
	}
	/*if(check_if_user_restricted(username, accounts) && data_cfg.use_lve){
		return NULL;
	}*/
	Stats *stt = NULL;
	if(us){
		if (us->tick == tick_id){
			stt = refresh_stats(st, us);
		} else {
			us->tick = get_current_tick();
			stt = push_stats(st, us);
		}
	}
	//pthread_mutex_unlock(&mtx_account);
	return stt;
}
Exemplo n.º 2
0
void tick_empty_users(gpointer key, User_stats * us, void *data) {
	if (is_new_tick(us->tick)) {
		us->tick = get_current_tick();
		Stats stats_holder;
		reset_stats(&stats_holder);
		push_stats(&stats_holder, us);
	}
}
Exemplo n.º 3
0
static unsigned int
vstat_push_test(struct http_request *request, const char *arg, void *data)
{
	struct vstat_priv_t *vstat;
	struct agent_core_t *core = data;

	(void)arg;
	GET_PRIV(core, vstat);
	if (push_stats(vstat, &vstat->http) < 0)
		http_reply(request->connection, 500, "Stats pushing failed");
	else
		http_reply(request->connection, 200, "Stats pushed");
	return 0;
}
Exemplo n.º 4
0
static void *
vstat_run(void *data)
{
	struct vstat_priv_t *vstat;
	struct agent_core_t *core = data;

	GET_PRIV(core, vstat);
	while (1) {
		sleep(1);
		/*
		 * FIXME: This whole thing is bonkers.
		 */
		if (push_stats(vstat, &vstat->timer) < 0)
			sleep(10);
	}
	return NULL;
}