--------------------- PatchSet 10486 Date: 2008/04/05 07:41:52 Author: adri Branch: s2_delaywork Tag: (none) Log: Play around with a "new" delay pools stats reporting style, inteded to eventually replace the older stuff. It'll look less pretty but it'll be easily machine parsable, easier to extend and serves as an experimental ground for "SNMP" like support in the future. Members: src/delay_pools.c:1.18.12.5->1.18.12.6 Index: squid/src/delay_pools.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/delay_pools.c,v retrieving revision 1.18.12.5 retrieving revision 1.18.12.6 diff -u -r1.18.12.5 -r1.18.12.6 --- squid/src/delay_pools.c 1 Apr 2008 12:24:00 -0000 1.18.12.5 +++ squid/src/delay_pools.c 5 Apr 2008 07:41:52 -0000 1.18.12.6 @@ -1,6 +1,6 @@ /* - * $Id: delay_pools.c,v 1.18.12.5 2008/04/01 12:24:00 adri Exp $ + * $Id: delay_pools.c,v 1.18.12.6 2008/04/05 07:41:52 adri Exp $ * * DEBUG: section 77 Delay Pools * AUTHOR: David Luyer @@ -101,6 +101,7 @@ static long memory_used = 0; static OBJH delayPoolStats; +static OBJH delayPoolStatsNew; static unsigned int delayIdPtrHash(const void *key, unsigned int n) @@ -142,6 +143,7 @@ delay_pools_last_update = getCurrentTime(); delay_no_delay = xcalloc(1, Squid_MaxFD); cachemgrRegister("delay", "Delay Pool Levels", delayPoolStats, 0, 1); + cachemgrRegister("delay2", "Delay Pool Statistics", delayPoolStatsNew, 0, 1); } void @@ -711,28 +713,40 @@ } static void -delayPoolStatsAg(StoreEntry * sentry, delaySpecSet * rate, int ag, uint64_t bytes) +delayPoolStatsAg(StoreEntry * sentry, int pool, int type, delaySpecSet * rate, int ag, uint64_t bytes) { /* note - always pass delaySpecSet's by reference as may be incomplete */ if (rate->aggregate.restore_bps == -1) { - storeAppendPrintf(sentry, "\tAggregate:\n\t\tDisabled.\n\n"); + if (type == 1) + storeAppendPrintf(sentry, "\tAggregate:\n\t\tDisabled.\n\n"); return; } - 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", ag); - storeAppendPrintf(sentry, "\t\tBytes Transferred: %" PRIu64 "\n\n", bytes); + if (type == 1) { + 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", ag); + storeAppendPrintf(sentry, "\t\tBytes Transferred: %" PRIu64 "\n\n", bytes); + } else { + storeAppendPrintf(sentry, "pools.pool.%d.max=%d\n", pool + 1, rate->aggregate.max_bytes); + storeAppendPrintf(sentry, "pools.pool.%d.restore=%d\n", pool + 1, rate->aggregate.restore_bps); + storeAppendPrintf(sentry, "pools.pool.%d.current=%d\n", pool + 1, ag); + storeAppendPrintf(sentry, "pools.pool.%d.bytes=%" PRIu64 "\n", pool + 1, bytes); + } } static void -delayPoolStats1(StoreEntry * sentry, unsigned short pool) +delayPoolStats1(StoreEntry * sentry, int type, unsigned short pool) { /* must be a reference only - partially malloc()d struct */ 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, delay_data[pool].class1->aggregate_bytes); + if (type == 1) { + storeAppendPrintf(sentry, "Pool: %d\n\tClass: 1\n\n", pool + 1); + } else { + storeAppendPrintf(sentry, "pools.pool.%d.class=1\n", pool + 1); + } + delayPoolStatsAg(sentry, pool, type, rate, delay_data[pool].class1->aggregate, delay_data[pool].class1->aggregate_bytes); } static void @@ -745,7 +759,7 @@ unsigned int i; storeAppendPrintf(sentry, "Pool: %d\n\tClass: 2\n\n", pool + 1); - delayPoolStatsAg(sentry, rate, class2->aggregate, class2->aggregate_bytes); + delayPoolStatsAg(sentry, pool, 1, rate, class2->aggregate, class2->aggregate_bytes); if (rate->individual.restore_bps == -1) { storeAppendPrintf(sentry, "\tIndividual:\n\t\tDisabled.\n\n"); return; @@ -781,7 +795,7 @@ unsigned int j; storeAppendPrintf(sentry, "Pool: %d\n\tClass: 3\n\n", pool + 1); - delayPoolStatsAg(sentry, rate, class3->aggregate, class3->aggregate_bytes); + delayPoolStatsAg(sentry, pool, 1, rate, class3->aggregate, class3->aggregate_bytes); if (rate->network.restore_bps == -1) { storeAppendPrintf(sentry, "\tNetwork:\n\t\tDisabled."); } else { @@ -860,7 +874,7 @@ storeAppendPrintf(sentry, "\tMisconfigured pool.\n\n"); break; case 1: - delayPoolStats1(sentry, i); + delayPoolStats1(sentry, 1, i); break; case 2: delayPoolStats2(sentry, i); @@ -875,4 +889,30 @@ storeAppendPrintf(sentry, "Memory Used: %d bytes\n", (int) memory_used); } +static void +delayPoolStatsNew(StoreEntry *e) +{ + unsigned short i; + + storeAppendPrintf(e, "pools.npools=%d\n", Config.Delay.pools); + for (i = 0; i < Config.Delay.pools; i++) { + switch (Config.Delay.class[i]) { + case 0: + storeAppendPrintf(e, "pools.pool.%d.class=0\n\n", i + 1); + break; + case 1: + delayPoolStats1(e, 2, i); + break; + case 2: + delayPoolStats2(e, i); + break; + case 3: + delayPoolStats3(e, i); + break; + default: + assert(0); + } + } +} + #endif