SSH client can be used to execute a command(s) on a remote UNIX box. Same technique can be used to get current network and system information usinginformation: netstat
ssh you@remotebox-a netstat
ssh you@remoteboxnetstat -tulpn
# vi /etc/inetd.conf
Append following line:
netstat stream tcp nowait root /bin/netstat netstat -a
Restart inetd:
# /etc/init.d/openbsd-inetd restart
Next, use telnet to connect to the
$ telnet server-name netstat
$ telnet 192.168.1.5 15
Output:
Trying 192.168.1.5...
Connected to 192.168.1.5.
Escape character is '^]'.
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address Statetcp 0 0 *:6881 *:* LISTENtcp 0 0 *:6081 *:* LISTENtcp 0 0 *:nfs *:* LISTENtcp 0 0 localhost:6082 *:* LISTENtcp 0 0 *:54053 *:* LISTENtcp 0 0 *:59275 *:* LISTENtcp 0 0 *:netstat *:* LISTENtcp 0 0 *:sunrpc *:* LISTENtcp 0 0 localhost:webcache *:* LISTENtcp 0 0 *:43218 *:* LISTENtcp 0 0 *:domain *:* LISTENtcp 0 0 localhost:ipp *:* LISTENtcp 0 0 *:telnet *:* LISTENtcp 0 0 *:3128 *:* LISTENtcp 0 0 localhost:smtp *:* LISTENtcp 0 1 vivek-desktop.loc:48925 bas4-kitchener06-:56662 SYN_SENTtcp 0 0 vivek-desktop.loc:54791 customer5673.pool:16273 ESTABLISHEDtcp 0 0 vivek-desktop.loc:38398 59.94.1xx.yy:45483 ESTABLISHEDtcp 0 0 vivek-desktop.loc:42048 60.21.zz.yyy:23235 ESTABLISHED
...........
....
....
unix 3 [ ] STREAM CONNECTED 15973
unix 3 [ ] STREAM CONNECTED 15947 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 15946
unix 3 [ ] STREAM CONNECTED 15936 /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 15935
unix 2 [ ] DGRAM 15931
unix 3 [ ] STREAM CONNECTED 15916
unix 3 [ ] STREAM CONNECTED 15915
unix 2 [ ] DGRAM 15906
Connection closed by foreign host.
a] Unnecessary service running at port # 15
ssh user@remote-box netstat -a
ssh user@remote-box df -H
ssh user@remote-box free -m
ssh user@remote-box /path/to/script.pl