Beispiel #1
0
static void submit_derive (const char *type, const char *type_instance,
		derive_t c, apache_t *st)
{
	value_t v;
	v.derive = c;
	submit_value (type, type_instance, v, st);
} /* void submit_derive */
Beispiel #2
0
static void submit_derive(int cpu_num, int cpu_state, derive_t derive)
{
	value_t value;

	value.derive = derive;
	submit_value (cpu_num, cpu_state, "cpu", value);
}
Beispiel #3
0
static void submit_gauge (const char *type, const char *type_instance,
		gauge_t g, apache_t *st)
{
	value_t v;
	v.gauge = g;
	submit_value (type, type_instance, v, st);
} /* void submit_gauge */
Beispiel #4
0
static int xencpu_read (void)
{
    cdtime_t now = cdtime ();

    int rc, nr_cpus;

    rc = xc_getcpuinfo(xc_handle, num_cpus, cpu_info, &nr_cpus);
    if (rc < 0) {
        ERROR ("xencpu: xc_getcpuinfo() Failed: %d %s\n", rc, xc_strerror(xc_handle,errno));
        return (-1);
    }

    int status;
    for (int cpu = 0; cpu < nr_cpus; cpu++) {
        gauge_t rate = NAN;
        value_t value = {.derive = cpu_info[cpu].idletime};

        status = value_to_rate (&rate, value, DS_TYPE_DERIVE, now, &cpu_states[cpu]);
        if (status == 0) {
            submit_value(cpu, 100 - rate/10000000);
        }
    }

    return (0);
} /* static int xencpu_read */

void module_register (void)
{
    plugin_register_init ("xencpu", xencpu_init);
    plugin_register_read ("xencpu", xencpu_read);
    plugin_register_shutdown ("xencpu", xencpu_shutdown);
} /* void module_register */
Beispiel #5
0
static void submit_percent(int cpu_num, int cpu_state, gauge_t percent)
{
	value_t value;

	value.gauge = percent;
	submit_value (cpu_num, cpu_state, "percent", value);
}
Beispiel #6
0
static void submit_counter (const char *type, const char *type_instance,
		counter_t c, apache_t *st)
{
	value_t v;
	v.counter = c;
	submit_value (type, type_instance, v, st);
} /* void submit_counter */
// Invoked when a value is delivered
void on_deliver(void* cmd_value, size_t cmd_size, void * arg) {
	client * cl = arg;
	
	cl->current_inst_number += 1;
	
	client_proposal * c;
	unsigned i;
	
	//Check if the delivered values was sent from this process.
	for(i = 0; i < CONCURRENT_VALUES; i++) {
		c = &cl->pending_values[i];
		submit_cmd_msg * msg = c->submit_msg;
		
		//If so, submit another one
		if(cmd_size == msg->cmd_size &&
		memcmp(msg->cmd_value, cmd_value, cmd_size) == 0) {
			// printf("CMD %u accepted in instance %lu\n", i, current_inst_number);
			
			cl->deliver_count += 1;
			cl->deliver_bytes += cmd_size;

			gettimeofday(&cl->current_time, NULL);
			save_latency(cl, &c->submit_time, &cl->current_time);
			
			generate_random_value(c->submit_msg);
			submit_value(cl->us, c->submit_msg);
			save_submit_time(c, &cl->current_time);
			timer_set_timeout(&cl->current_time, &c->timeout, &cl->value_timeout_interval);
			
			break;
		}
	}
}
Beispiel #8
0
static void submit_percent(int cpu_num, int cpu_state, gauge_t percent)
{
	value_t value;

	/* This function is called for all known CPU states, but each read
	 * method will only report a subset. The remaining states are left as
	 * NAN and we ignore them here. */
	if (isnan (percent))
		return;

	value.gauge = percent;
	submit_value (cpu_num, cpu_state, "percent", value);
}
//Custom init for the learner
void client_pl_init(void * arg) {
	client * cl = arg;
	
	printf("FastClient: submitting %d values of size [%lu...%lu]\n", 
		CONCURRENT_VALUES, MIN_VAL_SIZE, MAX_VAL_SIZE);
	
	
	//Use an udp sender instead of a submit_proxy
	cl->us = udp_sender_init(
		lptopo_get_leader_addr(learner_get_topolo_mngr(cl->l)), 
		lptopo_get_leader_clients_port(learner_get_topolo_mngr(cl->l)),
		learner_get_config_mngr(cl->l));
	// No autoflush, it's manual for this client
	assert(cl->us != NULL);
	udp_sender_enable_autoflush(cl->us, 25);
	
	//Periodically check for timeouts
	cl->periodic_check =  
	set_periodic_event(
	    &cl->value_timeout_interval,  /*Interval for this event*/
	    values_timeout_check, /*Called periodically*/
	    cl /*Argument passed to above function*/
	    );

	//Periodically print statistics
	cl->periodic_stats =  
	set_periodic_event(
	    &cl->print_stats_interval,  /*Interval for this event*/
	    print_stats, /*Called periodically*/
	    cl /*Argument passed to above function*/
	    );

	printf("Client initialization completed\n");
	cl->start_time = time(NULL);
	
	gettimeofday(&cl->current_time, NULL);

	//Submit the initial amount of values
	client_proposal * c;
	unsigned i;
	for(i = 0; i < CONCURRENT_VALUES; i++) {
		c = &cl->pending_values[i];
		// c->submit_msg = malloc(sizeof(submit_cmd_msg) + MAX_VAL_SIZE);
		c->submit_msg = (submit_cmd_msg*) &cl->values_buffer[i * (MAX_VAL_SIZE + sizeof(submit_cmd_msg))];
		generate_random_value(c->submit_msg);
		submit_value(cl->us, c->submit_msg);
		save_submit_time(c, &cl->current_time);
		timer_set_timeout(&cl->current_time, &c->timeout, &cl->value_timeout_interval);
	}
}
//Check that the sent values did not time-out
// The timed-out values are re-sent
void values_timeout_check(void* arg) {
	client * cl = arg;
	
	gettimeofday(&cl->current_time, NULL);
	
	client_proposal * c;
	unsigned i;
	for(i = 0; i < CONCURRENT_VALUES; i++) {
		c = &cl->pending_values[i];
		if(timer_is_expired(&c->timeout, &cl->current_time)) {
			cl->timeout_count += 1;
			// printf("Value %u timed-out\n", i);
			submit_value(cl->us, c->submit_msg);
			save_submit_time(c, &cl->current_time);
			timer_set_timeout(&cl->current_time, &c->timeout, &cl->value_timeout_interval);
		}
	}
	
}
Beispiel #11
0
static int xencpu_read(void) {
  cdtime_t now = cdtime();

  int rc, nr_cpus;

  rc = xc_getcpuinfo(xc_handle, num_cpus, cpu_info, &nr_cpus);
  if (rc < 0) {
    ERROR("xencpu: xc_getcpuinfo() Failed: %d %s\n", rc,
          xc_strerror(xc_handle, errno));
    return -1;
  }

  int status;
  for (int cpu = 0; cpu < nr_cpus; cpu++) {
    gauge_t rate = NAN;

    status = value_to_rate(&rate, (value_t){.derive = cpu_info[cpu].idletime},
                           DS_TYPE_DERIVE, now, &cpu_states[cpu]);
    if (status == 0) {
      submit_value(cpu, 100 - rate / 10000000);
    }
  }