Pradeep Padala wrote:
>>> Thanks for the clarifications Venu. I was measuring bandwidth by 
>>> checking 'kstat -n' and as you mentioned, it's probably not 
>>>       
>> accurate.
>>     
>>> Using 'netstat -k', I see that the bandwidth is capped correctly.
>>>       
>> OK, while the stats may not be accurate, but the output from 
>> netstat should not be very different from that calculated 
>> using kstat. netstat gets the kstat values for vnic1, gets 
>> the increment over the last time you read (via netstat) and 
>> gives the average input/output for that time duration.
>> Perhaps you are not computing the values from kstat -n correctly?
>> I believe netstat uses the following logic:
>>
>> e.g for input:
>>      input kbps = diff in (rbytes64 in kb) since prev read / 
>> time since
>>                   last read;
>>
>> similarly for output.
>>     
>
> That's exactly how I am measuring it. My python code looks like this
>
> timestamp = time.time()
> output = commands.getoutput('kstat -n vnic%d | grep bytes' %
> get_coid(coname)).split('\n')
> obytes = float(re.split('\s+', output[0])[2])
> rbytes = float(re.split('\s+', output[1])[2])
> return rbytes + obytes
>
> One question. The output of 'kstat -n vnic?' looks like this (I just
> rebooted, so most numbers are zero)
>
> module: unix                            instance: 0     
> name:   vnic1                           class:    flow
>         crtime                          109.436840067
>         ierrors                         0
>         ipackets                        268
>         obytes                          0
>         oerrors                         0
>         opackets                        0
>         rbytes                          24488
>         snaptime                        520.551380521
>
> module: vnic                            instance: 1     
> name:   vnic1                           class:    net
>         brdcstrcv                       1977
>         brdcstxmt                       0
>         collisions                      0
>         crtime                          484.32586088
>         ierrors                         2361
>         ifspeed                         200000000
>         ipackets                        268
>         ipackets64                      268
>         multircv                        0
>         multixmt                        0
>         norcvbuf                        0
>         noxmtbuf                        0
>         obytes                          0
>         obytes64                        0
>         oerrors                         0
>         opackets                        0
>         opackets64                      0
>         rbytes                          24488
>         rbytes64                        24488
>         snaptime                        520.552493729
>         unknowns                        0
>
> As you can see, there are a set of stats for 'flow' and for 'net'. Which
> ones should I be using? So far, I am taking the first set of stats.
>   
I'd use the second set of stats but at least these 2 look the same.

Everything that is displayed in netstat -k is derived from kstats.
If you want to avoid the curses stuff, you could try a form of
dladm show-vnic with -s (for stats) and -i (for interval).

-Mike

Reply via email to