예제 #1
0
static void
stack_stats_cb(struct ev_loop *loop, ev_timer *w, int revents)
{
	struct stack_config *scfg = w->data;
	struct uinet_tcpstat stat;
	int num_open_sockets = 0;
	size_t len;
	ev_tstamp timestamp;

	if (scfg->first_stats) {
		scfg->first_stats_time = ev_now(loop);
		scfg->first_stats = 0;
	}

	uinet_gettcpstat(scfg->uinst, &stat);

	len = sizeof(num_open_sockets);
	uinet_sysctlbyname(scfg->uinst, "kern.ipc.numopensockets", (char *)&num_open_sockets,
			   &len, NULL, 0, NULL, 0);

	timestamp = ev_now(loop) - scfg->first_stats_time;

#define PRINT_TCPSTAT(s)	printf("%.6f %s = %llu\n", timestamp, #s, (unsigned long long)stat.s)

	printf("%.6f num_sockets = %u\n", timestamp, num_open_sockets);
	PRINT_TCPSTAT(tcps_connects);
	PRINT_TCPSTAT(tcps_closed);

#undef PRINT_TCPSTAT
}
예제 #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);
}
예제 #3
0
파일: passive.c 프로젝트: decland/libuinet
static void
dump_tcpstat()
{
	struct uinet_tcpstat stat;
	int perline = 3;
	int index = 1;

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

	uinet_gettcpstat(&stat);

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

	PRINT_TCPSTAT(tcps_connattempt);
	PRINT_TCPSTAT(tcps_accepts);
	PRINT_TCPSTAT(tcps_connects);
	PRINT_TCPSTAT(tcps_drops);
	PRINT_TCPSTAT(tcps_conndrops);
	PRINT_TCPSTAT(tcps_minmssdrops);
	PRINT_TCPSTAT(tcps_closed);
	PRINT_TCPSTAT(tcps_segstimed);
	PRINT_TCPSTAT(tcps_rttupdated);
	PRINT_TCPSTAT(tcps_delack);
	PRINT_TCPSTAT(tcps_timeoutdrop);
	PRINT_TCPSTAT(tcps_rexmttimeo);
	PRINT_TCPSTAT(tcps_persisttimeo);
	PRINT_TCPSTAT(tcps_keeptimeo);
	PRINT_TCPSTAT(tcps_keepprobe);
	PRINT_TCPSTAT(tcps_keepdrops);

	PRINT_TCPSTAT(tcps_sndtotal);
	PRINT_TCPSTAT(tcps_sndpack);
	PRINT_TCPSTAT(tcps_sndbyte);
	PRINT_TCPSTAT(tcps_sndrexmitpack);
	PRINT_TCPSTAT(tcps_sndrexmitbyte);
	PRINT_TCPSTAT(tcps_sndrexmitbad);
	PRINT_TCPSTAT(tcps_sndacks);
	PRINT_TCPSTAT(tcps_sndprobe);
	PRINT_TCPSTAT(tcps_sndurg);
	PRINT_TCPSTAT(tcps_sndwinup);
	PRINT_TCPSTAT(tcps_sndctrl);

	PRINT_TCPSTAT(tcps_rcvtotal);
	PRINT_TCPSTAT(tcps_rcvpack);
	PRINT_TCPSTAT(tcps_rcvbyte);
	PRINT_TCPSTAT(tcps_rcvbadsum);
	PRINT_TCPSTAT(tcps_rcvbadoff);
	PRINT_TCPSTAT(tcps_rcvmemdrop);
	PRINT_TCPSTAT(tcps_rcvshort);
	PRINT_TCPSTAT(tcps_rcvduppack);
	PRINT_TCPSTAT(tcps_rcvdupbyte);
	PRINT_TCPSTAT(tcps_rcvpartduppack);
	PRINT_TCPSTAT(tcps_rcvpartdupbyte);
	PRINT_TCPSTAT(tcps_rcvoopack);
	PRINT_TCPSTAT(tcps_rcvoobyte);
	PRINT_TCPSTAT(tcps_rcvpackafterwin);
	PRINT_TCPSTAT(tcps_rcvbyteafterwin);
	PRINT_TCPSTAT(tcps_rcvafterclose);
	PRINT_TCPSTAT(tcps_rcvwinprobe);
	PRINT_TCPSTAT(tcps_rcvdupack);
	PRINT_TCPSTAT(tcps_rcvacktoomuch);
	PRINT_TCPSTAT(tcps_rcvackpack);
	PRINT_TCPSTAT(tcps_rcvackbyte);
	PRINT_TCPSTAT(tcps_rcvwinupd);
	PRINT_TCPSTAT(tcps_pawsdrop);
	PRINT_TCPSTAT(tcps_predack);
	PRINT_TCPSTAT(tcps_preddat);
	PRINT_TCPSTAT(tcps_pcbcachemiss);
	PRINT_TCPSTAT(tcps_cachedrtt);
	PRINT_TCPSTAT(tcps_cachedrttvar);
	PRINT_TCPSTAT(tcps_cachedssthresh);
	PRINT_TCPSTAT(tcps_usedrtt);
	PRINT_TCPSTAT(tcps_usedrttvar);
	PRINT_TCPSTAT(tcps_usedssthresh);
	PRINT_TCPSTAT(tcps_persistdrop);
	PRINT_TCPSTAT(tcps_badsyn);
	PRINT_TCPSTAT(tcps_mturesent);
	PRINT_TCPSTAT(tcps_listendrop);
	PRINT_TCPSTAT(tcps_badrst);

	PRINT_TCPSTAT(tcps_sc_added);
	PRINT_TCPSTAT(tcps_sc_retransmitted);
	PRINT_TCPSTAT(tcps_sc_dupsyn);
	PRINT_TCPSTAT(tcps_sc_dropped);
	PRINT_TCPSTAT(tcps_sc_completed);
	PRINT_TCPSTAT(tcps_sc_bucketoverflow);
	PRINT_TCPSTAT(tcps_sc_cacheoverflow);
	PRINT_TCPSTAT(tcps_sc_reset);
	PRINT_TCPSTAT(tcps_sc_stale);
	PRINT_TCPSTAT(tcps_sc_aborted);
	PRINT_TCPSTAT(tcps_sc_badack);
	PRINT_TCPSTAT(tcps_sc_unreach);
	PRINT_TCPSTAT(tcps_sc_zonefail);
	PRINT_TCPSTAT(tcps_sc_sendcookie);
	PRINT_TCPSTAT(tcps_sc_recvcookie);

	PRINT_TCPSTAT(tcps_hc_added);
	PRINT_TCPSTAT(tcps_hc_bucketoverflow);

	PRINT_TCPSTAT(tcps_finwait2_drops);

	PRINT_TCPSTAT(tcps_sack_recovery_episode);
	PRINT_TCPSTAT(tcps_sack_rexmits);
	PRINT_TCPSTAT(tcps_sack_rexmit_bytes);
	PRINT_TCPSTAT(tcps_sack_rcv_blocks);
	PRINT_TCPSTAT(tcps_sack_send_blocks);
	PRINT_TCPSTAT(tcps_sack_sboverflow);
	
	PRINT_TCPSTAT(tcps_ecn_ce);
	PRINT_TCPSTAT(tcps_ecn_ect0);
	PRINT_TCPSTAT(tcps_ecn_ect1);
	PRINT_TCPSTAT(tcps_ecn_shs);
	PRINT_TCPSTAT(tcps_ecn_rcwnd);

	PRINT_TCPSTAT(tcps_sig_rcvgoodsig);
	PRINT_TCPSTAT(tcps_sig_rcvbadsig);
	PRINT_TCPSTAT(tcps_sig_err_buildsig);
	PRINT_TCPSTAT(tcps_sig_err_sigopt);
	PRINT_TCPSTAT(tcps_sig_err_nosigopt);

#undef PRINT_TCPSTAT

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