Exemplo n.º 1
0
int rates_cmd(void *cp, cp_arg_t *arg, void *data) {
  utstring_renew(CF.s);
  unsigned i,hits;
  char *when;
  for(i=0; i<CF.frames_1h->num_buckets; i++) {
    hits = *(unsigned*)(bkt(CF.frames_1h,i)->data);
    when = asctime(localtime(&(bkt(CF.frames_1h,i)->start)));
    utstring_printf(CF.s, " %u frames: %s", hits, when);
  }
  cp_add_reply(cp,utstring_body(CF.s),utstring_len(CF.s));
}
Exemplo n.º 2
0
double rate_per_sec(ts_t *t) {
  long total=0;
  int i;
  for(i=0; i<t->num_buckets; i++) total += *(int*)(bkt(t,i)->data);
  int report_seconds = STATS_INTERVAL * t->num_buckets;
  double events_per_second = report_seconds ? (total * 1.0 / report_seconds) : 0;
  return events_per_second;
}
Exemplo n.º 3
0
void bkt(int *st, int k, int N)
{
	init(st, k);
	while (succesor(st, k, N))
	{
		if (valid(st, k))
			if (solutie(st, k, N))
				tipar(st, k);
			else
				bkt(st, k + 1, N);
	}
}