--------------------- PatchSet 10473 Date: 2008/03/27 12:47:16 Author: adri Branch: s2_delaywork Tag: (none) Log: * Transfer statistics per delay pool * Start playing with statistic reporting (class 1/class 2; no class 3 yet) Members: src/delay_pools.c:1.18.12.1->1.18.12.2 Index: squid/src/delay_pools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/delay_pools.c,v retrieving revision 1.18.12.1 retrieving revision 1.18.12.2 diff -u -r1.18.12.1 -r1.18.12.2 --- squid/src/delay_pools.c 25 Mar 2008 11:33:36 -0000 1.18.12.1 +++ squid/src/delay_pools.c 27 Mar 2008 12:47:16 -0000 1.18.12.2 @@ -1,6 +1,6 @@ /* - * $Id: delay_pools.c,v 1.18.12.1 2008/03/25 11:33:36 adri Exp $ + * $Id: delay_pools.c,v 1.18.12.2 2008/03/27 12:47:16 adri Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: David Luyer @@ -41,6 +41,7 @@ struct _class1DelayPool { int class; int aggregate; + uint64_t aggregate_bytes; }; #define IND_MAP_SZ 256 @@ -48,12 +49,14 @@ struct _class2DelayPool { int class; int aggregate; + uint64_t aggregate_bytes; /* OK: -1 is terminator. individual[255] is always host 255. */ /* 255 entries + 1 terminator byte */ unsigned char individual_map[IND_MAP_SZ]; unsigned char individual_255_used; /* 256 entries */ int individual[IND_MAP_SZ]; + uint64_t individual_bytes[IND_MAP_SZ]; }; #define NET_MAP_SZ 256 @@ -62,18 +65,21 @@ struct _class3DelayPool { int class; int aggregate; + uint64_t aggregate_bytes; /* OK: -1 is terminator. network[255] is always host 255. */ /* 255 entries + 1 terminator byte */ unsigned char network_map[NET_MAP_SZ]; unsigned char network_255_used; /* 256 entries */ int network[256]; + uint64_t network_bytes[256]; /* 256 sets of (255 entries + 1 terminator byte) */ unsigned char individual_map[NET_MAP_SZ][IND_MAP_SZ]; /* Pack this into one bit per net */ unsigned char individual_255_used[32]; /* largest entry = (255<<8)+255 = 65535 */ int individual[C3_IND_SZ]; + uint64_t individual_bytes[C3_IND_SZ]; }; typedef struct _class1DelayPool class1DelayPool; @@ -630,15 +636,25 @@ switch (class) { case 1: delay_data[pool].class1->aggregate -= qty; + + delay_data[pool].class1->aggregate_bytes += qty; return; case 2: delay_data[pool].class2->aggregate -= qty; delay_data[pool].class2->individual[position] -= qty; + + delay_data[pool].class2->aggregate_bytes += qty; + delay_data[pool].class2->individual_bytes[position] += qty; return; case 3: delay_data[pool].class3->aggregate -= qty; delay_data[pool].class3->network[position >> 8] -= qty; delay_data[pool].class3->individual[position] -= qty; + + delay_data[pool].class3->aggregate_bytes += qty; + delay_data[pool].class3->network_bytes[position >> 8] += qty; + delay_data[pool].class3->individual_bytes[position] += qty; + return; } fatalf("delayBytesWanted: Invalid class %d\n", class); @@ -695,7 +711,7 @@ } static void -delayPoolStatsAg(StoreEntry * sentry, delaySpecSet * rate, int ag) +delayPoolStatsAg(StoreEntry * sentry, delaySpecSet * rate, int ag, uint64_t bytes) { /* note - always pass delaySpecSet's by reference as may be incomplete */ if (rate->aggregate.restore_bps == -1) { @@ -705,7 +721,8 @@ storeAppendPrintf(sentry, "\tAggregate:\n"); storeAppendPrintf(sentry, "\t\tMax: %d\n", rate->aggregate.max_bytes); storeAppendPrintf(sentry, "\t\tRestore: %d\n", rate->aggregate.restore_bps); - storeAppendPrintf(sentry, "\t\tCurrent: %d\n\n", ag); + storeAppendPrintf(sentry, "\t\tCurrent: %d\n", ag); + storeAppendPrintf(sentry, "\t\tBytes Transferred: %" PRINTF_OFF_T "\n\n", bytes); } static void @@ -715,7 +732,7 @@ delaySpecSet *rate = Config.Delay.rates[pool]; storeAppendPrintf(sentry, "Pool: %d\n\tClass: 1\n\n", pool + 1); - delayPoolStatsAg(sentry, rate, delay_data[pool].class1->aggregate); + delayPoolStatsAg(sentry, rate, delay_data[pool].class1->aggregate, delay_data[pool].class1->aggregate_bytes); } static void @@ -728,7 +745,7 @@ unsigned int i; storeAppendPrintf(sentry, "Pool: %d\n\tClass: 2\n\n", pool + 1); - delayPoolStatsAg(sentry, rate, class2->aggregate); + delayPoolStatsAg(sentry, rate, class2->aggregate, class2->aggregate_bytes); if (rate->individual.restore_bps == -1) { storeAppendPrintf(sentry, "\tIndividual:\n\t\tDisabled.\n\n"); return; @@ -740,12 +757,12 @@ for (i = 0; i < IND_MAP_SZ; i++) { if (class2->individual_map[i] == 255) break; - storeAppendPrintf(sentry, "%d:%d ", class2->individual_map[i], - class2->individual[i]); + storeAppendPrintf(sentry, "%d:%d (%" PRINTF_OFF_T ") ", class2->individual_map[i], + class2->individual[i], class2->individual_bytes[i]); shown = 1; } if (class2->individual_255_used) { - storeAppendPrintf(sentry, "%d:%d ", 255, class2->individual[255]); + storeAppendPrintf(sentry, "%d:%d (%" PRINTF_OFF_T ")", 255, class2->individual[255], class2->individual_bytes[255]); shown = 1; } if (!shown) @@ -764,7 +781,7 @@ unsigned int j; storeAppendPrintf(sentry, "Pool: %d\n\tClass: 3\n\n", pool + 1); - delayPoolStatsAg(sentry, rate, class3->aggregate); + delayPoolStatsAg(sentry, rate, class3->aggregate, class3->aggregate_bytes); if (rate->network.restore_bps == -1) { storeAppendPrintf(sentry, "\tNetwork:\n\t\tDisabled."); } else {