mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-30 21:54:50 +00:00
Update sockstat to support INET6 socket printing.
Approved by: jkh Submitted by: Ben Smithurst <ben@scientia.demon.co.uk> Reviewed by: des
This commit is contained in:
parent
4d3289a849
commit
482ca4274b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=57494
|
@ -60,7 +60,8 @@ The address the foreign end of the socket is bound to (see
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr fstat 1 ,
|
.Xr fstat 1 ,
|
||||||
.Xr netstat 1 ,
|
.Xr netstat 1 ,
|
||||||
.Xr inet 4 .
|
.Xr inet 4 ,
|
||||||
|
.Xr inet6 4 .
|
||||||
.Sh HISTORY
|
.Sh HISTORY
|
||||||
The
|
The
|
||||||
.Nm
|
.Nm
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
# $FreeBSD$
|
# $FreeBSD$
|
||||||
#
|
#
|
||||||
|
|
||||||
my (%myaddr, %hisaddr);
|
my (%proto, %myaddr, %hisaddr);
|
||||||
my ($user, $cmd, $pid, $fd, $inet, $type, $proto, $sock, $laddr, $faddr);
|
my ($user, $cmd, $pid, $fd, $inet, $type, $proto, $sock, $laddr, $faddr);
|
||||||
|
|
||||||
print <<EOH;
|
print <<EOH;
|
||||||
|
@ -40,11 +40,13 @@ format STDOUT =
|
||||||
$user, $cmd, $pid, $fd, $proto,$laddr, $faddr
|
$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>) {
|
while (<NETSTAT>) {
|
||||||
my ($sock, $proto, $recvq, $sendq, $laddr, $faddr, $state) = split;
|
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;
|
close NETSTAT;
|
||||||
|
@ -54,8 +56,9 @@ open FSTAT, "fstat |" or die "'fstat' failed: $!\n";
|
||||||
while (<FSTAT>) {
|
while (<FSTAT>) {
|
||||||
($user, $cmd, $pid, $fd, $inet, $type, $proto, $sock) = split;
|
($user, $cmd, $pid, $fd, $inet, $type, $proto, $sock) = split;
|
||||||
chop $fd;
|
chop $fd;
|
||||||
next unless ($inet eq "internet");
|
next unless ($inet =~ m/^internet6?$/);
|
||||||
($laddr, $faddr) = ($myaddr{$sock}, $hisaddr{$sock});
|
($proto, $laddr, $faddr) =
|
||||||
|
($proto{$sock}, $myaddr{$sock}, $hisaddr{$sock});
|
||||||
write STDOUT;
|
write STDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue