1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

HowTo DD-WRT + SNMP + MRTG

Discussion in 'DD-WRT Firmware' started by u3gyxap, May 26, 2005.

  1. u3gyxap

    u3gyxap Network Guru Member

    OK, the folowing will describe how to setup SNMP monitoring for a WRT54G(s) running DD-WRT v22 prefinal5, using MRTG and JFFS.
    The folowing is written with the asumption that there is MRTG installed on a linux box or a server somewhere, DD-WRT prefinal5 is installed, configured and running, there is internet access available.

    1. Enable the SNMP function:
    Administration --> Management --> SNMP. Click Enable. Then Save settings.

    2. Setup the location, contact, name, RO/RW communities from
    Administration --> Management --> SNMP

    3. Enable JFFS
    Administration --> Management --> JFFS2 Support. Click Enable on both tags. Click Save settings.

    4. Wait for the JFFS partition to format. Please, DO WAIT 5 MINUTES!!!

    5. Enable Telnet/SSH - whatever you use.
    Administration --> Management --> Telnet
    Click Enable. Save Settings.

    6. Now, the JFFS partition is already formatted, disable the cleaning.
    Administration --> Management --> JFFS2 Support. Click Disable on "Clean JFFS2". Save Settings.

    7. Telnet/SSH to the WRT.
    Start --> Run
    Type "cmd". Click "Run".
    Type: "telnet 192.168.1.1" where 192.168.1.1 is yor WRT's IP address.
    for user type "root" and for password - whatever password you use.

    8. Make sure the JFFS exist.
    type:
    cd /jffs

    9. Make the RSSI scrip.
    type:
    cat - >/jffs/wlrssi1
    then type this:
    #!/bin/sh
    /usr/sbin/wl rssi |/usr/bin/cut -b 10-11

    Press Ctrl+C to save the file.

    10. Make the WL Rate script.
    type:
    cat - >/jffs/wlrate
    then type this:
    #!/bin/sh
    /usr/sbin/wl rate |/usr/bin/cut -b 9-10

    Press Ctrl+C to save the file.

    11. Make the Noise script.
    type:
    cat - >/jffs/wlnoise1
    then type this:
    #!/bin/sh
    /usr/sbin/wl noise |/usr/bin/cut -b 11-12

    Press Ctrl+C to save the file.

    12. Make the scripts executable.
    type:
    chmod -R a+xrw,g+rxw,u+rxw /jffs

    13. Modify the startup script.
    Administration --> Management --> Diagnostics
    Click Run. Type:
    #!/bin/sh
    cd /jffs
    echo "exec Noise /jffs/wlnoise1" >> /var/snmp/snmpd.conf
    echo "exec RSSI-WDS1 /jffs/wlrssi1" >> /var/snmp/snmpd.conf
    echo "exec Rate /jffs/wlrate" >> /var/snmp/snmpd.conf
    killall -TERM snmpd
    snmpd -c /var/snmp/snmpd.conf

    Click Save Startup.

    13. Reboot your router.

    Now, the SNMP daemon is executing the scripts, and giving the values to MRTG uppon request. The oids for the Noise, RSSI and Wireless Rate are:

    .1.3.6.1.4.1.2021.8.1.101.1 - Noise
    .1.3.6.1.4.1.2021.8.1.101.2 - RSSI
    .1.3.6.1.4.1.2021.8.1.101.3 - WL Rate

    This can be modified for more clients. The above is for one client on the wireless interface (or for a router in client mode) For more wireless clients just add scripts (specifying MAC address would be a good idea) and OIDs will appear.

    Also, there are OIDs for memory and cpu load:

    CPU Load
    .1.3.6.1.4.1.2021.10.1.5.1 - 1 minute average
    .1.3.6.1.4.1.2021.10.1.5.1 - 5 minutes average
    .1.3.6.1.4.1.2021.10.1.5.1 - 15 minutes average

    Memory
    .1.3.6.1.2.1.25.2.3.1.5.101 - Total Memory
    .1.3.6.1.2.1.25.2.3.1.6.101 - Used Memory

    Here is an example of what mrtg.cfg file might look like for a WRT working in client mode. Monitored are LAN, WAN/Wireless, Signal (RSSI), Noise, Signal to Noise Ratio, Memory, CPU Load. Router name is "zion, RO community is "public", contact person is "root", and location is "home". IP address of the router is 192.168.1.213:


    RunAsDaemon: Yes
    EnableIPv6: no
    WorkDir: /share/hdd/data/www/mrtg


    ######################################################################
    # System: zion
    # Description: Linux 2.4.20 #26 Thu Jan 27 21:27:06 UTC 2005 mips
    # Contact: root
    # Location: home
    ######################################################################


    ### LAN ###

    Target[192.168.1.213_5]: 5:public@192.168.1.213:
    RouterUptime[192.168.1.213_5]: public@192.168.1.213
    MaxBytes[192.168.1.213_5]: 250000
    Options[192.168.1.213_5]: growright,transparent,nolegend
    Title[192.168.1.213_5]: Traffic Analysis for zion - LAN
    PageTop[192.168.1.213_5]: <H1>Traffic Analysis for zion - LAN</H1>
    <TABLE>
    <TR><TD>Description:</TD><TD>LAN </TD></TR>
    <TR><TD>Max Speed:</TD> <TD>12.500 MBytes/s</TD></TR>
    </TABLE>


    ### WAN/ WL###

    Target[192.168.1.213_6]: 6:public@192.168.1.213:
    RouterUptime[192.168.1.213_6]: public@192.168.1.213
    MaxBytes[192.168.1.213_6]: 250000
    Options[192.168.1.213_6]: growright,transparent,nolegend
    Title[192.168.1.213_6]: Traffic Analysis for zion - WAN
    PageTop[192.168.1.213_6]: <H1>Traffic Analysis for zion - WAN</H1>
    <TABLE>
    <TR><TD>Description:</TD><TD>WAN </TD></TR>
    <TR><TD>Max Speed:</TD> <TD>2500 kBytes/s</TD></TR>
    <TR><TD>WanIp:</TD> <TD>192.168.0.49 ()</TD></TR>
    </TABLE>


    ### RSSI and Noise ###

    Options[192.168.1.213_rssi]: growright,gauge,nopercent,integer,transparent,nolegend
    Target[192.168.1.213_rssi]: 1.3.6.1.4.1.2021.8.1.101.1&1.3.6.1.4.1.2021.8.1.101.2:public@192.168.1.213
    RouterUptime[192.168.1.213_rssi]: public@192.168.1.213
    AbsMax[192.168.1.213_rssi]: 100
    MaxBytes[192.168.1.213_rssi]: 100
    Unscaled[192.168.1.213_rssi]: dwmy
    ShortLegend[192.168.1.213_rssi]: dB
    YLegend[192.168.1.213_rssi]: dB
    Title[192.168.1.213_rssi]: Signal and Noise Readings for zion
    PageTop[192.168.1.213_rssi]: <H1>Signal and Noise Readings for zion</H1>

    <TABLE>
    <TR><TD>Description:</TD><TD>RSSI and Noise </TD></TR>
    <TR><TD>Max Value:</TD> <TD>100dB</TD></TR>
    </TABLE>


    ### Signal to Noise Ratio ###

    Options[192.168.1.213_snr]: growright,gauge,nopercent,integer,transparent,noo,nolegend
    Target[192.168.1.213_snr]: 1.3.6.1.4.1.2021.8.1.101.1&1.3.6.1.4.1.2021.8.1.101.1:public@192.168.1.213 - 1.3.6.1.4.1.2021.8.1.101.2&1.3.6.1.4.1.2021.8.1.101.2:public@192.168.1.213
    RouterUptime[192.168.1.213_snr]: public@192.168.1.213
    AbsMax[192.168.1.213_snr]: 100
    MaxBytes[192.168.1.213_snr]: 100
    Unscaled[192.168.1.213_snr]: dwmy
    ShortLegend[192.168.1.213_snr]: dB
    YLegend[192.168.1.213_snr]: dB
    Title[192.168.1.213_snr]: Signal To Noise Ratio Analysis for zion
    PageTop[192.168.1.213_snr]: <H1>Signal To Noise Ratio Analysis for zion</H1>

    <TABLE>
    <TR><TD>Description:</TD><TD>SNR</TD></TR>
    <TR><TD>Max Value:</TD> <TD>100dB</TD></TR>
    </TABLE>


    ### Memory ###

    Target[192.168.1.213_MEM]: 1.3.6.1.2.1.25.2.3.1.6.101&1.3.6.1.2.1.25.2.3.1.6.101:public@192.168.1.213 * 1024
    Title[192.168.1.213_MEM]: Memory Usage
    Options[192.168.1.213_MEM]: growright,gauge,nopercent,transparent,noo,nolegend
    MaxBytes[192.168.1.213_MEM]: 32000000
    Unscaled[192.168.1.213_MEM]: dwmy
    ShortLegend[192.168.1.213_MEM]: B
    YLegend[192.168.1.213_MEM]: Mem Used
    PageTop[192.168.1.213_MEM]: <H1>Memory Usage for zion</H1>

    <TABLE>
    <TR><TD>Description:</TD><TD>Used Memory</TD></TR>
    <TR><TD>Max Value:</TD> <TD>32MB</TD></TR>
    </TABLE>


    ### cpu load ###

    Target[192.168.1.213_cpu]: 1.3.6.1.4.1.2021.10.1.5.1&1.3.6.1.4.1.2021.10.1.5.1:public@192.168.1.213:
    Options[192.168.1.213_cpu]: growright,gauge,integer,transparent,noo,nolegend
    RouterUptime[192.168.1.213_cpu]: public@192.168.1.213
    kilo[192.168.1.213_cpu]: 100
    MaxBytes[192.168.1.213_cpu]: 100
    Unscaled[192.168.1.213_cpu]: dwmy
    ShortLegend[192.168.1.213_cpu]: %
    YLegend[192.168.1.213_cpu]: CPU Load %
    Title[192.168.1.213_cpu]: CPU load
    PageTop[192.168.1.213_cpu]: <H1>CPU load</H1>

    <TABLE>
    <TR><TD>Description:</TD><TD>CPU load </TD></TR>
    <TR><TD>Max Value:</TD> <TD>100%</TD></TR>
    </TABLE>



    You can use the cfgmaker in MRTG to make the cfg file. Also, there are many more OIDs to monitor, if you like, just use GetIf to doscover them, and add them to your mrtg.cfg file. If you find anything interesting - share with us :)


    If you also have a LinkSys NSLU2, you may want to check out this:
    http://www.linksysinfo.org/modules.php?name=Forums&file=viewtopic&p=23499
     
  2. travanx

    travanx Network Guru Member

    thanks for the writeup. Just installed all of this for the network at work. Can't wait to try this at home. a couple of problems I ran into though that maybe someone else who is a newbie to this may run into.

    For the tables command mine didn't like it unless i indented like this, a space in front of the table and tr commands which is hard to see on here,s o replace the period with a space.

    PageTop[192.168.0.1_6]: <H1>Traffic Analysis - WAN</H1>
    .<TABLE>
    .<TR><TD>Description:</TD><TD>WAN </TD></TR>
    .<TR><TD>Max Speed:</TD> <TD>2500 kBytes/s</TD></TR>
    .<TR><TD>WanIp:</TD> <TD>192.168.0.49 ()</TD></TR>
    .</TABLE>

    Also there were a couple of spots where the IP number had spaces in it, when i copy and pasted this into my mrtg.cfg file.

    I used the firmware that I downloaded today 5/26/05 to follow this guide.
     
  3. zgamer

    zgamer Network Guru Member

    Good info. My only question is: can you run everything for mrtg on the wrt54? That way it's completely independant from needing another machine.
     
  4. u3gyxap

    u3gyxap Network Guru Member

    MRTG uses a scripting language - "Perl". That is not available for the WRT54G. Also, MRTG and Perl are both pretty big for the memory resources that the WRT54G has, so you will need some sort of SMB share accessible, which means you will end up with a machine working 24/7 to provide the extra space. Well, that machine will do better running the MRTG and keeping the stats, than just serving network storage.
     
  5. zgamer

    zgamer Network Guru Member

    For the storage problem I was thinking of doing the SD card mod to the router to get the storage space and for Perl I was thinking maybee libpcre and/or the microperl ipkgs for openwrt.

    Otherwise is there anything else that could be completely run on the wrt which would give the reporting that mrtg as far as usage by port, mem usage, cpu usage, ect?
     
  6. XCOM7

    XCOM7 Network Guru Member

    As far as I know micropearl would not run MRTG.
     
  7. u3gyxap

    u3gyxap Network Guru Member

    @zgamer, The only think I can think of is Samurize.
     
  8. travanx

    travanx Network Guru Member

    If you figure this out, please do a writeup. That was be really interesting to be able to run MRTG completely off of the router. Also what are some other useful things to monitor? Since I don't know where to look for those OID's. Also how did you learn how to write those 3 new things into the router jffs drive?

     
  9. mcavazos

    mcavazos Network Guru Member

    I tryed your howto but I dont have space on the device

    /jffs # df -h
    Filesystem Size Used Available Use% Mounted on
    /dev/root 2.7M 2.7M 0 100% /
    /dev/mtdblock/4 320.0k 320.0k 0 100% /jffs
    /jffs # ls
    /jffs # ls -lha
    drwxr-xr-x 1 root root 0 Jun 8 10:19 .
    drwxr-xr-x 1 root root 83 Apr 3 22:45 ..
    /jffs #

    Anything im missing?
     
  10. u3gyxap

    u3gyxap Network Guru Member

    What version off DD-WRT are you using? Update to the latest. Try to clean the JFFS trough the web interface and redo everything.
     
  11. zgamer

    zgamer Network Guru Member

    After playing around with it for about two weeks I've hit a roadblock in terms of functionality. Basically there's a cpu limitation and a perl library limitation. The cpu is pegged out when calling up the web pages(sometimes causes the router to reboot) & the incomplete perl libraries cause pages not to load correctly. The best bet I have on this for similar functionality for an "all on the router" solution would be to use the bwlog port from littlewhoo. Functionality wise this reporting tool is lacking some functionality currently but is in development.
     
  12. mcavazos

    mcavazos Network Guru Member

    im using Firmware version: DD-WRT #22 (prefinal3.2) i tryed to clean it but i couldnt
     
  13. u3gyxap

    u3gyxap Network Guru Member

    Update to the latest prefinal5.
     

Share This Page