Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 12-10-2003, 03:45 PM   #1
LQ Newbie
Registered: Nov 2003
Location: Ottawa, Canada
Distribution: Debian
Posts: 10

Rep: Reputation: 0
Linksys, SNMP and mrtg

I'm trying to get my Linksys BEFSR41 router to start reporting SNMP stuff, so I can track my whole network's bandwidth usage. I followed the directions here:

(I'm not allowed to post URLs yet... search Google for "linksys mrtg matthew" and it should be the first link.)

which were pretty good, and I now have timestamps updating in mrtg. The problem is that the values for in/out are always zero -- mrtg thinks that there's no bandwidth being used at all! From what I can see, the format that is expecting is not what is being received. This is the relevant snippet from

if($data =~ /^\"\@/) {
  $data =~ s/^\"\@|\.\"$//g;
  my ($dir, $src, $x, $dest, $port) = split /\s+/, $data, 5;
  if($dir eq "in") {
  } elsif($dir eq "out") {
It looks like it's expecting "@in", and then some more data. However, when I log all the SNMP traffic to a file, and then look for anything mentioning "@in", this is the kind of information I'm getting:

SNMPv2-MIB::sysUpTime.0 6:23:23:28.81
SNMPv2-MIB::snmpTrapOID.0 SNMPv2-SMI::enterprises.3093.
SNMPv2-SMI::enterprises.3093.1.1.0 "40 69 6E 20 32 34 2E 31 35 37 2E 31 34 37 2E 31  [@in]
34 37 20 33 36 37 33 38 20 32 2E 30 2E 30 2E 30  [47 36738]
20 32 32 0A   [ 22.]"
SNMP-COMMUNITY-MIB::snmpTrapCommunity.0 "public"
SNMPv2-MIB::snmpTrapEnterprise.0 SNMPv2-SMI::enterprises.3093.2.2.1
Parsed output: 0::0::6:23:23:28.81::router
As you can see, the @in is followed only by the IP and doesn't involve any quotations marks. So the regex doesn't match, doesn't see any bandwidth being used, and mrtg reports only a bunch of zeros.

I don't know enough about SNMP to guess why the format is different, or which (the Linksys' options or the script needs to be changed, or even what data is gathering to come up with bandwidth usage. (It seems unlikely that the Linksys is counting individual packets.) I've also tried linksysmon, but wasn't able to get it to output data so that mrtg can process it.

If anyone has any suggestions, I'd love to hear them!
Old 02-05-2004, 08:37 AM   #2
Registered: Aug 2003
Location: Colorado, USA
Distribution: Fedora Core
Posts: 100

Rep: Reputation: 15
I have a Linksys BEFW11S4 and the didn't seem to be working for me either. So I wrote the awk script below. It started out as a way to try and figure out what the heck was going on (i.e. what linksys was sending me)...but then I turned around and replaced with this script altogether (i.e. in /etc/snmp/snmptrapd.conf).

So now I have what I think is a valid /tmp/router.out file but mrtg graphs are still zero. Anyone else have any ideas?

#{printf "whole line: %s\n", $0}
{if (/sysUpTime/)
sysuptime = $2
else if (!/SNMP/)
{for (i = 0; i < NF; i++)
myStr = myStr sprintf("%c", strtonum("0x" $i));
else if (/40 6F/ || /40 69/)
{for (i = 0; i < NF; i++)
if ($i == "\"40")
myStr = "@"
found = 1
else if (found == 1)
myStr = myStr sprintf("%c", strtonum("0x" $i));
if (index(myStr, "@out") > 0)
outBytes = substr(myStr, 19, 6)
if (index(myStr, "@in") > 0)
inBytes = substr(myStr, 19, 6)
# {print " sysUpTime: ", sysuptime}
# {print " myStr: ", myStr}
# {print " in bytes: ", inBytes}
# {print " out bytes: ", outBytes}
getline < "/tmp/router.out"
fileInBytes = $0
getline < "/tmp/router.out"
fileOutBytes = $0
OFS = ""
if (length(inBytes) > 0 && length(outBytes) > 0)
{print strtonum(inBytes), "\n", strtonum(outBytes), "\n", sysuptime, "\nrouter" > "/tmp/router.out"}
else if (length(inBytes) > 0)
{print strtonum(inBytes), "\n", strtonum(fileOutBytes), "\n", sysuptime, "\nrouter" > "/tmp/router.out"}
else if (length(outBytes) > 0)
{print strtonum(fileInBytes), "\n", strtonum(outBytes), "\n", sysuptime, "\nrouter" > "/tmp/router.out"}

Last edited by JimDog; 02-05-2004 at 08:40 AM.
Old 03-19-2004, 11:05 PM   #3
LQ Newbie
Registered: Mar 2004
Posts: 21

Rep: Reputation: 15
Originally posted by Kyanos
(It seems unlikely that the Linksys is counting individual packets.) I've also tried linksysmon, but wasn't able to get it to output data so that mrtg can process it.

If anyone has any suggestions, I'd love to hear them!
Does your BEFSR Password page have entries for snmp communities? If so, use them and monitor directly instead of using trap collector. The Linksys routers do appear to send packet counts, not byte counts, so the traps are useless for monitoring bandwidth.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
snmp-mrtg ahmed4linux Linux - General 1 11-03-2004 08:27 AM
Net-SNMP and MRTG Astro Linux - Networking 5 07-25-2003 04:24 AM
help with mrtg and snmp cristi1979 Linux - Networking 1 06-24-2003 09:49 PM
Snmp/mrtg hydro Linux - Software 1 06-15-2003 10:39 AM
Running SNMP in RH 7.2 (for MRTG) Token Linux - Software 0 06-12-2002 03:05 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration