Beispiel #1
0
Datei: rqd.c Projekt: hyper/rqd
static void init_stats(system_data_t *sysdata)
{
	assert(sysdata);
	assert(sysdata->stats == NULL);
	
	sysdata->stats = (stats_t *) malloc(sizeof(stats_t));
	stats_init(sysdata->stats);
	sysdata->stats->sysdata = sysdata;
	stats_start(sysdata->stats);
}
Beispiel #2
0
void loop_start( void )
{
	// set us going
	ctl->run_flags |= RUN_LOOP;

	get_time( );

	// start a timing circuit
	thread_throw( &loop_timer, NULL );

	// and the tset/target loops
	// must happen before stats_start
	target_start( );

	// throw the data submission loops
	stats_start( ctl->stats->stats );
	stats_start( ctl->stats->adder );
	stats_start( ctl->stats->gauge );
	stats_start( ctl->stats->self );

	// and a synthetics loop
	thread_throw( &synth_loop, NULL );

	// throw the memory control loop
	thread_throw( &mem_loop, NULL );

	// and gc
	thread_throw( &gc_loop, NULL );

	// and token cleanup
	thread_throw( &token_loop, NULL );

	// throw the data listener loop
	net_start_type( ctl->net->stats );
	net_start_type( ctl->net->adder );
	net_start_type( ctl->net->gauge );
	net_start_type( ctl->net->compat );

	// and now we wait for the signal to end
	while( ctl->run_flags & RUN_LOOP )
		sleep( 1 );
}
Beispiel #3
0
Datei: stats.c Projekt: hyper/rqd
static void stats_handler(int fd, short int flags, void *arg)
{
	stats_t *stats;
	system_data_t *sysdata;
	int clients;
	int queues;
	int msg_pending, msg_proc;
	queue_t *q;

	assert(fd < 0);
	assert((flags & EV_TIMEOUT) == EV_TIMEOUT);
	assert(arg);

	stats = arg;

	// clear the stats event.
	assert(stats->stats_event);
	event_free(stats->stats_event);
	stats->stats_event = NULL;
	
	assert(stats->sysdata);
	sysdata = stats->sysdata;
	
// 	assert(stats->sysdata->server != NULL);
// 	server = stats->sysdata->server;

	assert(sysdata->nodelist);
	clients = ll_count(sysdata->nodelist);

	queues = 0;
	msg_pending = 0;
	msg_proc = 0;
	ll_start(sysdata->queues);
	while ((q = ll_next(sysdata->queues))) {
		queues ++;
		msg_pending += ll_count(&q->msg_pending);
		msg_proc += ll_count(&q->msg_proc);
	}
	ll_finish(sysdata->queues);

	assert(stats != NULL);
	if (stats->in_bytes || stats->out_bytes || stats->requests || stats->replies || stats->broadcasts || stats->re || stats->we) {

		logger(sysdata->logging, 1, "Bytes[%u/%u], Clients[%u], Requests[%u], Replies[%u], Broadcasts[%u], Queues[%u], Msgs[%d/%d], MsgPool[%u/%u], Events[%u/%u/%u]",
			stats->in_bytes,
			stats->out_bytes,
			clients,
			stats->requests,
			stats->replies,
			stats->broadcasts,
			queues,
			msg_pending, msg_proc,
			sysdata->msg_used, sysdata->msg_max,
			stats->re, stats->we, stats->te);
		
		stats->in_bytes = 0;
		stats->out_bytes = 0;
		stats->requests = 0;
		stats->replies = 0;
		stats->broadcasts = 0;
		stats->re = 0;
		stats->we = 0;
		stats->te = 0;
	}

	// if we are not shutting down, then schedule the stats event again.
	if (stats->shutdown == 0) {
		stats_start(stats);
	}
}