void us_mfa_group::output_info(base_stream &out, bool counters, bool noempty) const { if (counters) { out.writeline("Aggregate activity statistics:"); out.inc_level(); if (stat_packet_count60s) { const char *format = "%.2f %s"; double rate = 8 * stat_octet_count60s / 60000.; const char *unit = "Kb/s"; if (rate > 1000) { rate /= 1000.; unit = "Mb/s"; } out.write("Current rate: "); out.printf(format, rate, unit); out.printf(" (%.2f pkt/s)", stat_packet_count60s / 60.f); out.newl(); out.printf("Last 60 secs: %llu bytes (%llu packets, %.2lf bytes/packet)", stat_octet_count60s, stat_packet_count60s, stat_octet_count60s / (double)stat_packet_count60s); out.newl(); } else { out.writeline("No available statistics"); } out.dec_level(); } /* no active sources */ if (counters && noempty && !stat_packet_count60s) return; out.writeline("Sources:"); out.inc_level(); if (m_sources.empty()) { out.writeline("(None)"); } else { for (sources::const_iterator i = m_sources.begin(); i != m_sources.end(); ++i) { i->second->output_info(out, counters, noempty); } } out.dec_level(); }
void us_mfa_group_source::output_info(base_stream &out, bool counters, bool noempty) const { if (counters) { if (noempty && !stat_packet_count60s) return; out.xprintf("%{addr}", m_addr); out.inc_level(); if (stat_packet_count60s) { out.write(" Activity statistics: "); const char *format = "%.2f %s"; double rate = 8 * stat_octet_count60s / 60000.; const char *unit = "Kb/s"; if (rate > 1000) { rate /= 1000.; unit = "Mb/s"; } out.printf(format, rate, unit); out.printf(" (%.2f pkt/s)", stat_packet_count60s / 60.f); out.newl(); out.printf("Last 60 secs: %llu bytes (%llu packets, %.2lf bytes/packet)", stat_octet_count60s, stat_packet_count60s, stat_octet_count60s / (double)stat_packet_count60s); out.newl(); } else { out.writeline(" No activity in the last 60 seconds"); } out.dec_level(); } else { out.xprintf("%{addr} from %s to ", m_addr, m_iif ? m_iif->name() : "(None)"); output(out, m_oifs); out.newl(); } }
bool timermgr::output_info(base_stream &ctx, bool extended) const { size_t namelen = 20; for (tq_def::const_iterator i = tq.begin(); namelen < 50 && i != tq.end(); ++i) { timer_base *h = *i; if (h->name.size() > namelen) namelen = h->name.size(); } if (namelen > 50) namelen = 50; char fmt[64]; snprintf(fmt, sizeof(fmt), "| %%%is | %%12s | %%10s | %%8s |", (int)namelen); _draw_sep(ctx, namelen); ctx.printf(fmt, "timer name", "time left", "interval", "repeat").newl(); _draw_sep(ctx, namelen); char buf1[64], buf2[64]; for (tq_def::const_iterator i = tq.begin(); i != tq.end(); ++i) { timer_base *h = *i; _prettyprint(buf1, sizeof(buf1), h->time_left()); _prettyprint(buf2, sizeof(buf2), h->_interval); ctx.printf(fmt, h->name.c_str(), buf1, buf2, h->_repeat ? "true" : "false").newl(); } _draw_sep(ctx, namelen); return true; }