summaryrefslogtreecommitdiffstats
path: root/usr.bin/sockstat
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>1999-07-06 19:12:31 +0000
committerdes <des@FreeBSD.org>1999-07-06 19:12:31 +0000
commit71fd17e057eaec0ab952eb46cd1d1dcd78b8183a (patch)
treec33fbcf553a44415d92aeb164f3dc3d65e3f77ac /usr.bin/sockstat
parentf234b406a45a445cc33488b6a9260e82cb4d01b8 (diff)
downloadFreeBSD-src-71fd17e057eaec0ab952eb46cd1d1dcd78b8183a.zip
FreeBSD-src-71fd17e057eaec0ab952eb46cd1d1dcd78b8183a.tar.gz
Use -finet option to netstat(1), and don't discard anything.
Don't truncate the protocol field. These two changes conspire to make sockstat(1) show divert sockets. Submitted by: ru
Diffstat (limited to 'usr.bin/sockstat')
-rw-r--r--usr.bin/sockstat/sockstat.110
-rw-r--r--usr.bin/sockstat/sockstat.pl11
2 files changed, 10 insertions, 11 deletions
diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1
index f2540ae..d009bf9 100644
--- a/usr.bin/sockstat/sockstat.1
+++ b/usr.bin/sockstat/sockstat.1
@@ -25,7 +25,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id: lsock.1,v 1.1 1999/04/14 16:17:34 des Exp $
+.\" $Id: sockstat.1,v 1.1 1999/04/15 13:40:43 des Exp $
.\"
.Dd April 13, 1999
.Dt LSOCK 1
@@ -39,7 +39,7 @@ The
.Nm
command lists open Internet sockets. The information listed for each
socket is:
-.Bl -tag -width FOREIGN_ADDRESS
+.Bl -tag -width "FOREIGN ADDRESS"
.It Li USER
The user who owns the socket.
.It Li COMMAND
@@ -49,7 +49,7 @@ The process ID of the command which holds the socket.
.It Li FD
The file descriptor number of the socket.
.It Li PROTO
-The transport protocol (udp or tcp) associated with the socket.
+The transport protocol associated with the socket.
.It Li LOCAL ADDRESS
The address the local end of the socket is bound to (see
.Xr getsockname 2 ).
@@ -59,8 +59,8 @@ The address the foreign end of the socket is bound to (see
.El
.Sh SEE ALSO
.Xr fstat 1 ,
-.Xr inet 4 ,
-.Xr netstat 1 .
+.Xr netstat 1 ,
+.Xr inet 4 .
.Sh HISTORY
The
.Nm
diff --git a/usr.bin/sockstat/sockstat.pl b/usr.bin/sockstat/sockstat.pl
index 34c69be..9d9261c 100644
--- a/usr.bin/sockstat/sockstat.pl
+++ b/usr.bin/sockstat/sockstat.pl
@@ -26,25 +26,24 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
-# $Id: sockstat.pl,v 1.1 1999/04/15 13:40:43 des Exp $
+# $Id: sockstat.pl,v 1.2 1999/05/01 11:31:19 des Exp $
#
my (%myaddr, %hisaddr);
my ($user, $cmd, $pid, $fd, $inet, $type, $proto, $sock, $laddr, $faddr);
print <<EOH;
-USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
+USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
EOH
format STDOUT =
-@<<<<<<< @<<<<<<<<< @>>>> @>>> @<< @<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<
-$user, $cmd, $pid, $fd, $proto,$laddr, $faddr
+@<<<<<<< @<<<<<<< @>>>> @>>> @<<<<< @<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<
+$user, $cmd, $pid, $fd, $proto,$laddr, $faddr
.
-open NETSTAT, "netstat -Aan |" or die "'netstat -Aan' failed: $!";
+open NETSTAT, "netstat -Aan -finet | tail +3 |" or die "'netstat' failed: $!";
while (<NETSTAT>) {
my ($sock, $proto, $recvq, $sendq, $laddr, $faddr, $state) = split;
- next unless ($proto =~ m/tcp|udp/);
($myaddr{$sock}, $hisaddr{$sock}) = ($laddr, $faddr);
}
OpenPOWER on IntegriCloud