Esempio n. 1
0
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();
}
Esempio n. 2
0
bool mld_interface::output_info(base_stream &ctx, const std::vector<std::string> &) const {
	ctx.xprintf("MLD, version %i", (int)mif_mld_version);

	if (owner()->linklocals().empty()) {
		ctx.writeline(", not running");
		return true;
	}

	ctx.newl();

	ctx.inc_level();

	if (!mif_isquerier) {
		if (mif_querier_addr.is_any()) {
			ctx.writeline("Querier: None");
		} else {
			ctx.xprintf("Querier: %{Addr} for %{duration}\n",
				    mif_querier_addr,
				    mif_other_querier_present_timer_id.time_left_d());
		}
	} else {
		ctx.writeline("Querier: self");
	}

	ctx.dec_level();

	return true;
}
Esempio n. 3
0
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();
	}
}
Esempio n. 4
0
void base_ptree::dump_internal_tree(base_stream &os, const ptree_node *node,
				    const char *desc) const {
	if (!node)
		return;
	os.xprintf("%s ", desc);
	if (node->_t_color == ptree_node::BLACK)
		write_prefix(os, node);
	else
		os.write("white");
	os.xprintf(" at %i", (int)node->_t_bit);
	os.newl();

	os.inc_level();

	dump_internal_tree(os, node->_t_left, "left");
	dump_internal_tree(os, node->_t_right, "right");

	os.dec_level();
}
Esempio n. 5
0
bool node::call_method(int id, base_stream &out,
		       const std::vector<std::string> &args) {
	switch (id) {
	case node_method_enable:
	case node_method_disable:
		return enable_several(args, id == node_method_enable);
	case node_method_no:
		return exec_negate(out, args);
	case node_method_show_properties:
		{
			std::string fname = m_parent ? full_name() : std::string();
			for (properties::const_iterator i = m_properties.begin();
					i != m_properties.end(); ++i) {
				if (!fname.empty())
					out.write(fname.c_str()).write(".");
				out.write(i->first.c_str()).write(" = ");
				if (i->second.is_property()) {
					i->second.output_value(out);
					if (i->second.is_readonly())
						out.write(" [readonly]");
				} else if (i->second.is_child()) {
					out.xprintf("<node %s>", i->second.get_node()->name());
				} else if (i->second.is_method()) {
					if (i->second.is_readonly())
						out.write("<info-method ");
					else
						out.write("<method ");
					out.xprintf("%s>", i->second.get_method_info()->name);
				}

				out.newl();
			}

			return true;
		}
	}

	return false;
}
Esempio n. 6
0
void mld_group_interface::output_info(base_stream &ctx, bool detailed) const {
	ctx.xprintf("Group-Interface %s [MLD]\n", intf()->name());

	ctx.inc_level();

	int maxsources = 3;
	const address_set &srcs = active_set();

	if (detailed) {
		maxsources = srcs.size();
	}

	ctx.xprintf("Filter: %s ", filter_mode() == include ? "Include" : "Exclude");

	if (srcs.empty()) {
		ctx.write("{}");
	} else {
		ctx.write("{");

		address_set::const_iterator i = srcs.begin();
		ctx.xprintf("%{addr}", *i);
		++i;

		for (int k = 1; k < maxsources && i != srcs.end(); ++i) {
			ctx.xprintf(", %{addr}", *i);
			k++;
		}

		if (i != srcs.end())
			ctx.write(", ...");

		ctx.write(" }");
	}

	if (g_filter_timer.is_running()) {
		ctx.xprintf(" (Reset in %{duration})", g_filter_timer.time_left_d());
	}

	ctx.newl();

	if (detailed) {
		if (!g_sources_timers.empty()) {
			ctx.writeline("Sources:");

			ctx.inc_level();

			std::vector<source_timer>::const_iterator i;

			for (i = g_sources_timers.begin();
					i != g_sources_timers.end(); ++i) {
				ctx.xprintf("%{addr} for %{duration}",
					    i->argument(), i->time_left_d());
			}

			ctx.dec_level();
		}
	}

	output_inner_info(ctx, detailed);

	ctx.dec_level();
}