Installing Cacti on Tomato router

First, you need a router with Tomato USB firmware, then you need optware, installation instructions can be found from here:

http://uk.nyclee.net/2012/04/28/installing-optware-in-tomato-usb-shibby/

Installing needed packages

# ipkg-opt install php php-fcgi php-mysql php-mssql mysql ncursesw libuclibc++ net-snmp rrdtool lighttpd

Downloading cacti

# cd /opt/share/www
# wget http://www.cacti.net/downloads/cacti-0.8.8a.tar.gz
# tar zxf cacti-0.8.8a.tar.gz
# rm cacti-0.8.8a.tar.gz
# ln -s cacti-0.8.8a cacti

Configuring mySQL

# mysql

> SET PASSWORD FOR root@localhost = PASSWORD(‘PWDforR00t’);

Remove example database

> DROP DATABASE test;

Create database for cacti

> CREATE DATABASE cacti;
> QUIT

import cacti database tables

# mysql -p cacti < /opt/share/www/cacti/cacti.sql

set user rights

# mysql -p

> GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY ‘PWDforC4ct1’;
> FLUSH PRIVILEGES;
> QUIT

Configure cacti

# vi /opt/share/www/cacti/include/config.php

set the mySQL connection info correct
set the directory information correct

Add cactiuser

# adduser cactiuser -D –H  
# cat /etc/passwd
# tail -1 /etc/passwd > /etc/passwd.custom
# nvram setfile2nvram /etc/passwd.custom
# commit
# chown -R cactiuser /opt/share/www/cacti/rra/ /opt/share/www/cacti/log/
# create a poller_helper.sh script
# vi /opt/scripts/poller_helper.sh

#!/bin/sh
cd /opt/share/www/cacti
php poller.php

Go to tomato web interface / Administrator / Scheduler add following to be done every 5 minutes

su cactiuser /opt/scripts/poller_helper.sh > /dev/null 2>&1

Go to the cacti web interface http://tomato/cacti/install/

Correct all paths for binaries

RRDtool
  /opt/bin/rrdtool

PHP
  /opt/bin/php

SNMPWALK
  /opt/bin/snmpwalk

SNMPGET
  /opt/bin/snmpget

SNMPBULKWALK
  /opt/bin/snmpbulkwalk

SNMPGETNEXT
  /opt/bin/snmpgetnext

and you are done! Go ahead start working with Cacti