DD-WRT

From Segfault
Jump to: navigation, search

Releases

TBD!

Use the Router Database to find out the correct image:

Backup

Backups can be created from the GUI (AdministrationBackup) or via command line. Since Busybox tar(1) does not support --exclude, a backup command will look something like this:

ssh router 2>/dev/null "cd / && nvram show > /tmp/nvram_show.txt && \
                        tar -cf - etc tmp" | gzip -c > backup-router.tar.gz

Software

muninlite

Apparently, on this WRT54GL I cannot install any packages:

% ipkg list
please enable jffs first, you can't use IPKG without jffs support

But we still can copy files to the box. muninlite is a shell script, implementing a basic munin-node.

svn co https://muninlite.svn.sourceforge.net/svnroot/muninlite/muninlite muninlite-svn
cd muninlite-svn

Use an NTP server near you:

sed 's/pool.ntp.org/us.pool.ntp.org/' -i.bak munin-node.conf

Before we build munin-node we have to get rid of some errors. Apparently, the if_ plugins are broken:

2012/12/17 03:35:27 [WARNING] munin_set_var_loc: Setting unknown option '_tmp_munin_node_' \
                              at example.org;router.example.org:if_etherip0

The df(1) command on the DD-WRT router is also broken. That is, it does not output anything if a filesystem is given as an argument. Since "/" is the only filesystem on the router, we modify the df munin-plugin. There's is a patch to be applied with -p0 that should fix those issues:

patch -p0 < ~/muninlite_v36.diff.txt
make

With all that in place, we're ready to transfer this to the router:

make
scp munin-node root@router:/tmp/

Now, on the router:

% while [ -x /tmp/munin-node ]; do nc -l -p 4949 -e /tmp/munin-node; done &
% netstat -an | grep 4949
tcp        0      0 0.0.0.0:4949            0.0.0.0:*               LISTEN      

With that in place, we can query the munin-node:

$ echo fetch load | nc router 4949
# munin node at router.example.org
load.value 0.02
.

We want to add this to our startup routine, so this gets executed during system boot:

% nvram set rc_startup="while [ -x /tmp/munin-node ]; do nc -l -p 4949 -e /tmp/munin-node; done"
% nvram commit

Links