Home Directory Documentation Nagios with InfluxDB, nagflux and Grafana

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com


Remember Me

Directory Tree

Nagios with InfluxDB, nagflux and Grafana

3 votes
Compatible With
  • Nagios 4.x
  • Nagios XI
Network Monitoring Software - Download Nagios XI
Log Management Software - Nagios Log Server - Download
Netflow Analysis Software - Nagios Network Analyzer - Download
A short tutorial howto install InfluxDB, nagflux and Grafana.
This short document describes how to install InfluxDB, nagflux and Grafana on the Nagios XI appliance (CentOS release 6.8).
No passwords are changed in this tutorial, access to the database is configured without password, make sure to change the passwords and restrict the access.

# yum install golang-github-influxdb-influxdb-client golang-github-influxdb-influxdb-datastore git

Get InfluxDB from https://influxdata.com/downloads/#influxdb
# rpm -Uvh influxdb-0.13.0.x86_64.rpm
# service influxdb start

Install and configure nagflux
# export GOPATH=$HOME/gorepo
# mkdir $GOPATH
# go get -v -u github.com/griesbacher/nagflux
# go build github.com/griesbacher/nagflux

# vi config.gcfg
NagiosSpoolfileFolder = "/usr/local/nagios/var/spool/nagfluxperfdata"
NagiosSpoolfileWorker = 1
InfluxWorker = 2
MaxInfluxWorker = 5
DumpFile = "/usr/local/nagios/var/log/nagflux/nagflux.dump"
NagfluxSpoolfileFolder = "/usr/local/nagios/var/nagflux"
FieldSeparator = "&"
BufferSize = 1000

#leave empty for stdout
LogFile = ""
#List of Severities https://godoc.org/github.com/kdar/factorlog#Severity
MinSeverity = "INFO"

# mkdir -p /usr/local/nagios/var/spool/nagfluxperfdata
# chown nagios:nagios /usr/local/nagios/var/spool/nagfluxperfdata

The scripts are necessary to write performance data to pnp4nagios and nagflux.
# vi /usr/local/nagios/libexec/process-host-perfdata-file-bulk

/bin/cp -p /usr/local/nagios/var/host-perfdata /usr/local/nagios/var/spool/nagfluxperfdata/${1}.perfdata.host
/bin/mv /usr/local/nagios/var/host-perfdata /usr/local/nagios/var/spool/xidpe/${1}.perfdata.host

# vi /usr/local/nagios/libexec/process-service-perfdata-file-bulk

/bin/cp -p /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/nagfluxperfdata/${1}.perfdata.service
/bin/mv /usr/local/nagios/var/service-perfdata /usr/local/nagios/var/spool/xidpe/${1}.perfdata.service

# chown apache:nagios /usr/local/nagios/libexec/process-*-perfdata-file-bulk
# chmod 755 /usr/local/nagios/libexec/process-*-perfdata-file-bulk

Login to the web interface -> Core Config Manager -> Commands.
Modify the command: process-host-perfdata-file-bulk
/usr/local/nagios/libexec/process-host-perfdata-file-bulk $TIMET$

Modify the command: process-service-perfdata-file-bulk
/usr/local/nagios/libexec/process-service-perfdata-file-bulk $TIMET$
=> Apply Configuration
After some seconds you should see files in "/usr/local/nagios/var/spool/nagfluxperfdata" (nagflux will remove the files from the directory).

Start nagflux. Nagflux will not fork as a deamon, make sure to create a start script for it.
# ./nagflux

Download Grafana from http://grafana.org/download/
# rpm -Uvh grafana-3.0.4-1464167696.x86_64.rpm
# chkconfig --add grafana-server
# service grafana-server start

Add a firewall rule to allow the access to port 3000, add the line before the REJECT rules
# vi /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3000 -j ACCEPT

# service iptables restart
Login to the web interface http://Nagios-Server:3000
User name and password: admin
Menu -> Data Source -> Add Data Source
Name: nagflux
Type: InfluxDB
Url: http://localhost:8086
Access: proxy
Database: nagflux

Go to Dashboards -> Home -> New
Click the small icon on the left -> Add panel -> Graph
Panel data source: nagflux
Sample query: SELECT mean("value") AS "time-value", mean("warn") AS "time-warn", mean("warn-min") AS "time-warn-min", mean("warn-max") AS "time-warn-max", mean("crit") AS "time-crit", mean("crit-min") AS "time-crit-min", mean("crit-max") AS "time-crit-max" FROM "metrics" WHERE "host" = 'localhost' AND "service" = 'HTTP' AND "command" = 'check_http' AND "performanceLabel" = 'time' AND $timeFilter GROUP BY time($interval) fill(null)
Alias by $col

Update 20th March 2017:
A very nice addon is https://github.com/Griesbacher/histou
Copy the files from github to your web server directory.
Copy histou.js to grafana.
cp -p histou.js /usr/share/grafana/public/dashboards/

Reviews (1)
byPeer, July 21, 2016
Worked for me with Nagios and pnp4nagios (which I plan to keep for now), but this is very cool and makes Nagios perfdata gathering more meaningful.
Using Nagios Core 4.1.1, pnp4nagios, Thruk and now Grafana.

Wonder what is the main differences between that and Graphios...
does anyone know?