Browse Source

add total requests (hits + misses) to stats

master
Brett Langdon 13 years ago
parent
commit
21728df16b
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      src/handlers.c

+ 3
- 1
src/handlers.c View File

@ -3,6 +3,7 @@
const char* VERSION = "0.0.1"; const char* VERSION = "0.0.1";
const char* STATS_FORMAT = const char* STATS_FORMAT =
"STAT connections %d\r\n" "STAT connections %d\r\n"
"STAT requests %d\r\n"
"STAT hits %d\r\n" "STAT hits %d\r\n"
"STAT misses %d\r\n" "STAT misses %d\r\n"
"STAT hit_ratio %2.4f\r\n" "STAT hit_ratio %2.4f\r\n"
@ -12,6 +13,7 @@ const char* STATS_FORMAT =
void handle_stats(KCLIST* tokens, FILE* client){ void handle_stats(KCLIST* tokens, FILE* client){
char out[1024]; char out[1024];
int total = hits + misses;
float hit_ratio = 0; float hit_ratio = 0;
if(hits){ if(hits){
hit_ratio = (float)hits / (float)(hits + misses); hit_ratio = (float)hits / (float)(hits + misses);
@ -36,7 +38,7 @@ void handle_stats(KCLIST* tokens, FILE* client){
kclistdel(parts); kclistdel(parts);
strcat(status_buf, buf); strcat(status_buf, buf);
} }
sprintf(out, STATS_FORMAT, connections, hits, misses, hit_ratio, size, status_buf);
sprintf(out, STATS_FORMAT, connections, total, hits, misses, hit_ratio, size, status_buf);
fputs(out, client); fputs(out, client);
} }


Loading…
Cancel
Save