From: wessels <> Date: Tue, 17 Mar 1998 06:10:38 +0000 (+0000) Subject: lincoln dale's stat graphing code X-Git-Tag: SQUID_3_0_PRE1~3824 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=01aebf311d6919b5fa70b7ea6f4ed37b0aeb6f06;p=thirdparty%2Fsquid.git lincoln dale's stat graphing code --- diff --git a/src/stat.cc b/src/stat.cc index cc7f5565ce..af8a685f97 100644 --- a/src/stat.cc +++ b/src/stat.cc @@ -1,6 +1,6 @@ /* - * $Id: stat.cc,v 1.217 1998/03/16 20:11:53 wessels Exp $ + * $Id: stat.cc,v 1.218 1998/03/16 23:10:38 wessels Exp $ * * DEBUG: section 18 Cache Manager Statistics * AUTHOR: Harvest Derived @@ -113,6 +113,9 @@ static const char *describeFlags(const StoreEntry *); static const char *describeTimestamps(const StoreEntry *); static void statAvgTick(void *notused); static void statAvgDump(StoreEntry *, int minutes, int hours); +#if STAT_GRAPHS +static void statGraphDump(StoreEntry *); +#endif static void statCountersInit(StatCounters *); static void statCountersInitSpecial(StatCounters *); static void statCountersClean(StatCounters *); @@ -725,6 +728,11 @@ statInit(void) cachemgrRegister("utilization", "Cache Utilization", statUtilization, 0); +#if STAT_GRAPHS + cachemgrRegister("graph_variables", + "Display cache metrics graphically", + statGraphDump, 0); +#endif } static void @@ -940,7 +948,6 @@ statAvg60min(StoreEntry * e) statAvgDump(e, 60, 0); } - enum { HTTP_SVC, ICP_SVC, DNS_SVC }; @@ -980,3 +987,87 @@ snmpStatGet(int minutes) { return &CountHist[minutes]; } + + +#if STAT_GRAPHS +/* + * urgh, i don't like these, but they do cut the amount of code down immensely + */ + +#define GRAPH_PER_MIN(Y) \ + for (i=0;i<(N_COUNT_HIST-2);i++) { \ + dt = tvSubDsec(CountHist[i].timestamp, CountHist[i+1].timestamp); \ + if (dt <= 0.0) \ + break; \ + storeAppendPrintf(e, "%lu,%0.2f:", \ + CountHist[i].timestamp.tv_sec, \ + ((CountHist[i].Y - CountHist[i+1].Y) / dt)); \ + } + +#define GRAPH_PER_HOUR(Y) \ + for (i=0;i<(N_COUNT_HOUR_HIST-2);i++) { \ + dt = tvSubDsec(CountHourHist[i].timestamp, CountHourHist[i+1].timestamp); \ + if (dt <= 0.0) \ + break; \ + storeAppendPrintf(e, "%lu,%0.2f:", \ + CountHourHist[i].timestamp.tv_sec, \ + ((CountHourHist[i].Y - CountHourHist[i+1].Y) / dt)); \ + } + +#define GRAPH_TITLE(X,Y) storeAppendPrintf(e,"%s\t%s\t",X,Y); +#define GRAPH_END storeAppendPrintf(e,"\n"); + +#define GENGRAPH(X,Y,Z) \ + GRAPH_TITLE(Y,Z) \ + GRAPH_PER_MIN(X) \ + GRAPH_PER_HOUR(X) \ + GRAPH_END + +static void +statGraphDump(StoreEntry * e) +{ + int i; + double dt; + + GENGRAPH(client_http.requests, "client_http.requests", "Client HTTP requests/sec"); + GENGRAPH(client_http.hits, "client_http.hits", "Client HTTP hits/sec"); + GENGRAPH(client_http.errors, "client_http.errors", "Client HTTP errors/sec"); + GENGRAPH(client_http.kbytes_in.kb, "client_http.kbytes_in", "Client HTTP kbytes_in/sec"); + GENGRAPH(client_http.kbytes_out.kb, "client_http.kbytes_out", "Client HTTP kbytes_out/sec"); + + /* XXX todo: http median service times */ + + GENGRAPH(server.all.requests, "server.all.requests", "Server requests/sec"); + GENGRAPH(server.all.errors, "server.all.errors", "Server errors/sec"); + GENGRAPH(server.all.kbytes_in.kb, "server.all.kbytes_in", "Server total kbytes_in/sec"); + GENGRAPH(server.all.kbytes_out.kb, "server.all.kbytes_out", "Server total kbytes_out/sec"); + + GENGRAPH(server.http.requests, "server.http.requests", "Server HTTP requests/sec"); + GENGRAPH(server.http.errors, "server.http.errors", "Server HTTP errors/sec"); + GENGRAPH(server.http.kbytes_in.kb, "server.http.kbytes_in", "Server HTTP kbytes_in/sec"); + GENGRAPH(server.http.kbytes_out.kb, "server.http.kbytes_out", "Server HTTP kbytes_out/sec"); + + GENGRAPH(server.ftp.requests, "server.ftp.requests", "Server FTP requests/sec"); + GENGRAPH(server.ftp.errors, "server.ftp.errors", "Server FTP errors/sec"); + GENGRAPH(server.ftp.kbytes_in.kb, "server.ftp.kbytes_in", "Server FTP kbytes_in/sec"); + GENGRAPH(server.ftp.kbytes_out.kb, "server.ftp.kbytes_out", "Server FTP kbytes_out/sec"); + + GENGRAPH(server.other.requests, "server.other.requests", "Server other requests/sec"); + GENGRAPH(server.other.errors, "server.other.errors", "Server other errors/sec"); + GENGRAPH(server.other.kbytes_in.kb, "server.other.kbytes_in", "Server other kbytes_in/sec"); + GENGRAPH(server.other.kbytes_out.kb, "server.other.kbytes_out", "Server other kbytes_out/sec"); + + GENGRAPH(icp.pkts_sent, "icp.pkts_sent", "ICP packets sent/sec"); + GENGRAPH(icp.pkts_recv, "icp.pkts_recv", "ICP packets received/sec"); + GENGRAPH(icp.kbytes_sent.kb, "icp.kbytes_sent", "ICP kbytes_sent/sec"); + GENGRAPH(icp.kbytes_recv.kb, "icp.kbytes_recv", "ICP kbytes_received/sec"); + + /* XXX todo: icp median service times */ + /* XXX todo: dns median service times */ + + GENGRAPH(unlink.requests, "unlink.requests", "Cache File unlink requests/sec"); + GENGRAPH(page_faults, "page_faults", "System Page Faults/sec"); + GENGRAPH(select_loops, "select_loops", "System Select Loop calls/sec"); + GENGRAPH(cputime, "cputime", "CPU utilisation"); +} +#endif /* STAT_GRAPHS */