OpenWrt Forum Archive

Topic: WRT54G - SNMP

The content of this topic has been archived on 20 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I want to pull snmp data from the linksys and publish it with MRTG. I would like to know if anyone has been able to make this work before...


I've got it working. I used the net-snmp ipkg from … mipsel.ipk. This is my /etc/snmp/snmpd.conf:

com2sec         readonly        default         public
com2sec         readwrite       localhost       private

group           public          v1              readonly
group           public          v2c             readonly
group           public          vusm            readonly
group           private         v1              readwrite
group           private         v2c             readwrite
group           private         vusm            readwrite

view    all     included        .1

access  public  ""      any     noauth  exact   all     none    none
access  private ""      any     noauth  exact   all     all     all

Good luck.

Do you know how I can change the port on which the snmpd is running?

The problem looks like this:
I'd like to monitor my snmp-data from my rootserver. There's mrtg running which checks the snmpd-data every 5 minutes.
At the moment, I'm only getting the snmpd-data of my router, not the data of my wrt54g which is located behind the router. My router is using the default snmpd-port.
Now, I'd like to change the port of the snmpd on my wrt54g and forward it, so that I can monitor both (the router and the wrt54g).

I hope someone understood my problem, and is able to help me. sad

got it now. it was just:

root@ap:/# snmpd

when I want to make it listen on on port 180.

Yet another question:
Did anyone of you monitor other stuff than just the traffic?
For example CPU or memory usage, or the load? If yes, what were the OIDs?

If you want to monitor cpu en mem status, you have to compile net-snmp with host mibs. The mibs-file will be larger!

Try snmpwalk to see what options you can monitor!

Yep, i used a snmp-browser but only found stuff related to networking, not to the system performance.
But i'll let it be. The actual size is already very large, i don't want to extend it.

This is the makefile for the snmpd binary only.

Keeps you from wasting all that space...

I wanted some stats off my wrt54g. I didn't want to waste any space, so I did the following...
I installed crond, set up a /etc/cron.5min/

root@OpenWrt:/etc/cron.5min# cat
cat /proc/loadavg | awk '{ print $1":"$2":"$3 }' > /www/load
cat /proc/net/dev | grep tun1 | cut -d: -f2 | awk '{ print $1":"$9}' > /www/tun1
cat /proc/net/dev | grep vlan1 | cut -d: -f2 | awk '{ print $1":"$9}' > /www/eth
cat /proc/meminfo > /www/mem
df -k | grep /dev/mtdblock/4 | awk '{ print $3":"$4 }' > /www/flashdisk

it runs every 5 minutes and puts the data files on the www share. Then I have my main server wget that and parse it using slightly modified scripts from here.. … .1a.tar.gz

he derived those from here...

if anyone is interested I can post a quickie how-to.

here's the results.. … -index.php

I just got it running last night,so not much data there yet :-)

Really great! Exactly that kind of stats i was searching for!

But one thing I would advise you to change as fast as possible: Change the location of the file where the data is stored to somewhere in /tmp. Maybe you could run a second httpd on a different port with its document directory to /tmp/www or so.
The flash of the wrt54g supports only a limited number of write processes .. if you do this to often (and, hey: you do this every 5 minutes if I understood you correctly), your box will be crunched in a few weeks or months.
Better write it to /tmp. That's the RAM and as the guys on #wrt54g at freenode told me, there's no limited number of writings.

It would be nice if you could post this howto. smile

wow! I hadn't thought about that, thank you for the info.

I fixed it by using ln

root@OpenWrt:/www# ln -s /tmp/flashdisk flashdisk
root@OpenWrt:/www# ln -s /tmp/load load
root@OpenWrt:/www# ln -s /tmp/mem mem
root@OpenWrt:/www# ln -s /tmp/tun1 tun1

works great!


Another good SNMP graphing tool that I like is Cacti (also rrd based). Here are the network interface graphs I started using the snmpd: … ;leaf_id=9

I wonder how much extra size is added by just turning on the "scripts"? I think that is the one that I want turned on. I could then write scripts and define my own OIDs right in the snmpd.conf that could get the memory/loadavg stuff. Then you can continue to use snmpd to get your load average and memory stats which should make life a little easier. If not I can create Cacti scripts that would grab the data from a URL like your workaround. I used to create a lot of my own OIDs and tie them to script output but it's not turned on in the snmpd that was in the ipkg. I guess I'll have to take the Makefile and see if I can get one compiled with script support.


rrdtool stats howto

I did all of this using Nico's firmware here

It had all the openvpn stuff I needed, thnx Nico!

mkdir /etc/cron.5min
vi /etc/cron.5min/

paste in the following

cat /proc/loadavg | awk '{ print $1":"$2":"$3 }' > /tmp/load
cat /proc/net/dev | grep tun1 | cut -d: -f2 | awk '{ print $1":"$9}' > /tmp/tun1
cat /proc/net/dev | grep vlan1 | cut -d: -f2 | awk '{ print $1":"$9}' > /tmp/eth
cat /proc/meminfo > /tmp/mem
df -k | grep /dev/mtdblock/4 | awk '{ print $3":"$4 }' > /tmp/flashdisk

then chmod 755 /etc/cron.5min/

go into you /www directory and

ln -s /tmp/flashdisk flashdisk
ln -s /tmp/load load
ln -s /tmp/mem mem
ln -s /tmp/tun1 tun1

if your rrdtool server is located on the outside your lan you will need to edit your /etc/init.d/S45firewall to allow outside http access

install crond, set it up to exec /etc/cron.5min/ every 5 minutes.

that’s it for the openwrt box, now onto the rrdtool server..

install rrdtool

download this...

edit and copy the rrdtoolgraphs.conf to your /etc

edit and for your paths..

edit your crontab with
*/5 * * * * root run-parts /etc/cron.5min > /dev/null 2>&1

cp the to /etc/cron.5min

cp to /etc/cron.hourly

good to go!
I am no guru, if anyone can think of stuff to add or modify speak up!

Did you modify the scripts from … .1a.tar.gz  ? If yes, in which way? Could you release them here?

And one thing I don't understand:
You wget the files .. Then, these scripts which are in the archive above parse them?
Do you then still need this file called bgraphs-1.1.tar.gz from ?

Which snmpd are you using then? And how do you define the new OIDs? Could you post an ipkg of your snmpd (or the source, so maybe I can create an ipkg) or your whole configuration file?

edit: forget it, bobsalt. Everything got answered by your last posting.

Thanks for the howto, bobsalt!
May I add it to the wiki?

heck ya!

The ipkg listed in this thread is minimalized as mentioned so this functionality isn't built in to it. I did just take the and modified it slightly and got the 2021 stuff to display. It did make snmpd much larger (went from like 80k to 600k). I didn't get the scripting capability as I hoped though. I'll have to play around with it when I get home (at work right now). The line I changed before making went from:

--with-out-mib-modules="snmpv3mibs notification target utilities agent_mibs agentx utilities/execute"


--with-out-mib-modules="snmpv3mibs notification target utilities agent_mibs agentx"

What I was hoping to achieve was being able to have snmpd execute scripts and return the result through an OID but this did not do it. There are examples in the included snmpd.conf file in the ipkg for how it is "supposed" to work for script execution. Again, I'll have to play around tonight and see if I can figure it out.

Did I understand you right, your snmpd version is 600k big? :shock:

Heh heh, that was my reaction but since I didn't spend more than about 5 minutes on the whole thing I'm sure it is something as simple as stripping the binary or something (either that or I got the wrong Makefile). I was getting loadavg and memory stats from the built in OIDs now though. smile I'll be able to work on it more in a few hours.

When you got a smaller binary, please tell me. smile

When you got a smaller binary, please tell me. smile

I should have realized what the deal was right away. The "" file linked to earlier in this thread is not the one that comes with the current b4 distribution. It's for the newer version of net-snmp. It's set to build a static binary where the default file is set to build a shared version, which is how the ipkg is built. The ipkg comes with all the libraries where the 600k snmpd file I built didn't require any libraries. I don't believe the running size is a lot different than the shared version.

I went ahead and built net-snmp with the included with b4 and it does build bigger than the what is included in the ipkg but all the other stuff works (the scripts, the load avg, memory OIDs etc). I install on NFS so it's not that big of a deal space wise for me but obviously I am limited in the amount of RAM. At any rate I don't think I'm quite ready for an ipkg until I can get things trimmed down.

Who built the ipkg linked to in this thread and would they still have their file? It would be nice to know what configure options were used and it would probably be a good starting point. Here's the last one I used that comes with b4 (I just turned off ssl):

The net-snmp_5.1-5.diff.gz was a little tricky to find as it seems to be outdated but here's were I found a copy:

Of course 5.1.1 is probably just as good or better to use.

Hrm .. nothing working here. sad
First, i tried the very latest release. I got the following error:

/bin/sh ../../libtool  --mode=compile /home/phil/dev/wrt54g/buildroot/build_mipsel/staging_dir/bin/mipsel-linux-uclibc-gcc -I../../include -I../../include -I. -I../.. -I. -I./../.. -I./../../snmplib -I./.. -I..   -g -O2 -Delf  -c -o mibII/at.lo mibII/at.c
/home/phil/dev/wrt54g/buildroot/build_mipsel/staging_dir/bin/mipsel-linux-uclibc-gcc -I../../include -I../../include -I. -I../.. -I. -I./../.. -I./../../snmplib -I./.. -I.. -g -O2 -Delf -c mibII/at.c -o mibII/at.o
mibII/at.c: In function `ARP_Scan_Next':
mibII/at.c:705: error: `ifIndex' undeclared (first use in this function)
mibII/at.c:705: error: (Each undeclared identifier is reported only once
mibII/at.c:705: error: for each function it appears in.)
make[2]: *** [mibII/at.lo] Error 1
make[2]: Leaving directory `/home/phil/dev/wrt54g/buildroot/net-snmp-5.1.2.pre2/agent/mibgroup'
make[1]: *** [subdirs] Error 1
make[1]: Leaving directory `/home/phil/dev/wrt54g/buildroot/net-snmp-5.1.2.pre2/agent'
make: *** [subdirs] Error 1

With the release 5.1.1 i got the same error ..

Do I need the patch you posted to get it compiled?

I've got your script running now .. But there's a small problem. Everytime the script is executed, i get a mail with the output of the script (the wget log). How can I disable this?
I already thought about using

wget http://myhostx/eth0 > /tmp/eth0 > /dev/null

but then, the output isn't saved in /tmp/eth0.
Do you have an idea what to do?

And yet another problem. Compare your graph for the load average with my one. First yours, then mine:
As you may see, my graph has no numbers on the left hand side. How do i get them?

hi Phil,

log into your wrt and type in cat /proc/loadavg | awk '{ print $1":"$2":"$3 }'

here's the results of that command for me...

root@OpenWrt:~# cat /proc/loadavg | awk '{ print $1":"$2":"$3 }'

does yours show up with any results?

on my main server, I have the 5 minute cron setup with the /dev/null 2>&1 part in it to suppress any messages email back to root. I am running fedora core 1. Maybe suse is different for cron? - I'm guessing you are using suse because you are in Germany :-)

*/01 * * * * root run-parts /etc/cron.1min > /dev/null 2>&1

on a side note, I didn't mod the processes script to the wrt. When I execute ps ax | grep -c : on my main box I get...

[root@rrust rrdtool-graphs]# ps ax | grep -c :

when i execute it on my wrt I get...

root@OpenWrt:~# ps ax | grep -c :

Does busyboxes grep use a differnet -c : count than fedora's? What results you get when you do it on your server Phil? I think the processes would be an interesting graph to have in there, along with the uptime.

also, I have problems with spiking in my rrdtool db files. I tried running that killspike, but it just errors out...anyone know of a tool that will kill the spikes?

Yes, it gives me a result:

root@ap:/# cat /proc/loadavg | awk '{ print $1":"$2":"$3 }' 

But it's still without the numbers on the left side. sad

Let's talk about the crontab script smile
It's no wonder that the script sends me the output, because behind the wget-lines, the output isn't modified. When you look into it, it justs wgets the files and moves that what it has downloaded to /tmp/$VAR, but it still gives me the output.
I modified the script a bit, now. I put a --quiet right after each wget command, and now it's not sending me mails anymore. smile
Btw, I'm not using SuSE. I hate SuSE. I'm using Debian.

And now this grep -c stuff. What do you want to do? Count the number of processes? I'd better use this way:

root@ap:/# ps -auwx | wc -l

And what are these spikes, you were talking about?

maybe your wrt is just coasting then? I have mine up with an active tunnel. Try to set up some sort of repitive task to suck up some cpu cycles. Has anyone ported the seti client to wrt? -lol

you da man Phil!
the "root@ap:/# ps -auwx | wc -l" command will work perfect

in the original scripts there's a graph script we can do for process's.

[root@rrust rrdtool-graphs]# cat

source /etc/rrdtoolgraphs.conf


PROCESSES=`ps ax | grep -c :`

rrdtool update $DBFILE N:$PROCESSES

DATE=`date +'%D %T'`
echo $DATE $PROCESSES >> $BASEDIR/processes.log
[root@rrust rrdtool-graphs]#

I'll edit that for PROCESSES=/tmp/proc" and get it added to the gz file.

here's the graphs for most of angrys scripts for linux

now, I would like to add the data at the bottom of the system temperature graph to the processes graph fro the wrt....

I'll work on that at lunch and post back when its done.

Every once in a while I will get a spike in network activity going up to 15mb therefore making the internet traffic disappear. not sure if there's a fix for that, except maybe do some sort of script logic to ignore #'s bigger than some predefined amount.

The discussion might have continued from here.