diff options
author | shin <shin@FreeBSD.org> | 2000-02-26 02:56:16 +0000 |
---|---|---|
committer | shin <shin@FreeBSD.org> | 2000-02-26 02:56:16 +0000 |
commit | a310d24367456f83ba8ce55cd9334e7570203115 (patch) | |
tree | 0c6e6183062b878c53211f9fdc91ad2144e81811 /usr.bin/sockstat/sockstat.pl | |
parent | 18bcb8d29743e6421787c5d1ef0a057f19ced626 (diff) | |
download | FreeBSD-src-a310d24367456f83ba8ce55cd9334e7570203115.zip FreeBSD-src-a310d24367456f83ba8ce55cd9334e7570203115.tar.gz |
Update sockstat to support INET6 socket printing.
Approved by: jkh
Submitted by: Ben Smithurst <ben@scientia.demon.co.uk>
Reviewed by: des
Diffstat (limited to 'usr.bin/sockstat/sockstat.pl')
-rw-r--r-- | usr.bin/sockstat/sockstat.pl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/sockstat/sockstat.pl b/usr.bin/sockstat/sockstat.pl index 3c25188..c20f542 100644 --- a/usr.bin/sockstat/sockstat.pl +++ b/usr.bin/sockstat/sockstat.pl @@ -29,7 +29,7 @@ # $FreeBSD$ # -my (%myaddr, %hisaddr); +my (%proto, %myaddr, %hisaddr); my ($user, $cmd, $pid, $fd, $inet, $type, $proto, $sock, $laddr, $faddr); print <<EOH; @@ -40,11 +40,13 @@ format STDOUT = $user, $cmd, $pid, $fd, $proto,$laddr, $faddr . -open NETSTAT, "netstat -Aan -finet | tail +3 |" or die "'netstat' failed: $!"; +open NETSTAT, "netstat -Aan |" or die "'netstat' failed: $!"; +<NETSTAT>; <NETSTAT>; while (<NETSTAT>) { my ($sock, $proto, $recvq, $sendq, $laddr, $faddr, $state) = split; - ($myaddr{$sock}, $hisaddr{$sock}) = ($laddr, $faddr); + ($proto{$sock}, $myaddr{$sock}, $hisaddr{$sock}) = + ($proto, $laddr, $faddr); } close NETSTAT; @@ -54,8 +56,9 @@ open FSTAT, "fstat |" or die "'fstat' failed: $!\n"; while (<FSTAT>) { ($user, $cmd, $pid, $fd, $inet, $type, $proto, $sock) = split; chop $fd; - next unless ($inet eq "internet"); - ($laddr, $faddr) = ($myaddr{$sock}, $hisaddr{$sock}); + next unless ($inet =~ m/^internet6?$/); + ($proto, $laddr, $faddr) = + ($proto{$sock}, $myaddr{$sock}, $hisaddr{$sock}); write STDOUT; } |