Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
11547 Want connstat(1M) command to display per-connection TCP statistics
Portions contributed by: Cody Peter Mello <cody.mello@joyent.com> Portions contributed by: Ahmed G <ahmedg@delphix.com> Reviewed by: Jason King <jason.king@joyent.com> Reviewed by: Robert Mustacchi <rm@joyent.com> Reviewed by: Dan McDonald <danmcd@joyent.com> Approved by: Richard Lowe <richlowe@richlowe.net>
- Loading branch information
Showing
24 changed files
with
2,022 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# | ||
# CDDL HEADER START | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
# CDDL HEADER END | ||
# | ||
# | ||
# Copyright (c) 2015 by Delphix. All rights reserved. | ||
# | ||
|
||
PROG= connstat | ||
OBJS= connstat_main.o connstat_mib.o connstat_tcp.o | ||
SRCS= $(OBJS:%.o=%.c) | ||
POFILES= connstat_main.po connstat_tcp.po connstat_mib.po | ||
POFILE= connstat.po | ||
|
||
include ../Makefile.cmd | ||
include ../Makefile.ctf | ||
|
||
CSTD= $(CSTD_GNU99) | ||
LDLIBS += -lsocket -lnsl -lumem -lofmt | ||
XGETFLAGS += -a -x $(PROG).xcl | ||
|
||
.KEEP_STATE: | ||
|
||
all: $(PROG) | ||
|
||
$(PROG): $(OBJS) | ||
$(LINK.c) -o $@ $(OBJS) $(LDLIBS) | ||
$(POST_PROCESS) | ||
|
||
$(POFILE): $(POFILES) | ||
$(RM) $@ | ||
cat $(POFILES) > $@ | ||
|
||
install: all $(ROOTPROG) | ||
|
||
clean: | ||
$(RM) $(OBJS) | ||
|
||
lint: lint_SRCS | ||
|
||
include ../Makefile.targ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
* CDDL HEADER START | ||
* | ||
* This file and its contents are supplied under the terms of the | ||
* Common Development and Distribution License ("CDDL"), version 1.0. | ||
* You may only use this file in accordance with the terms of version | ||
* 1.0 of the CDDL. | ||
* | ||
* A full copy of the text of the CDDL should have accompanied this | ||
* source. A copy of the CDDL is also available via the Internet at | ||
* http://www.illumos.org/license/CDDL. | ||
* | ||
* CDDL HEADER END | ||
*/ | ||
/* | ||
* Copyright (c) 2015, 2016 by Delphix. All rights reserved. | ||
*/ | ||
|
||
#ifndef _CONNSTAT_H | ||
#define _CONNSTAT_H | ||
|
||
#include <sys/types.h> | ||
#include <sys/socket.h> | ||
#include <ofmt.h> | ||
#include <sys/stropts.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
typedef struct connstat_conn_attr_s { | ||
struct sockaddr_storage ca_laddr; | ||
struct sockaddr_storage ca_raddr; | ||
int ca_lport; | ||
int ca_rport; | ||
int ca_state; | ||
} connstat_conn_attr_t; | ||
|
||
typedef struct conn_walk_state_s { | ||
ofmt_handle_t cws_ofmt; | ||
uint_t cws_flags; | ||
connstat_conn_attr_t cws_filter; | ||
} conn_walk_state_t; | ||
|
||
/* cws_flags */ | ||
#define CS_LOOPBACK 0x0001 /* Include loopback connections */ | ||
#define CS_IPV4 0x0002 /* Show only IPv4 connections */ | ||
#define CS_IPV6 0x0004 /* Show only IPv6 connections */ | ||
#define CS_LADDR 0x0008 /* Filter by laddr in cws_filter */ | ||
#define CS_RADDR 0x0010 /* Filter by raddr in cws_filter */ | ||
#define CS_LPORT 0x0020 /* Filter by lport in cws_filter */ | ||
#define CS_RPORT 0x0040 /* Filter by rport in cws_filter */ | ||
#define CS_STATE 0x0080 /* Filter by state in cws_filter */ | ||
#define CS_PARSABLE 0x0100 /* Parsable output */ | ||
|
||
typedef ofmt_field_t *connstat_getfieldsfunc_t(void); | ||
typedef void connstat_walkfunc_t(struct strbuf *, conn_walk_state_t *); | ||
|
||
typedef struct connstat_proto_s { | ||
char *csp_proto; | ||
char *csp_default_fields; | ||
int csp_miblevel; | ||
int csp_mibv4name; | ||
int csp_mibv6name; | ||
connstat_getfieldsfunc_t *csp_getfields; | ||
connstat_walkfunc_t *csp_v4walk; | ||
connstat_walkfunc_t *csp_v6walk; | ||
} connstat_proto_t; | ||
|
||
boolean_t print_string(ofmt_arg_t *, char *, uint_t); | ||
boolean_t print_uint16(ofmt_arg_t *, char *, uint_t); | ||
boolean_t print_uint32(ofmt_arg_t *, char *, uint_t); | ||
boolean_t print_uint64(ofmt_arg_t *, char *, uint_t); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* _CONNSTAT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# | ||
# CDDL HEADER START | ||
# | ||
# This file and its contents are supplied under the terms of the | ||
# Common Development and Distribution License ("CDDL"), version 1.0. | ||
# You may only use this file in accordance with the terms of version | ||
# 1.0 of the CDDL. | ||
# | ||
# A full copy of the text of the CDDL should have accompanied this | ||
# source. A copy of the CDDL is also available via the Internet at | ||
# http://www.illumos.org/license/CDDL. | ||
# | ||
# CDDL HEADER END | ||
# | ||
# | ||
# Copyright (c) 2015 by Delphix. All rights reserved. | ||
# | ||
|
||
msgid "count" | ||
msgid "established" | ||
msgid "filter" | ||
msgid "help" | ||
msgid "interval" | ||
msgid "ipv4" | ||
msgid "ipv6" | ||
msgid "no-loopback" | ||
msgid "output" | ||
msgid "parsable" | ||
msgid "protocol" | ||
msgid "timestamp" | ||
msgid "tcp" | ||
msgid "laddr,lport,raddr,rport,inbytes,outbytes," | ||
"retransbytes,suna,swnd,cwnd,rwnd" | ||
msgid " %s\n" | ||
msgid "" | ||
msgid "c:eF:hi:Lo:Pp:T:46" | ||
msgid "all" | ||
msgid "laddr" | ||
msgid "raddr" | ||
msgid "lport" | ||
msgid "rport" | ||
msgid "= " | ||
msgid "%s%ld\n" | ||
msgid "%s%s\n" | ||
msgid "%hu" | ||
msgid "%u" | ||
msgid "%llu" | ||
msgid "%s: " | ||
msgid "LADDR" | ||
msgid "RADDR" | ||
msgid "LPORT" | ||
msgid "RPORT" | ||
msgid "INBYTES" | ||
msgid "INSEGS" | ||
msgid "INUNORDERBYTES" | ||
msgid "INUNORDERSEGS" | ||
msgid "OUTBYTES" | ||
msgid "OUTSEGS" | ||
msgid "RETRANSBYTES" | ||
msgid "RETRANSSEGS" | ||
msgid "SUNA" | ||
msgid "count" | ||
msgid "SWND" | ||
msgid "CWND" | ||
msgid "RWND" | ||
msgid "STATE" | ||
msgid "CLOSED" | ||
msgid "IDLE" | ||
msgid "BOUND" | ||
msgid "LISTEN" | ||
msgid "SYN_SENT" | ||
msgid "SYN_RCVD" | ||
msgid "ESTABLISHED" | ||
msgid "CLOSE_WAIT" | ||
msgid "FIN_WAIT_1" | ||
msgid "CLOSING" | ||
msgid "LAST_ACK" | ||
msgid "FIN_WAIT_2" | ||
msgid "TIME_WAIT" | ||
msgid "UNKNOWN(%d)" | ||
msgid "/dev/arp" | ||
msgid "putmsg" | ||
msgid "getmsg" | ||
msgid "malloc" |
Oops, something went wrong.