Beispiel #1
0
static void
dump_ifstat(const char *name)
{
	struct uinet_ifstat stat;
	int perline = 3;
	int index = 1;

#define PRINT_IFSTAT(s) printf("%-26s= %-10lu%s", #s, stat.s, (index % perline == 0) ? "\n" : "  "); index++ 

	uinet_getifstat(name, &stat);

	printf("========================================================================\n");
	printf("%s:\n", name);

	PRINT_IFSTAT(ifi_ipackets);
	PRINT_IFSTAT(ifi_ierrors);
	PRINT_IFSTAT(ifi_opackets);
	PRINT_IFSTAT(ifi_oerrors);
	PRINT_IFSTAT(ifi_collisions);
	PRINT_IFSTAT(ifi_ibytes);
	PRINT_IFSTAT(ifi_obytes);
	PRINT_IFSTAT(ifi_imcasts);
	PRINT_IFSTAT(ifi_omcasts);
	PRINT_IFSTAT(ifi_iqdrops);
	PRINT_IFSTAT(ifi_noproto);
	PRINT_IFSTAT(ifi_hwassist);
	PRINT_IFSTAT(ifi_epoch);
	PRINT_IFSTAT(ifi_icopies);
	PRINT_IFSTAT(ifi_izcopies);
	PRINT_IFSTAT(ifi_ocopies);
	PRINT_IFSTAT(ifi_ozcopies);

	printf("\n");
	printf("========================================================================\n");


#undef PRINT_IFSTAT
}
Beispiel #2
0
static void
stats_cb(struct ev_loop *loop, ev_timer *w, int revents)
{
	struct event_loop_config *elcfg = w->data;
	struct stack_config *scfg;
	struct interface_config *ifcfg;
	struct uinet_tcpstat tcpstat;
	struct uinet_ifstat stat;
	unsigned int i, j;
	char tmpbuf[32];
	ev_loop_counters *loop_counters;

	pthread_mutex_lock(&print_lock);
	loop_counters = ev_loop_counters_get(elcfg->loop);
	if (elcfg->first_stats)
		printf("[%s] iterations:%11llu ips: %11s\n", elcfg->name,
		       (unsigned long long)loop_counters->iterations, "--");
	else
		printf("[%s] iterations:%11llu ips: %11.1f\n", elcfg->name,
		       (unsigned long long)loop_counters->iterations,
		       (double)(loop_counters->iterations - elcfg->last_counters.iterations) / elcfg->stats_interval);
	elcfg->last_counters = *loop_counters;
	for (i = 0; i < elcfg->num_stacks; i++) {
		scfg = elcfg->scfgs[i];
		snprintf(tmpbuf, sizeof(tmpbuf), "  [%s]", scfg->name);
		if (scfg->syncache_stats) {
			uinet_gettcpstat(scfg->uinst, &tcpstat);
			printf("%s  syncache stats\n", tmpbuf);
#define PRINT_SYNCACHE_ROW(a,b,c) printf("    %14s=%11lu   %14s=%11lu   %14s=%11lu\n", \
					 #a, tcpstat.tcps_sc_##a,	\
					 #b, tcpstat.tcps_sc_##b,	\
					 #c, tcpstat.tcps_sc_##c)
			PRINT_SYNCACHE_ROW(added, retransmitted, dupsyn);
			PRINT_SYNCACHE_ROW(dropped, completed, bucketoverflow);
			PRINT_SYNCACHE_ROW(cacheoverflow, reset, stale);
			PRINT_SYNCACHE_ROW(aborted, badack, unreach);
			PRINT_SYNCACHE_ROW(zonefail, sendcookie, recvcookie);
#undef PRINT_SYNCACHE_ROW
		}
		printf("%-16s %11s %11s %11s %11s %11s %11s %8s %8s %8s %8s\n", tmpbuf,
		       "in_copy", "in_zcopy", "in_drop", "out_copy", "out_zcopy", "out_drop",
		       "in_Kpps", "in_MBps", "out_Kpps", "out_MBps");
		for (j = 0; j < scfg->num_ifs; j++) {
			ifcfg = scfg->ifcfgs[j];

			uinet_getifstat(ifcfg->uif, &stat);
			snprintf(tmpbuf, sizeof(tmpbuf), "%s (%s)", ifcfg->ucfg.alias, ifcfg->ucfg.configstr);
			printf("%16s %11lu %11lu %11lu %11lu %11lu %11lu",
			       tmpbuf,
			       stat.ifi_icopies, stat.ifi_izcopies, stat.ifi_iqdrops,
			       stat.ifi_ocopies, stat.ifi_ozcopies, stat.ifi_oerrors);
			if (elcfg->first_stats) {
				printf(" %8s %8s %8s %8s\n", "--", "--", "--", "--");
			} else {
				printf(" %8.1f %8.1f %8.1f %8.1f\n",
				       (stat.ifi_ipackets - ifcfg->last_stat.ifi_ipackets) / 1000. / elcfg->stats_interval,
				       (stat.ifi_ibytes - ifcfg->last_stat.ifi_ibytes) / 1000000. / elcfg->stats_interval,
				       (stat.ifi_opackets - ifcfg->last_stat.ifi_opackets) / 1000. / elcfg->stats_interval,
				       (stat.ifi_obytes - ifcfg->last_stat.ifi_obytes) / 1000000. / elcfg->stats_interval);
			}
			ifcfg->last_stat = stat;
		}
	}
	elcfg->first_stats = 0;

	pthread_mutex_unlock(&print_lock);
}