SBaronda.com a little place I like to call home.


Logging PFSense metrics to InfluxDB

Jun. 14, 2016

I recently upgraded to PFSense 2.3.1 and one of the things that I missed was the old RRD graphs. The replacement is called Monitoring, which does a pretty good job, but I think we can do better. Our solution will be installing telegraf on the PFSense and running InfluxDB on another box.

Here is my configuration details:

InfluxDB IP: 10.5.5.40
InfluxDB Username: influxdb
InfluxDB Password: influxdb

Router IP: 10.5.5.1

First we need to prepare the router, lets ssh into our router.

ssh [email protected]

Then enter the shell:

*** Welcome to pfSense 2.3.1-RELEASE (amd64 full-install) on pfSense ***

 WAN (wan)       -> vmx0       -> v4/DHCP4: x.x.x.x/23
 LAN (lan)       -> vmx1       -> v4: 10.5.5.1/24

 0) Logout (SSH only)                  9) pfTop
 1) Assign Interfaces                 10) Filter Logs
 2) Set interface(s) IP address       11) Restart webConfigurator
 3) Reset webConfigurator password    12) pfSense Developer Shell
 4) Reset to factory defaults         13) Update from console
 5) Reboot system                     14) Disable Secure Shell (sshd)
 6) Halt system                       15) Restore recent configuration
 7) Ping host                         16) Restart PHP-FPM
 8) Shell

Enter an Option: 8

Install Telegraf (note you need to adjust the version to something newer):

[2.3.1-RELEASE][[email protected]]/root: pkg add \
http://pkg.freebsd.org/freebsd:10:x86:64/latest/All/telegraf-0.12.1_1.txz

After it installs you need to configure it to be startable:

echo 'telegraf_enable=YES' >> /etc/rc.conf

Now we need to update the telegraf.conf connection information and what metrics we want to log:

cd /usr/local/etc
vi telegraf.conf

change:

[[outputs.influxdb]]
  urls = ["http://10.5.5.40:8089"]
  ...
  database = "telegraf"
  ...
  username = "influxdb"
  password = "influxdb"

Note: I didn't change any of the metrics that we are collecting and just using the defaults that came with the installation.

Now lets start telegraf up:

cd /usr/local/etc/rc.d
./telegraf start

Now you should be able to go http://10.5.5.40:8083 and do a query for SHOW DATABASES and see telegraf listed.

In my next tutorial I'll show you how to do some queries to get useful data. If you are eager to jump ahead look here.


comments powered by Disqus