Setting up RTG on FreeBSD

Install the software we will be using

MySQL Setup

Enable MySQL by adding the following to /etc/rc.conf:

mysql_enable="YES"
Start MySQL:
# /usr/local/etc/rc.d/mysql-server start
Lock down MySQL by adding a password for the MySQL root account:
# mysqladmin -u root password $NEW_PASSWORD_HERE
Flush the MySQL Privileges:
# mysqladmin flush-privileges
Run the RTG setup script:
# /usr/local/etc/rtg/createdb $MYSQL_ROOT_PASSWORD

Configure RTG

Edit the routers file to contain an entry pointing to your router:

192.168.1.1:public:32
Run rtgtargmkr.pl to create the targets file:
# ./rtgtargmkr.pl
Poking 192.168.1.1 (public) (32 bit)...
No router id found for 192.168.1.2...adding.
No id found for VLAN1 on device 1...adding.
No id found for FastEthernet0/1 on device 1...adding.
No id found for FastEthernet0/6 on device 1...adding.
No id found for FastEthernet0/7 on device 1...adding.
No id found for FastEthernet0/8 on device 1...adding.
No id found for FastEthernet0/12 on device 1...adding.
No id found for FastEthernet0/13 on device 1...adding.
No id found for FastEthernet0/14 on device 1...adding.
No id found for FastEthernet0/23 on device 1...adding.
No id found for FastEthernet0/24 on device 1...adding.
Done.

Setup Daemontools

Create a /usr/local/etc/rtg/run file containing:

#!/bin/sh
exec /usr/local/bin/rtgpoll -v -c /usr/local/etc/rtg/rtg.conf -t /usr/local/etc/rtg/targets.cfg
Change the run file to be executable:
chmod +x /usr/local/etc/rtg/run
Create a /usr/local/etc/rtg/log directory:
mkdir /usr/local/etc/rtg/log
Create a /usr/local/etc/rtg/log/run file containing:
#!/bin/sh
exec multilog t ./main
Change the run file to be executable:
chmod +x /usr/local/etc/rtg/log/run
Link /usr/local/etc/rtg to the /service/rtg:
ln -s /usr/local/etc/rtg /service/
Configure svscan to start by adding the following to /etc/rc.conf:
svscan_enable="YES"
svscan_servicedir="/service"
Create the /service directory for svscan:
mkdir /service
Check to see if RTG is running, by running:
# svstat /service/rtg/
/service/rtg/: up (pid 6544) 28 seconds