⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stat.c

📁 -
💻 C
📖 第 1 页 / 共 4 页
字号:
    storeAppendPrintf(sentry, "server.other.requests = %f/sec\n",	XAVG(server.other.requests));    storeAppendPrintf(sentry, "server.other.errors = %f/sec\n",	XAVG(server.other.errors));    storeAppendPrintf(sentry, "server.other.kbytes_in = %f/sec\n",	XAVG(server.other.kbytes_in.kb));    storeAppendPrintf(sentry, "server.other.kbytes_out = %f/sec\n",	XAVG(server.other.kbytes_out.kb));    storeAppendPrintf(sentry, "icp.pkts_sent = %f/sec\n",	XAVG(icp.pkts_sent));    storeAppendPrintf(sentry, "icp.pkts_recv = %f/sec\n",	XAVG(icp.pkts_recv));    storeAppendPrintf(sentry, "icp.queries_sent = %f/sec\n",	XAVG(icp.queries_sent));    storeAppendPrintf(sentry, "icp.replies_sent = %f/sec\n",	XAVG(icp.replies_sent));    storeAppendPrintf(sentry, "icp.queries_recv = %f/sec\n",	XAVG(icp.queries_recv));    storeAppendPrintf(sentry, "icp.replies_recv = %f/sec\n",	XAVG(icp.replies_recv));    storeAppendPrintf(sentry, "icp.replies_queued = %f/sec\n",	XAVG(icp.replies_queued));    storeAppendPrintf(sentry, "icp.query_timeouts = %f/sec\n",	XAVG(icp.query_timeouts));    storeAppendPrintf(sentry, "icp.kbytes_sent = %f/sec\n",	XAVG(icp.kbytes_sent.kb));    storeAppendPrintf(sentry, "icp.kbytes_recv = %f/sec\n",	XAVG(icp.kbytes_recv.kb));    storeAppendPrintf(sentry, "icp.q_kbytes_sent = %f/sec\n",	XAVG(icp.q_kbytes_sent.kb));    storeAppendPrintf(sentry, "icp.r_kbytes_sent = %f/sec\n",	XAVG(icp.r_kbytes_sent.kb));    storeAppendPrintf(sentry, "icp.q_kbytes_recv = %f/sec\n",	XAVG(icp.q_kbytes_recv.kb));    storeAppendPrintf(sentry, "icp.r_kbytes_recv = %f/sec\n",	XAVG(icp.r_kbytes_recv.kb));    x = statHistDeltaMedian(&l->icp.query_svc_time, &f->icp.query_svc_time);    storeAppendPrintf(sentry, "icp.query_median_svc_time = %f seconds\n",	x / 1000000.0);    x = statHistDeltaMedian(&l->icp.reply_svc_time, &f->icp.reply_svc_time);    storeAppendPrintf(sentry, "icp.reply_median_svc_time = %f seconds\n",	x / 1000000.0);    x = statHistDeltaMedian(&l->dns.svc_time, &f->dns.svc_time);    storeAppendPrintf(sentry, "dns.median_svc_time = %f seconds\n",	x / 1000.0);    storeAppendPrintf(sentry, "unlink.requests = %f/sec\n",	XAVG(unlink.requests));    storeAppendPrintf(sentry, "page_faults = %f/sec\n",	XAVG(page_faults));    storeAppendPrintf(sentry, "select_loops = %f/sec\n",	XAVG(select_loops));    storeAppendPrintf(sentry, "select_fds = %f/sec\n",	XAVG(select_fds));    storeAppendPrintf(sentry, "average_select_fd_period = %f/fd\n",	f->select_fds > l->select_fds ?	(f->select_time - l->select_time) / (f->select_fds - l->select_fds)	: 0.0);    x = statHistDeltaMedian(&l->select_fds_hist, &f->select_fds_hist);    storeAppendPrintf(sentry, "median_select_fds = %f\n", x);    storeAppendPrintf(sentry, "swap_files_cleaned = %f/sec\n",	XAVG(swap_files_cleaned));    storeAppendPrintf(sentry, "aborted_requests = %f/sec\n",	XAVG(aborted_requests));#if HAVE_POLL    storeAppendPrintf(sentry, "syscalls.polls = %f/sec\n", XAVG(syscalls.polls));#else    storeAppendPrintf(sentry, "syscalls.selects = %f/sec\n", XAVG(syscalls.selects));#endif    storeAppendPrintf(sentry, "syscalls.disk.opens = %f/sec\n", XAVG(syscalls.disk.opens));    storeAppendPrintf(sentry, "syscalls.disk.closes = %f/sec\n", XAVG(syscalls.disk.closes));    storeAppendPrintf(sentry, "syscalls.disk.reads = %f/sec\n", XAVG(syscalls.disk.reads));    storeAppendPrintf(sentry, "syscalls.disk.writes = %f/sec\n", XAVG(syscalls.disk.writes));    storeAppendPrintf(sentry, "syscalls.disk.seeks = %f/sec\n", XAVG(syscalls.disk.seeks));    storeAppendPrintf(sentry, "syscalls.disk.unlinks = %f/sec\n", XAVG(syscalls.disk.unlinks));    storeAppendPrintf(sentry, "syscalls.sock.accepts = %f/sec\n", XAVG(syscalls.sock.accepts));    storeAppendPrintf(sentry, "syscalls.sock.sockets = %f/sec\n", XAVG(syscalls.sock.sockets));    storeAppendPrintf(sentry, "syscalls.sock.connects = %f/sec\n", XAVG(syscalls.sock.connects));    storeAppendPrintf(sentry, "syscalls.sock.binds = %f/sec\n", XAVG(syscalls.sock.binds));    storeAppendPrintf(sentry, "syscalls.sock.closes = %f/sec\n", XAVG(syscalls.sock.closes));    storeAppendPrintf(sentry, "syscalls.sock.reads = %f/sec\n", XAVG(syscalls.sock.reads));    storeAppendPrintf(sentry, "syscalls.sock.writes = %f/sec\n", XAVG(syscalls.sock.writes));    storeAppendPrintf(sentry, "syscalls.sock.recvfroms = %f/sec\n", XAVG(syscalls.sock.recvfroms));    storeAppendPrintf(sentry, "syscalls.sock.sendtos = %f/sec\n", XAVG(syscalls.sock.sendtos));    storeAppendPrintf(sentry, "cpu_time = %f seconds\n", ct);    storeAppendPrintf(sentry, "wall_time = %f seconds\n", dt);    storeAppendPrintf(sentry, "cpu_usage = %f%%\n", dpercent(ct, dt));}voidstatInit(void){    int i;    debug(18, 5) ("statInit: Initializing...\n");    for (i = 0; i < N_COUNT_HIST; i++)	statCountersInit(&CountHist[i]);    for (i = 0; i < N_COUNT_HOUR_HIST; i++)	statCountersInit(&CountHourHist[i]);    statCountersInit(&Counter);    eventAdd("statAvgTick", statAvgTick, NULL, (double) COUNT_INTERVAL, 1);    cachemgrRegister("info",	"General Runtime Information",	info_get, 0, 1);    cachemgrRegister("filedescriptors",	"Process Filedescriptor Allocation",	statFiledescriptors, 0, 1);    cachemgrRegister("objects",	"All Cache Objects",	stat_objects_get, 0, 0);    cachemgrRegister("vm_objects",	"In-Memory and In-Transit Objects",	stat_vmobjects_get, 0, 0);#if DEBUG_OPENFD    cachemgrRegister("openfd_objects",	"Objects with Swapout files open",	statOpenfdObj, 0, 0);#endif    cachemgrRegister("io",	"Server-side network read() size histograms",	stat_io_get, 0, 1);    cachemgrRegister("counters",	"Traffic and Resource Counters",	statCountersDump, 0, 1);    cachemgrRegister("peer_select",	"Peer Selection Algorithms",	statPeerSelect, 0, 1);    cachemgrRegister("digest_stats",	"Cache Digest and ICP blob",	statDigestBlob, 0, 1);    cachemgrRegister("5min",	"5 Minute Average of Counters",	statAvg5min, 0, 1);    cachemgrRegister("60min",	"60 Minute Average of Counters",	statAvg60min, 0, 1);    cachemgrRegister("utilization",	"Cache Utilization",	statUtilization, 0, 1);#if STAT_GRAPHS    cachemgrRegister("graph_variables",	"Display cache metrics graphically",	statGraphDump, 0, 1);#endif    cachemgrRegister("histograms",	"Full Histogram Counts",	statCountersHistograms, 0, 1);    ClientActiveRequests.head = NULL;    ClientActiveRequests.tail = NULL;    cachemgrRegister("active_requests",	"Client-side Active Requests",	statClientRequests, 0, 1);}static voidstatAvgTick(void *notused){    StatCounters *t = &CountHist[0];    StatCounters *p = &CountHist[1];    StatCounters *c = &Counter;    struct rusage rusage;    eventAdd("statAvgTick", statAvgTick, NULL, (double) COUNT_INTERVAL, 1);    squid_getrusage(&rusage);    c->page_faults = rusage_pagefaults(&rusage);    c->cputime = rusage_cputime(&rusage);    c->timestamp = current_time;    /* even if NCountHist is small, we already Init()ed the tail */    statCountersClean(CountHist + N_COUNT_HIST - 1);    xmemmove(p, t, (N_COUNT_HIST - 1) * sizeof(StatCounters));    statCountersCopy(t, c);    NCountHist++;    if ((NCountHist % COUNT_INTERVAL) == 0) {	/* we have an hours worth of readings.  store previous hour */	StatCounters *t = &CountHourHist[0];	StatCounters *p = &CountHourHist[1];	StatCounters *c = &CountHist[N_COUNT_HIST - 1];	statCountersClean(CountHourHist + N_COUNT_HOUR_HIST - 1);	xmemmove(p, t, (N_COUNT_HOUR_HIST - 1) * sizeof(StatCounters));	statCountersCopy(t, c);	NCountHourHist++;    }}static voidstatCountersInit(StatCounters * C){    assert(C);    memset(C, 0, sizeof(*C));    C->timestamp = current_time;    statCountersInitSpecial(C);}/* add special cases here as they arrive */static voidstatCountersInitSpecial(StatCounters * C){    /*     * HTTP svc_time hist is kept in milli-seconds; max of 3 hours.     */    statHistLogInit(&C->client_http.all_svc_time, 300, 0.0, 3600000.0 * 3.0);    statHistLogInit(&C->client_http.miss_svc_time, 300, 0.0, 3600000.0 * 3.0);    statHistLogInit(&C->client_http.nm_svc_time, 300, 0.0, 3600000.0 * 3.0);    statHistLogInit(&C->client_http.nh_svc_time, 300, 0.0, 3600000.0 * 3.0);    statHistLogInit(&C->client_http.hit_svc_time, 300, 0.0, 3600000.0 * 3.0);    /*     * ICP svc_time hist is kept in micro-seconds; max of 1 minute.     */    statHistLogInit(&C->icp.query_svc_time, 300, 0.0, 1000000.0 * 60.0);    statHistLogInit(&C->icp.reply_svc_time, 300, 0.0, 1000000.0 * 60.0);    /*     * DNS svc_time hist is kept in milli-seconds; max of 10 minutes.     */    statHistLogInit(&C->dns.svc_time, 300, 0.0, 60000.0 * 10.0);    /*     * Cache Digest Stuff     */    statHistEnumInit(&C->cd.on_xition_count, CacheDigestHashFuncCount);    statHistEnumInit(&C->comm_icp_incoming, INCOMING_ICP_MAX);    statHistEnumInit(&C->comm_http_incoming, INCOMING_HTTP_MAX);    statHistIntInit(&C->select_fds_hist, SQUID_MAXFD);}/* add special cases here as they arrive */static voidstatCountersClean(StatCounters * C){    assert(C);    statHistClean(&C->client_http.all_svc_time);    statHistClean(&C->client_http.miss_svc_time);    statHistClean(&C->client_http.nm_svc_time);    statHistClean(&C->client_http.nh_svc_time);    statHistClean(&C->client_http.hit_svc_time);    statHistClean(&C->icp.query_svc_time);    statHistClean(&C->icp.reply_svc_time);    statHistClean(&C->dns.svc_time);    statHistClean(&C->cd.on_xition_count);    statHistClean(&C->comm_icp_incoming);    statHistClean(&C->comm_http_incoming);    statHistClean(&C->select_fds_hist);}/* add special cases here as they arrive */static voidstatCountersCopy(StatCounters * dest, const StatCounters * orig){    assert(dest && orig);    /* this should take care of all the fields, but "special" ones */    memcpy(dest, orig, sizeof(*dest));    /* prepare space where to copy special entries */    statCountersInitSpecial(dest);    /* now handle special cases */    /* note: we assert that histogram capacities do not change */    statHistCopy(&dest->client_http.all_svc_time, &orig->client_http.all_svc_time);    statHistCopy(&dest->client_http.miss_svc_time, &orig->client_http.miss_svc_time);    statHistCopy(&dest->client_http.nm_svc_time, &orig->client_http.nm_svc_time);    statHistCopy(&dest->client_http.nh_svc_time, &orig->client_http.nh_svc_time);    statHistCopy(&dest->client_http.hit_svc_time, &orig->client_http.hit_svc_time);    statHistCopy(&dest->icp.query_svc_time, &orig->icp.query_svc_time);    statHistCopy(&dest->icp.reply_svc_time, &orig->icp.reply_svc_time);    statHistCopy(&dest->dns.svc_time, &orig->dns.svc_time);    statHistCopy(&dest->cd.on_xition_count, &orig->cd.on_xition_count);    statHistCopy(&dest->comm_icp_incoming, &orig->comm_icp_incoming);    statHistCopy(&dest->comm_http_incoming, &orig->comm_http_incoming);    statHistCopy(&dest->select_fds_hist, &orig->select_fds_hist);}static voidstatCountersHistograms(StoreEntry * sentry){    StatCounters *f = &Counter;    storeAppendPrintf(sentry, "client_http.all_svc_time histogram:\n");    statHistDump(&f->client_http.all_svc_time, sentry, NULL);    storeAppendPrintf(sentry, "client_http.miss_svc_time histogram:\n");    statHistDump(&f->client_http.miss_svc_time, sentry, NULL);    storeAppendPrintf(sentry, "client_http.nm_svc_time histogram:\n");    statHistDump(&f->client_http.nm_svc_time, sentry, NULL);    storeAppendPrintf(sentry, "client_http.nh_svc_time histogram:\n");    statHistDump(&f->client_http.nh_svc_time, sentry, NULL);    storeAppendPrintf(sentry, "client_http.hit_svc_time histogram:\n");    statHistDump(&f->client_http.hit_svc_time, sentry, NULL);    storeAppendPrintf(sentry, "icp.query_svc_time histogram:\n");    statHistDump(&f->icp.query_svc_time, sentry, NULL);    storeAppendPrintf(sentry, "icp.reply_svc_time histogram:\n");    statHistDump(&f->icp.reply_svc_time, sentry, NULL);    storeAppendPrintf(sentry, "dns.svc_time histogram:\n");    statHistDump(&f->dns.svc_time, sentry, NULL);}static voidstatCountersDump(StoreEntry * sentry){    StatCounters *f = &Counter;    struct rusage rusage;    squid_getrusage(&rusage);    f->page_faults = rusage_pagefaults(&rusage);    f->cputime = rusage_cputime(&rusage);    storeAppendPrintf(sentry, "sample_time = %d.%d (%s)\n",	(int) f->timestamp.tv_sec,	(int) f->timestamp.tv_usec,	mkrfc1123(f->timestamp.tv_sec));    storeAppendPrintf(sentry, "client_http.requests = %d\n",	f->client_http.requests);    storeAppendPrintf(sentry, "client_http.hits = %d\n",	f->client_http.hits);    storeAppendPrintf(sentry, "client_http.errors = %d\n",	f->client_http.errors);    storeAppendPrintf(sentry, "client_http.kbytes_in = %d\n",	(int) f->client_http.kbytes_in.kb);    storeAppendPrintf(sentry, "client_http.kbytes_out = %d\n",	(int) f->client_http.kbytes_out.kb);    storeAppendPrintf(sentry, "client_http.hit_kbytes_out = %d\n",	(int) f->client_http.hit_kbytes_out.kb);    storeAppendPrintf(sentry, "server.all.requests = %d\n",	(int) f->server.all.requests);    storeAppendPrintf(sentry, "server.all.errors = %d\n",	(int) f->server.all.errors);    storeAppendPrintf(sentry, "server.all.kbytes_in = %d\n",	(int) f->server.all.kbytes_in.kb);    storeAppendPrintf(sentry, "server.all.kbytes_out = %d\n",	(int) f->server.all.kbytes_out.kb);    storeAppendPrintf(sentry, "server.http.requests = %d\n",	(int) f->server.http.requests);    storeAppendPrintf(sentry, "server.http.errors = %d\n",	(int) f->server.http.errors);    storeAppendPrintf(sentry, "server.http.kbytes_in = %d\n",	(int) f->server.http.kbytes_in.kb);    storeAppendPrintf(sentry, "server.http.kbytes_out = %d\n",	(int) f->server.http.kbytes_out.kb);    storeAppendPrintf(sentry, "server.ftp.requests = %d\n",	(int) f->server.ftp.requests);    storeAppendPrintf(sentry, "server.ftp.errors = %d\n",	(int) f->server.ftp.errors);    storeAppendPrintf(sentry, "server.ftp.kbytes_in = %d\n",	(int) f->server.ftp.kbytes_in.kb);    storeAppendPrintf(sentry, "server.ftp.kbytes_out = %d\n",	(int) f->server.ftp.kbytes_out.kb);    storeAppendPrintf(sentry, "server.other.requests = %d\n",	(int) f->server.other.requests);    storeAppendPrintf(sentry, "server.other.errors = %d\n",	(int) f->server.other.errors);    storeAppendPrintf(sentry, "server.other.kbytes_in = %d\n",	(int) f->server.other.kbytes_in.kb);    storeAppendPrintf(sentry, "server.other.kbytes_out = %d\n",	(int) f->server.other.kbytes_out.kb);    storeAppendPrintf(sentry, "icp.pkts_sent = %d\n",	f->icp.pkts_sent);    storeAppendPrintf(sentry, "icp.pkts_recv = %d\n",	f->icp.pkts_recv);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -