How to monitor send/receive bytes

Hello,
I need to create a script to monitor sent/received packets for a period of time (the period of time will be a users input) and write the result to some txt file.
Is there any command (don`t want to use any 3rd party sw) what I can use?
I`m using Solaris 10.

Thank you

Take a look at "snoop" command.

yes that`s what I did, but can you be a more specific please:-]]. What parameters should I use.

Try reading the snoop man page:

man snoop

Come up with suggested parameters and test them out on your system. You will quickly find the correct parameters to use.

snoop is not the right command...need something what shows network traffic.Like in XP Activity...total of sent and received packets..Is there something like that?

Take a look at "netstat" :wink:

I found netsat -s. It gives me some info. There is "tcpOutDataBytes"..is it the amount of sent bytes?And also there is "tcpInDupBytes" I assume it is not the amount of received bytes.

"netstat -i <interval>" would be better if you are asking about packets like stated in your initial question.

yes "netstat - i" gives mi a packets, but I would rather have sent/received bytes..

kstat -n interface | grep s64

should print both the packet and byte statistics for the specified interface.

Hi jlliagre, thank you,but the command doesn`t do anything. When I use the "netstat" command, there is a row like "tcpOutDataBytes" which I assume are bytes sent out, but dont know which row is "data sent in"...

What interface do you use ?
What Solaris 10 release (cat /etc/release) ?
What says

kstat -n interface 

(with interface replaced by your interface name)

The closer would be tcpInAckBytes but TCP statistics include local (internal) communication so is probably not what you are looking for.

As interface I use TCP
I use Solrais 2009.06 snv_111b X86
when I use "jack@opensolaris:/# kstat -n tcp | grep s64" I can hear HDD runnig for a while and then it prints again "jack@opensolaris:/#"

So can you point me to where (what command) I should look?

Thank you very much

"tcp" is hardly a network interface. It should be e1000g0, iwh0 or something similar.
What says

ifconfig -a

?

1 Like

ok you are right "ifconfig -a" says lo0 and e1000g0 plus some other stuff..
Now when I try to run "kstat - n e1000g0 | grep s64" it gives me "obytes64" which I assume are sent bytes and "rbytes64" which I assume are received bytes..and yes there are also ipakets and opakets.