int xpercentInt(double part, double whole) { #if HAVE_RINT return (int) rint(xpercent(part, whole)); #else /* SCO 3.2v4.2 doesn't have rint() -- [email protected] */ return (int) floor(xpercent(part, whole) + 0.5); #endif }
void cacheDigestGuessStatsReport(const cd_guess_stats * stats, StoreEntry * sentry, const char *label) { const int true_count = stats->true_hits + stats->true_misses; const int false_count = stats->false_hits + stats->false_misses; const int hit_count = stats->true_hits + stats->false_hits; const int miss_count = stats->true_misses + stats->false_misses; const int tot_count = true_count + false_count; assert(label); assert(tot_count == hit_count + miss_count); /* paranoid */ if (!tot_count) { storeAppendPrintf(sentry, "no guess stats for %s available\n", label); return; } storeAppendPrintf(sentry, "Digest guesses stats for %s:\n", label); storeAppendPrintf(sentry, "guess\t hit\t\t miss\t\t total\t\t\n"); storeAppendPrintf(sentry, " \t #\t %%\t #\t %%\t #\t %%\t\n"); storeAppendPrintf(sentry, "true\t %d\t %.2f\t %d\t %.2f\t %d\t %.2f\n", stats->true_hits, xpercent(stats->true_hits, tot_count), stats->true_misses, xpercent(stats->true_misses, tot_count), true_count, xpercent(true_count, tot_count)); storeAppendPrintf(sentry, "false\t %d\t %.2f\t %d\t %.2f\t %d\t %.2f\n", stats->false_hits, xpercent(stats->false_hits, tot_count), stats->false_misses, xpercent(stats->false_misses, tot_count), false_count, xpercent(false_count, tot_count)); storeAppendPrintf(sentry, "all\t %d\t %.2f\t %d\t %.2f\t %d\t %.2f\n", hit_count, xpercent(hit_count, tot_count), miss_count, xpercent(miss_count, tot_count), tot_count, xpercent(tot_count, tot_count)); storeAppendPrintf(sentry, "\tclose_hits: %d ( %d%%) /* cd said hit, doc was in the peer cache, but we got a miss */\n", stats->close_hits, xpercentInt(stats->close_hits, stats->false_hits)); }
static void cacheIndexCmpReport(CacheIndex * idx, int shared_count) { assert(idx && shared_count <= idx->count); printf("%s:\t %7d = %7d + %7d (%7.2f%% + %7.2f%%)\n", idx->name, idx->count, idx->count - shared_count, shared_count, xpercent(idx->count - shared_count, idx->count), xpercent(shared_count, idx->count)); }
static void httpHeaderFldsPerHdrDumper(StoreEntry * sentry, int idx, double val, double size, int count) { if (count) storeAppendPrintf(sentry, "%2d\t %5d\t %5d\t %6.2f\n", idx, (int) val, count, xpercent(count, dump_stat->destroyedCount)); }
static void refreshCountsStats(StoreEntry * sentry, struct RefreshCounts *rc) { int sum = 0; int tot = rc->total; storeAppendPrintf(sentry, "\n\n%s histogram:\n", rc->proto); storeAppendPrintf(sentry, "Count\t%%Total\tCategory\n"); #define refreshCountsStatsEntry(code,desc) { \ storeAppendPrintf(sentry, "%6d\t%6.2f\t%s\n", \ rc->status[code], xpercent(rc->status[code], tot), desc); \ sum += rc->status[code]; \ } refreshCountsStatsEntry(FRESH_REQUEST_MAX_STALE_ALL, "Fresh: request max-stale wildcard"); refreshCountsStatsEntry(FRESH_REQUEST_MAX_STALE_VALUE, "Fresh: request max-stale value"); refreshCountsStatsEntry(FRESH_EXPIRES, "Fresh: expires time not reached"); refreshCountsStatsEntry(FRESH_LMFACTOR_RULE, "Fresh: refresh_pattern last-mod factor percentage"); refreshCountsStatsEntry(FRESH_MIN_RULE, "Fresh: refresh_pattern min value"); refreshCountsStatsEntry(FRESH_OVERRIDE_EXPIRES, "Fresh: refresh_pattern override expires"); refreshCountsStatsEntry(FRESH_OVERRIDE_LASTMOD, "Fresh: refresh_pattern override lastmod"); refreshCountsStatsEntry(STALE_MUST_REVALIDATE, "Stale: response has must-revalidate"); refreshCountsStatsEntry(STALE_RELOAD_INTO_IMS, "Stale: changed reload into IMS"); refreshCountsStatsEntry(STALE_FORCED_RELOAD, "Stale: request has no-cache directive"); refreshCountsStatsEntry(STALE_EXCEEDS_REQUEST_MAX_AGE_VALUE, "Stale: age exceeds request max-age value"); refreshCountsStatsEntry(STALE_EXPIRES, "Stale: expires time reached"); refreshCountsStatsEntry(STALE_MAX_RULE, "Stale: refresh_pattern max age rule"); refreshCountsStatsEntry(STALE_LMFACTOR_RULE, "Stale: refresh_pattern last-mod factor percentage"); refreshCountsStatsEntry(STALE_DEFAULT, "Stale: by default"); tot = sum; /* paranoid: "total" line shows 100% if we forgot nothing */ storeAppendPrintf(sentry, "%6d\t%6.2f\tTOTAL\n", rc->total, xpercent(rc->total, tot)); \ storeAppendPrintf(sentry, "\n"); }
void storeDigestReport(StoreEntry * e) { #if USE_CACHE_DIGESTS if (!Config.onoff.digest_generation) { return; } if (store_digest) { cacheDigestReport(store_digest, "store", e); storeAppendPrintf(e, "\t added: %d rejected: %d ( %.2f %%) del-ed: %d\n", sd_stats.add_count, sd_stats.rej_count, xpercent(sd_stats.rej_count, sd_stats.rej_count + sd_stats.add_count), sd_stats.del_count); storeAppendPrintf(e, "\t collisions: on add: %.2f %% on rej: %.2f %%\n", xpercent(sd_stats.add_coll_count, sd_stats.add_count), xpercent(sd_stats.rej_coll_count, sd_stats.rej_count)); } else { storeAppendPrintf(e, "store digest: disabled.\n"); } #endif }
void httpHeaderStoreReport(StoreEntry * e) { int i; http_hdr_type ht; assert(e); HttpHeaderStats[0].parsedCount = HttpHeaderStats[hoRequest].parsedCount + HttpHeaderStats[hoReply].parsedCount; HttpHeaderStats[0].ccParsedCount = HttpHeaderStats[hoRequest].ccParsedCount + HttpHeaderStats[hoReply].ccParsedCount; HttpHeaderStats[0].destroyedCount = HttpHeaderStats[hoRequest].destroyedCount + HttpHeaderStats[hoReply].destroyedCount; HttpHeaderStats[0].busyDestroyedCount = HttpHeaderStats[hoRequest].busyDestroyedCount + HttpHeaderStats[hoReply].busyDestroyedCount; for (i = 1; i < HttpHeaderStatCount; i++) { httpHeaderStatDump(HttpHeaderStats + i, e); storeAppendPrintf(e, "%s\n", "<br>"); } /* field stats for all messages */ storeAppendPrintf(e, "\nHttp Fields Stats (replies and requests)\n"); storeAppendPrintf(e, "%2s\t %-20s\t %5s\t %6s\t %6s\n", "id", "name", "#alive", "%err", "%repeat"); for (ht = 0; ht < HDR_ENUM_END; ht++) { HttpHeaderFieldInfo *f = Headers + ht; storeAppendPrintf(e, "%2d\t %-20s\t %5d\t %6.3f\t %6.3f\n", f->id, strBuf(f->name), f->stat.aliveCount, xpercent(f->stat.errCount, f->stat.parsCount), xpercent(f->stat.repCount, f->stat.seenCount)); } storeAppendPrintf(e, "Headers Parsed: %d + %d = %d\n", HttpHeaderStats[hoRequest].parsedCount, HttpHeaderStats[hoReply].parsedCount, HttpHeaderStats[0].parsedCount); storeAppendPrintf(e, "Hdr Fields Parsed: %d\n", HeaderEntryParsedCount); }
static void refreshStats(StoreEntry * sentry) { int i; int total = 0; /* get total usage count */ for (i = 0; i < rcCount; ++i) total += refreshCounts[i].total; /* protocol usage histogram */ storeAppendPrintf(sentry, "\nRefreshCheck calls per protocol\n\n"); storeAppendPrintf(sentry, "Protocol\t#Calls\t%%Calls\n"); for (i = 0; i < rcCount; ++i) storeAppendPrintf(sentry, "%10s\t%6d\t%6.2f\n", refreshCounts[i].proto, refreshCounts[i].total, xpercent(refreshCounts[i].total, total)); /* per protocol histograms */ storeAppendPrintf(sentry, "\n\nRefreshCheck histograms for various protocols\n"); for (i = 0; i < rcCount; ++i) refreshCountsStats(sentry, &refreshCounts[i]); }