DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 22nd October 2008
gregf gregf is offline
New User
 
Join Date: May 2008
Posts: 4
Default [SOLVED]RX bytes

Have a small ruby script I wrote that gathers bandwidth from ifconfig eth0 on linux. I get the info from this line.

RX bytes:6742305874 (6.2 GiB) TX bytes:269880060 (257.3 MiB)

As far as I can tell my OpenBSD box does not provide this information in ifconfig. Is there another way to get the same type of info?

Thanks.

Last edited by gregf; 22nd October 2008 at 12:45 AM.
Reply With Quote
  #2   (View Single Post)  
Old 22nd October 2008
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default

Code:
$ netstat -inb     
Name    Mtu   Network     Address               Ibytes     Obytes
lo0     33168 <Link>                             14035      14035
lo0     33168 127/8       127.0.0.1              14035      14035
lo0     33168 ::1/128     ::1                    14035      14035
lo0     33168 fe80::%lo0/ fe80::1%lo0            14035      14035
bge0    1500  <Link>      00:10:18:00:9f:fd  287795130   11082790
bge0    1500  192.168.222 192.168.222.20     287795130   11082790
bge0    1500  fe80::%bge0 fe80::210:18ff:fe  287795130   11082790
re0*    1500  <Link>      00:19:db:47:b0:4c          0          0
enc0*   1536  <Link>                                 0          0
Or
Code:
$ netstat -in  
Name    Mtu   Network     Address              Ipkts Ierrs    Opkts Oerrs Colls
lo0     33168 <Link>                              75     0       75     0     0
lo0     33168 127/8       127.0.0.1               75     0       75     0     0
lo0     33168 ::1/128     ::1                     75     0       75     0     0
lo0     33168 fe80::%lo0/ fe80::1%lo0             75     0       75     0     0
bge0    1500  <Link>      00:10:18:00:9f:fd   192905    42   129995     0     0
bge0    1500  192.168.222 192.168.222.20      192905    42   129995     0     0
bge0    1500  fe80::%bge0 fe80::210:18ff:fe   192905    42   129995     0     0
re0*    1500  <Link>      00:19:db:47:b0:4c        0     0        0     0     0
enc0*   1536  <Link>                               0     0        0     0     0
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
  #3   (View Single Post)  
Old 22nd October 2008
gregf gregf is offline
New User
 
Join Date: May 2008
Posts: 4
Default

That was quick. Thanks. Had looked at netstat but, I guess I ran it with the wrong options.
Reply With Quote
  #4   (View Single Post)  
Old 22nd October 2008
bsddaemon bsddaemon is offline
Slack Daemon
 
Join Date: Oct 2008
Posts: 35
Default

A couple of months ago, I was writting a shell script to monitor internet usage. The script was based on netstat. The script was totally useless, because the statistic (in/out) is randomly resetted.

For example, this is statistic of a server which has been up for a couple of months:

Code:
netstat -I bfe0 -nh                                                           
Name    Mtu Network       Address              Ipkts Ierrs    Opkts Oerrs  Coll
bfe0   1500 <Link#1>      00:15:c5:23:89:72     299M     1     277M     0     1
bfe0   1500 10.1.1.0/24   10.1.1.2              299M     -     277M     -     -
Only 300M? Should be 300G actually. I was thinking maybe the stat resetted because of the interface was down, then up, but no, I havent brought I down for months.

Any idea?
__________________
...then the God created man...
Reply With Quote
  #5   (View Single Post)  
Old 22nd October 2008
gregf gregf is offline
New User
 
Join Date: May 2008
Posts: 4
Default

Wow, had no idea it was randomly reset. I knew it was reset upon reboot but not randomly. Any idea how long of a period before this "random" reset is? I would say it's at least a week? Anyways, I plan on using the deamon gem in ruby to have it update my data every 30 seconds or so. I gotta play with the idea still. So even if it was reset I would only be missing a few seconds of data. Would love to hear some better ideas.
Reply With Quote
  #6   (View Single Post)  
Old 22nd October 2008
phoenix's Avatar
phoenix phoenix is offline
Risen from the ashes
 
Join Date: May 2008
Posts: 696
Default

Not completely sure about OpenBSD, but the FreeBSD kernel uses 32-bit ints for keeping stats like this. Wouldn't be surprised if OpenBSD did something similar. As such, the counters will wrap around at some point. Not exactly random.
__________________
Freddie

Help for FreeBSD: Handbook, FAQ, man pages, mailing lists.
Reply With Quote
  #7   (View Single Post)  
Old 22nd October 2008
ephemera's Avatar
ephemera ephemera is offline
Knuth's homeboy
 
Join Date: Apr 2008
Posts: 537
Default

openbsd uses 64bit counters.

> So even if it was reset I would only be missing a few seconds of data. Would love to hear some better ideas.

one way you could keep track of the bytes passing through an interface is through a script running from cron that keeps some state on the disk so that it can continue tracking the usage correctly on interface reset, counter roll-over, reboot etc.

i wrote a daemon + script to keep track of my net usage you can check it out http://www.daemonforums.org/showthre...ighlight=bwmon

also, i recall a program mentioned on one of the threads (can't remember which one - try searching) that can give you statistics in nice html o/p, graphs etc.
Reply With Quote
  #8   (View Single Post)  
Old 22nd October 2008
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,975
Default

If PF is enabled and is keeping state, you can get traffic on individual state sessions with # pfctl -vs state
Reply With Quote
  #9   (View Single Post)  
Old 22nd October 2008
gregf gregf is offline
New User
 
Join Date: May 2008
Posts: 4
Default

Thanks for all the ideas. That other thread was a great resource. Missed that when searching some how.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:16 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick