Subject: Re: equivalent of sockstat?
To: Zafer Aydogan <zafer@gmx.info>
From: Brian A. Seklecki <lavalamp@spiritual-machines.org>
List: netbsd-help
Date: 12/23/2004 11:48:47
On Thu, 23 Dec 2004, Zafer Aydogan wrote:
> Hej,
>
> Maybe, someone could compile, test and import it to NetBSD.
http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/sockstat/Attic/sockstat.pl?rev=1.6.2.6&content-type=text/x-cvsweb-markup&hideattic=0&only_with_tag=RELENG_4_9_0_RELEASE
Bah! FreeBSD perl scripts in /usr/bin. Perl in the kernel config too.
The only flag missing from fbsd netstat(1) in nbsd is "-W"
-W In certain displays, avoid truncating addresses even if this
causes
some fields to overflow.
...but if you remove the flag from the script, it works just fine:
- exec("/usr/bin/netstat", "-AanW");
+ exec("/usr/bin/netstat", "-Aan");
die("exec(netstat): $!\n");
We should get a pkgsrc-wip entry going and send-pr(1) regarding possibly
using the src/binary version from 5.x
$ perl sockstat.pl
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
lavalamp ssh 20169 4 tcp 216.170.102.137:58316
216.151.95.156:22
lavalamp sshd 19608 6 tcp 192.168.1.1:22
68.164.16.122:1143
lavalamp sshd 19608 9 tcp 127.0.0.1:6010 *:*
root sshd 5370 6 tcp 192.168.1.1:22
68.164.16.122:1143
root dhcpd 27174 4 ? ? ?
root dhcpd 27174 6 udp *:67 *:*
nobody squid 18281 4 udp *:51219 *:*
nobody squid 18281 10 tcp 192.168.1.1:3128 *:*
nobody squid 18281 11 udp *:3130 *:*
nobody squid 18281 12 udp *:3401 *:*
www httpd 5427 3 tcp 192.168.1.1:80 *:*
www httpd 360 3 tcp 192.168.1.1:80 *:*
www httpd 738 3 tcp 192.168.1.1:80 *:*
www httpd 446 3 tcp 192.168.1.1:80 *:*
root inetd 754 5 tcp *:2401 *:*
root master 723 11 tcp *:25 *:*
root sshd 433 5 tcp *:22 *:*
www httpd 591 3 tcp 192.168.1.1:80 *:*
www httpd 464 3 tcp 192.168.1.1:80 *:*
www httpd 171 3 tcp 192.168.1.1:80 *:*
www httpd 167 3 tcp 192.168.1.1:80 *:*
www httpd 169 3 tcp 192.168.1.1:80 *:*
root cupsd 597 0 tcp 127.0.0.1:631 *:*
root cupsd 597 2 tcp 192.168.1.1:631 *:*
root cupsd 597 3 udp *:631 *:*
root httpd 313 3 tcp 192.168.1.1:80 *:*
root snmpd 101 10 tcp *:199 *:*
root snmpd 101 13 udp *:161 *:*
root snmpd 101 15 udp *:65509 *:*
root snmpd 101 16 udp *:65511 *:*
root snmpd 101 17 udp *:65510 *:*
root snmptrap 96 11 udp *:162 *:*
named named 507 20 udp 192.168.1.1:53 *:*
named named 507 21 tcp 192.168.1.1:53 *:*
named named 507 22 udp 216.170.102.137:53 *:*
named named 507 23 tcp 216.170.102.137:53 *:*
named named 507 24 udp 127.0.0.1:53 *:*
named named 507 25 tcp 127.0.0.1:53 *:*
named named 507 26 udp6 *:65524 *:*
named named 507 28 tcp 192.168.1.1:953 *:*
named named 507 29 tcp 127.0.0.1:953 *:*
root nfsd 344 3 tcp *:2049 *:*
root mountd 343 3 udp6 *:1019 *:*
root mountd 343 4 tcp *:1022 *:*
root rpcbind 158 8 udp *:111 *:*
root rpcbind 158 9 udp6 *:* *:*
root rpcbind 158 10 tcp *:111 *:*
USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS
lavalamp sshd 19608 8 tcp6 ::1:6010 *:*
root sshd 433 4 tcp6 *:22 *:*
named named 507 27 ? ? ?
root nfsd 344 4 tcp6 *:2049 *:*
root mountd 343 5 ? ? ?
root mountd 343 6 tcp6 *:1021 *:*
root rpcbind 158 3 ? ? ?
root rpcbind 158 5 udp6 *:1022 *:*
root rpcbind 158 6 ? ? ?
root rpcbind 158 7 tcp6 *:111 *:*
USER COMMAND PID FD PROTO ADDRESS
>
> Greetings, Zafer.