void chldreadcb(struct bufferevent *b, void *arg) { char *line, *sp, *ap; int n, i, total, nprocs = *(int *)arg; if((line=evbuffer_readline(b->input)) != nil){ sp = line; if((ap = strsep(&sp, "\t")) == nil) panic("report error\n"); n = atoi(ap); if(n - nreport > NBUFFER) panic("a process fell too far behind\n"); n %= NBUFFER; for(i=0; i<params.nbuckets + 3 && (ap=strsep(&sp, "\t")) != nil; i++) reportbuf[n][i] += atoi(ap); if(++nreportbuf[n] >= nprocs){ /* Timestamp it. */ printf("%d\t",(int)time(nil)); for(i = 0; i < params.nbuckets + 3; i++) printf("%d\t", reportbuf[n][i]); /* Compute the total rate of succesful requests. */ total = 0; for(i=3; i<params.nbuckets+1; i++) total += reportbuf[n][i]; printf("%d\n", mkrate(&lastreporttv, total)); /* Aggregate. */ counts.errors += reportbuf[n][0]; counts.timeouts += reportbuf[n][1]; counts.closes += reportbuf[n][2]; for(i=0; i<params.nbuckets; i++){ counts.successes += reportbuf[n][i + 3]; counts.counters[i] += reportbuf[n][i + 3]; } /* Clear it. Advance nreport. */ memset(reportbuf[n], 0,(params.nbuckets + 3) * sizeof(int)); nreportbuf[n] = 0; nreport++; } free(line); } bufferevent_enable(b, EV_READ); }
void chldreadcb(struct bufferevent *b, void *arg) { char *line, *sp, *ap; int n, i, nprocs = *(int *)arg; if((line=evbuffer_readline(b->input)) != nil){ sp = line; if((ap = strsep(&sp, "\t")) == nil) panic("report error\n"); n = atoi(ap); if(n - nreport > NBUFFER) panic("a process fell too far behind\n"); n %= NBUFFER; for(i=0; i<params.nbuckets + num_cols && (ap=strsep(&sp, "\t")) != nil; i++) reportbuf[n][i] += atoi(ap); if(++nreportbuf[n] >= nprocs){ /* Timestamp it. */ printf("%d\t",(int)time(nil)); for(i = 0; i < params.nbuckets + num_cols; i++) printf("%d\t", reportbuf[n][i]); printf("%ld\n", mkrate(&lastreporttv, reportbuf[n][0])); reset_time(&lastreporttv); /* Aggregate. */ counts.conn_successes += reportbuf[n][0]; counts.conn_errors += reportbuf[n][1]; counts.conn_timeouts += reportbuf[n][2]; counts.conn_closes += reportbuf[n][3]; counts.http_successes += reportbuf[n][4]; counts.http_errors += reportbuf[n][5]; for(i=0; i<params.nbuckets; i++) counts.counters[i] += reportbuf[n][i + num_cols]; /* Clear it. Advance nreport. */ memset(reportbuf[n], 0,(params.nbuckets + num_cols) * sizeof(int)); nreportbuf[n] = 0; nreport++; } free(line); } bufferevent_enable(b, EV_READ); }
void report() { char buf[128]; int i, total = counts.successes + counts.errors + counts.timeouts; printcount("successes", total, counts.successes); printcount("errors", total, counts.errors); printcount("timeouts", total, counts.timeouts); printcount("closes", total, counts.closes); for(i=0; params.buckets[i]!=0; i++){ snprintf(buf, sizeof(buf), "<%d\t", params.buckets[i]); printcount(buf, total, counts.counters[i]); } snprintf(buf, sizeof(buf), ">=%d\t", params.buckets[i - 1]); printcount(buf, total, counts.counters[i]); /* no total */ fprintf(stderr, "# hz\t\t%d\n", mkrate(&ratetv, counts.successes)); }
void report() { char buf[128]; int i, total = counts.conn_successes + counts.conn_errors + counts.conn_timeouts; fprintf(stderr, "# hz\t\t\t%ld\n", mkrate(&ratetv, total)); fprintf(stderr, "# time\t\t\t%.3f\n", milliseconds_since_start(&ratetv)/1000.0); printcount("conn_total ", total, total); printcount("conn_successes", total, counts.conn_successes); printcount("conn_errors ", total, counts.conn_errors); printcount("conn_timeouts ", total, counts.conn_timeouts); printcount("conn_closes ", total, counts.conn_closes); printcount("http_successes", total, counts.http_successes); printcount("http_errors ", total, counts.http_errors); for(i=0; params.buckets[i]!=0; i++){ snprintf(buf, sizeof(buf), "<%d\t\t", params.buckets[i]); printcount(buf, total, counts.counters[i]); } snprintf(buf, sizeof(buf), ">=%d\t\t", params.buckets[i - 1]); printcount(buf, total, counts.counters[i]); }