SNMP monitoring with Grafana and telegraf on FreeBSD

This monitoring solution has three components, a database, collector and visualisor.

Database – influxdb

As the package description suggests influxdb is the perfect piece of software for storing SNMP data, and unlike the classic RRDtool it does not lose fidelity as the age of the data increases. Installing and start the service is easy:

# pkg search influxdb
influxdb-1.7.9                 Open-source distributed time series database
# pkg install influxdb-1.7.9
# sysrc influxd_enable=YES
# service influxd start 

Create a service user for the collector:

# influx
Connected to http://localhost:8086 version 1.7.9
InfluxDB shell version: 1.7.9
> exit
# service influxd restart

Collector – Telegraf

Telegraf will be used to take the values of the out SNMP OIDs and stores them in the influxdb.

# pkg search telegraf
telegraf-1.12.5                Time-series data collection
# pkg install telegraf-1.12.5

Configure telegraf to use the local influxdb instance as an ouput and also specify the Squid SNMP OIDs of interest as inputs.

# /usr/local/etc/telegraf.conf
  urls = [""]
  database = "telegraf"
  user = "telegraf_squid"
  password = "some_pa55"

  agents = [ "" ]
  timeout = "5s"
  retries = 3
  version = 2
  community = "squid_proxy"
  name = squid

    name = "uptime"
    oid = ""

    name = "cacheVersionId"
    oid = ""

    name = "cacheMemMaxSize"
    oid = ""

    name = "cacheSwapMaxSize"
    oid = ""

    name = "cacheMemUsage"
    oid = ""

    name = "cacheCpuUsage"
    oid = ""

    name = "cacheNumObjCount"
    oid = ""

    name = "cacheProtoClientHttpRequests"
    oid = ""

    name = "cacheCurrentSwapSize"
    oid = ""

    name = "cacheHttpHits"
    oid = ""

    name = "cacheHttpErrors"
    oid = ""

    name = "cacheHttpInKb"
    oid = ""

    name = "cacheHttpOutKb"
    oid = ""

    name = "cacheServerInKb"
    oid = ""

    name = "cacheServerOutKb"
    oid = ""

    name = "cacheClients"
    oid = ""
# sysrc telegraf_enable="YES"
# service telegraf start

Squid Config

Configure the local Squid instance for SNMP. Only SNMP v2c is supported so change the community string to something other than ‘public’. An ACL is also used to only allow SNMP queries from localhost.

# /usr/local/etc/squid/squid.conf
acl snmp_net src
acl snmp_r snmp_community squid_proxy
snmp_port 3401
snmp_access allow snmp_r snmp_net
snmp_access deny all

Visualiser – Grafana

The final piece to this puzzle is Grafana which will give us the ability to create a multitude of dashboards based on the data held within the influxdb. First install the package and configure the service.

# pkg search grafana
grafana6-6.5.2                 Dashboard and graph editor for multiple data stores
# pkg install grafana6-6.5.2
# sysrc grafana_enable=YES
# service grafana start

Next log onto webGUI, using the default credentials: admin / admin . Once logged in go ahead and configure the infuxdb instance as the datastore.

Setting up influxDB datasource

Once the davestore has been tested working and saved, graphs can then be created. The names which we gave to the Squid OIDs in the telgraf config file will appear as fields which can be queried and graphed.

Creating graphs by querying influxdb

In a very short space of time a multitude of graphs can be added to your dashboard.

Grafana Squid dashboard

If you don’t fancy digging through the various graphing options and creating your own, Grafana has an excellent ecosystem of user submitted dashboard:

This does still require you to configure influxdb/ telegraf to collect necessary SNMP OIDs but does safe some of the legwork.

Squid Dashboard by molu8bits

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

Up ↑

%d bloggers like this: