Library

Docs
Beta

Projects

Nagios Core 4 Home PageNagios Core 4 Host InformationNagios Core 4 Host Status DetailsNagios Core 4 IntroductionNagios Core 4 Service InformationNagios Core 4 Service Overview For All Host GroupsNagios Core 4 Service Overview For All Service GroupsNagios Core 4 Service Status DetailsNagios Core 4 Status MapsNagios Core 4 Tactical OverviewNagios Core Active ChecksNagios Core Adaptive MonitoringNagios Core Alerting With MySQL and Nagios NWC13Nagios Core Authentication And Authorization In The CGIsNagios Core CGI Configuration File OptionsNagios Core Cached ChecksNagios Core Configuration OverviewNagios Core Configuring SSL/TLSNagios Core Custom CGI Headers and FootersNagios Core Detection and Handling of State FlappingNagios Core Distributed MonitoringNagios Core Enhanced CGI Security and AuthenticationNagios Core Event HandlersNagios Core External CommandsNagios Core Fast Startup OptionsNagios Core Graphing Performance Info With MRTGNagios Core Host ChecksNagios Core Host and Service DependenciesNagios Core How To Monitor A Linux/Unix MachineNagios Core How To Monitor A Netware ServerNagios Core How To Monitor A Network PrinterNagios Core How To Monitor A Publicly Available Service (HTTP, FTP, SSH, etc.)Nagios Core How To Monitor A Router/SwitchNagios Core How To Monitor A Windows MachineNagios Core How to Maintain Over 20 Monitoring Appliances NWC14Nagios Core Integration OverviewNagios Core Leveraging SNMP Extensions with Nagios NWC13Nagios Core Main Configuration File OptionsNagios Core Monitoring Remote Locations with Nagios NWC13Nagios Core Monitoring Service and Host ClustersNagios Core Nagios, AWS, and Hosted VoIP NWC13Nagios Core Nagios Plugin APINagios Core Nagios URL In NotificationsNagios Core Nagios on AWS NWC14Nagios Core Notification EscalationsNagios Core NotificationsNagios Core Object Configuration OverviewNagios Core Object DefinitionsNagios Core Object InheritanceNagios Core On Call RotationsNagios Core Passive ChecksNagios Core Passive Host State TranslationNagios Core Performance DataNagios Core Performance Graphs Using InfluxDB + Nagflux + Grafana + HistouNagios Core Performance Graphs Using PNP4NagiosNagios Core Plugin Development GuidelinesNagios Core Predictive Dependency ChecksNagios Core SNMP Explained NWC15Nagios Core SNMP Monitoring Architecture With Nagios NWC13Nagios Core SNMP Trap IntegrationNagios Core Scheduled DowntimeNagios Core Security ConsiderationsNagios Core Service And Daemon ChecksNagios Core Service and Host Freshness ChecksNagios Core Standard Macros in NagiosNagios Core Starting and Stopping NagiosNagios Core State StalkingNagios Core State TypesNagios Core Status Map Customization (Legacy)Nagios Core Status Map CustomizationNagios Core TCP Wrapper IntegrationNagios Core Time Period InheritanceNagios Core Time PeriodsNagios Core Understanding Macros and How They WorkNagios Core Upgrading From Previous VersionsNagios Core Upgrading Nagios Core From SourceNagios Core Using Grafana With PNP4NagiosNagios Core Using The Nagiostats UtilityNagios Core Verifying Your ConfigurationNagios Core Volatile ServicesNagios Core Writing a Custom Worker

Nagios Core - Using Grafana With PNP4Nagios


This documentation explains how to install and configure Grafana to generate performance graphs with an existing PNP4Nagios solution. This guide relies on having installed and configured PNP4Nagios using the following documentation:

Nagios Core - Performance Graphs Using PNP4Nagios

If you don't have PNP4Nagios installed and want to use Grafana then you might be interested in this alternate solution:

Nagios Core - Performance Graphs Using InfluxDB + Nagflux + Grafana + Histou

IMPORTANT

DO NOT follow this guide if you are using Nagios XI. This guide is intended for Nagios Core only.

This guide is broken up into several sections and covers different Linux distributions and operating systems (OS), only the 64-bit (x86_64) implementations of these OS's will work, it does not work on 32-bit (x86). If your Linux Distribution or operating system is not included in this guide then please contact us to see if we can get it added. Some distributions may be missing as we don't have access to a test environment that allows us to develop the documentation.

Note: This guide is based on Nagios Core being installed using the following KB article:

Documentation - Installing Nagios Core From Source

Please select your OS:

CentOS | RHEL | Oracle Linux

This documentation works on CentOS / RHEL / Oracle Linux version 6+. We were unable to get this solution working on versions prior to 6.x.

Install Grafana

Please follow the Grafana installation documentation:

http://docs.grafana.org/installation/rpm/

Once installed, execute the following commands to start the service and ensure it is enabled to start on boot:

===== RHEL 6 | CentOS 6 | Oracle Linux 6 =====

chkconfig --add grafana-server
service grafana-server start

===== RHEL 7 | CentOS 7 | Oracle Linux 7 =====

systemctl enable grafana-server.service
systemctl start grafana-server.service

You need to allow port 3000 inbound traffic on the local firewall so you can reach the Grafana web interface:

===== RHEL 6 | CentOS 6 | Oracle Linux 6 =====

iptables -I INPUT -p tcp --destination-port 3000 -j ACCEPT
service iptables save
ip6tables -I INPUT -p tcp --destination-port 3000 -j ACCEPT
service ip6tables save

===== RHEL 7 | CentOS 7 | Oracle Linux 7 =====

firewall-cmd --zone=public --add-port=3000/tcp
firewall-cmd --zone=public --add-port=3000/tcp --permanent

Install PNP Components

Execute these commands to install the PNP4Nagios components for Grafana:

grafana-cli plugins install sni-pnp-datasource
cd /usr/local/pnp4nagios/share/application/controllers/
wget -O api.php "https://github.com/lingej/pnp-metrics-api/raw/master/application/controller/api.php"

You also need to restart the grafana-server service:

===== RHEL 6 | CentOS 6 | Oracle Linux 6 =====

service grafana-server restart

===== RHEL 7 | CentOS 7 | Oracle Linux 7 =====

systemctl restart grafana-server.service

Grant localhost Permission To PNP4Nagios Site

Grafana will be making calls to the PNP API and will require permission. This guide focusses on granting access to the local host however with "CentOS | RHEL | Oracle Linux 6.x" a username/password is required.

===== RHEL 6 | CentOS 6 | Oracle Linux 6 =====

The following command will add the user grafana with the password ANAFARG to htpasswd.users:

htpasswd -b /usr/local/nagios/etc/htpasswd.users grafana ANAFARG

Please proceed to the Grafana Configuration section for the next step.

===== RHEL 7 | CentOS 7 | Oracle Linux 7 =====

The method used here is to allow the 127.0.0.1 & ::1 addresses of the Nagios server access. This is defined by adding the following line to pnp4nagios.cfg:

Require ip 127.0.0.1 ::1

The following command will add that line to pnp4nagios.cfg:

sed -i '/Require valid-user/a\        Require ip 127.0.0.1 ::1' /etc/httpd/conf.d/pnp4nagios.conf

The Apache httpd service needs to be restarted for this change to take affect:

systemctl restart httpd.service

Please proceed to the Grafana Configuration section for the next step.

Ubuntu

This documentation works on Ubuntu version 16+. We were unable to get this solution working on versions prior to 16.x.

Install Grafana

Please follow the Grafana installation documentation:

http://docs.grafana.org/installation/debian/

Once installed, execute the following commands to start the service and ensure it is enabled to start on boot:

sudo systemctl enable grafana-server.service
sudo systemctl start grafana-server.service

You need to allow port 3000 inbound traffic on the local firewall so you can reach the Grafana web interface.

sudo ufw allow 3000/tcp
sudo ufw reload

Install PNP Components

Execute these commands to install the PNP4 components for Grafana:

sudo grafana-cli plugins install sni-pnp-datasource
sudo systemctl restart grafana-server.service
cd /usr/local/pnp4nagios/share/application/controllers/
sudo wget -O api.php "https://github.com/lingej/pnp-metrics-api/raw/master/application/controller/api.php"

Grant localhost Permission To PNP4Nagios Site

Grafana will be making calls to the PNP API and will require permission. The method used here is to allow the 127.0.0.1 & ::1 addresses of the Nagios server access. This is defined by adding the following line to pnp4nagios.cfg:

Require ip 127.0.0.1 ::1

The following command will add that line to pnp4nagios.cfg:

sudo sh -c "sed -i '/Require valid-user/a\        Require ip 127.0.0.1 ::1' /etc/apache2/sites-enabled/pnp4nagios.conf"

The Apache apache2 service needs to be restarted for this change to take affect:

sudo systemctl restart apache2.service

Please proceed to the Grafana Configuration section for the next step.

SUSE SLES | openSUSE Leap

This documentation was tested on SUSE SLES 12.2+ and openSUSE Leap 42.2+.

Install Grafana

Please follow the Grafana installation documentation:

http://docs.grafana.org/installation/rpm/

Once installed, execute the following commands to start the service and ensure it is enabled to start on boot:

sudo systemctl enable grafana-server.service
sudo systemctl start grafana-server.service

You need to allow port 3000 inbound traffic on the local firewall so you can reach the Grafana web interface:

===== SUSE SLES 12.x =====

sudo /usr/sbin/SuSEfirewall2 open EXT TCP 3000
sudo systemctl restart SuSEfirewall2 

===== openSUSE Leap 42.x =====

The firewall service is not enabled by defauly on openSUSE.

Install PNP Components

Execute these commands to install the PNP4 components for Grafana:

sudo grafana-cli plugins install sni-pnp-datasource
sudo systemctl restart grafana-server.service
cd /usr/local/pnp4nagios/share/application/controllers/
sudo wget -O api.php "https://github.com/lingej/pnp-metrics-api/raw/master/application/controller/api.php"

Grant localhost Permission To PNP4Nagios Site

Grafana will be making calls to the PNP API and will require permission. The method used here is to allow the 127.0.0.1 & ::1 addresses of the Nagios server access. This is defined by adding the following line to pnp4nagios.cfg:

Require ip 127.0.0.1 ::1

The following command will add that line to pnp4nagios.cfg:

sudo sh -c "sed -i '/Require valid-user/a\        Require ip 127.0.0.1 ::1' /etc/apache2/vhosts.d/pnp4nagios.conf"

The Apache apache2 service needs to be restarted for this change to take affect:

sudo systemctl restart apache2.service

Please proceed to the Grafana Configuration section for the next step.

Debian | Raspbian

This documentation works on Debian / Raspbian version 8+. We were unable to get this solution working on versions prior to 8.x.

All steps on Debian require to run as root. To become root simply run:

Debian:

su

Raspbian:

sudo -i

All commands from this point onwards will be as root.

Install Grafana

Please follow the Grafana installation documentation:

http://docs.grafana.org/installation/debian/

Once installed, execute the following commands to start the service and ensure it is enabled to start on boot:

systemctl enable grafana-server.service
systemctl start grafana-server.service

You need to allow port 3000 inbound traffic on the local firewall so you can reach the Grafana web interface.

iptables -I INPUT -p tcp --destination-port 3000 -j ACCEPT

Install PNP Components

Execute these commands to install the PNP4 components for Grafana:

grafana-cli plugins install sni-pnp-datasource
systemctl restart grafana-server.service
cd /usr/local/pnp4nagios/share/application/controllers/
wget -O api.php "https://github.com/lingej/pnp-metrics-api/raw/master/application/controller/api.php"

Grant localhost Permission To PNP4Nagios Site

Grafana will be making calls to the PNP API and will require permission. The method used here is to allow the 127.0.0.1 & ::1 addresses of the Nagios server access. This is defined by adding the following line to pnp4nagios.cfg:

Require ip 127.0.0.1 ::1

The following command will add that line to pnp4nagios.cfg:

sed -i '/Require valid-user/a\        Require ip 127.0.0.1 ::1' /etc/apache2/sites-enabled/pnp4nagios.conf

The Apache apache2 service needs to be restarted for this change to take affect:

systemctl restart apache2.service

Please proceed to the Grafana Configuration section for the next step.

Fedora

Install Grafana

Please follow the Grafana installation documentation:

http://docs.grafana.org/installation/rpm/

Once installed, execute the following commands to start the service and ensure it is enabled to start on boot:

systemctl enable grafana-server.service
systemctl start grafana-server.service

You need to allow port 3000 inbound traffic on the local firewall so you can reach the Grafana web interface:

firewall-cmd --zone=FedoraServer --add-port=3000/tcp
firewall-cmd --zone=FedoraServer --add-port=3000/tcp --permanent

Install PNP Components

Execute these commands to install the PNP4 components for Grafana:

grafana-cli plugins install sni-pnp-datasource
systemctl restart grafana-server.service
cd /usr/local/pnp4nagios/share/application/controllers/
wget -O api.php "https://github.com/lingej/pnp-metrics-api/raw/master/application/controller/api.php"

Grant localhost Permission To PNP4Nagios Site

Grafana will be making calls to the PNP API and will require permission. The method used here is to allow the 127.0.0.1 & ::1 addresses of the Nagios server access. This is defined by adding the following line to pnp4nagios.cfg:

Require ip 127.0.0.1 ::1

The following command will add that line to pnp4nagios.cfg:

sed -i '/Require valid-user/a\        Require ip 127.0.0.1 ::1' /etc/httpd/conf.d/pnp4nagios.conf

The Apache httpd service needs to be restarted for this change to take affect:

systemctl restart httpd.service

Please proceed to the Grafana Configuration section for the next step.

Arch Linux

Install Grafana

Please follow these instructions to install Grafana:

pacman --noconfirm -Syyu
pacman --noconfirm -S grafana

Once installed, execute the following commands to start the service and ensure it is enabled to start on boot:

systemctl enable grafana.service
systemctl start grafana.service

Arch Linux does not have a firewall enabled in a fresh installation. Please refer to the Arch Linux documentation on allowing TCP port 3000 inbound.

Install PNP Components

Execute these commands to install the PNP4 components for Grafana:

grafana-cli plugins install sni-pnp-datasource
systemctl restart grafana.service
cd /usr/local/pnp4nagios/share/application/controllers/
wget -O api.php "https://github.com/lingej/pnp-metrics-api/raw/master/application/controller/api.php"

Grant localhost Permission To PNP4Nagios Site

Grafana will be making calls to the PNP API and will require permission. The method used here is to allow the 127.0.0.1 & ::1 addresses of the Nagios server access. This is defined by adding the following line to pnp4nagios.cfg:

Require ip 127.0.0.1 ::1

The following command will add that line to pnp4nagios.cfg:

sed -i '/Require valid-user/a\        Require ip 127.0.0.1 ::1' /etc/httpd/conf/extra/pnp4nagios.conf

The Apache httpd service needs to be restarted for this change to take affect:

systemctl restart httpd.service

Please proceed to the Grafana Configuration section for the next step.

Gentoo

Install Grafana

Please follow these instructions to install Grafana:

emerge --sync
echo ">=www-apps/grafana-bin-5.0.0 " >> /etc/portage/package.accept_keywords
emerge --noreplace www-apps/grafana-bin

Once installed, execute the following commands to start the service and ensure it is enabled to start on boot:

rc-update add grafana default
rc-service grafana start

Gentoo does not have a firewall enabled in a fresh installation. Please refer to the Gentoo documentation on allowing TCP port 3000 inbound.

Install PNP Components

Execute these commands to install the PNP4 components for Grafana:

grafana-cli plugins install sni-pnp-datasource
ln -s /var/lib/grafana/plugins/sni-pnp-datasource /usr/share/grafana/data/plugins
rc-service grafana restart
cd /usr/local/pnp4nagios/share/application/controllers/
wget -O api.php "https://github.com/lingej/pnp-metrics-api/raw/master/application/controller/api.php"

Grant localhost Permission To PNP4Nagios Site

Grafana will be making calls to the PNP API and will require permission. The method used here is to allow the 127.0.0.1 & ::1 addresses of the Nagios server access. This is defined by adding the following line to pnp4nagios.cfg:

Require ip 127.0.0.1 ::1

The following command will add that line to pnp4nagios.cfg:

sed -i '/Require valid-user/a\        Require ip 127.0.0.1 ::1' /etc/apache2/vhosts.d/pnp4nagios.conf

The Apache apache2 service needs to be restarted for this change to take affect:

rc-service apache2 restart

Please proceed to the Grafana Configuration section for the next step.

FreeBSD

Install Grafana

Please follow these instructions to install Grafana:

pkg install -y grafana4

Once installed, execute the following commands to start the service and ensure it is enabled to start on boot:

echo 'grafana_enable="YES"' >> /etc/rc.conf
service grafana onestart

FreeBSD does not have a firewall enabled in a fresh installation. Please refer to the FreeBSD documentation on allowing TCP port 3000 inbound.

Install PNP Components

Execute these commands to install the PNP4 components for Grafana:

grafana-cli plugins install sni-pnp-datasource
service grafana onerestart
cd /usr/local/pnp4nagios/share/application/controllers/
wget -O api.php "https://github.com/lingej/pnp-metrics-api/raw/master/application/controller/api.php"

Grant localhost Permission To PNP4Nagios Site

Grafana will be making calls to the PNP API and will require permission. The method used here is to allow the 127.0.0.1 & ::1 addresses of the Nagios server access. This is defined by adding the following line to pnp4nagios.cfg:

Require ip 127.0.0.1 ::1

The following command will add that line to pnp4nagios.cfg:

perl -ni.bak -le 'print; print "        Require ip 127.0.0.1 ::1" if /Require valid-user/' /usr/local/etc/apache24/Includes/pnp4nagios.conf

The Apache apache2 service needs to be restarted for this change to take affect:

service apache24 onerestart

Please proceed to the Grafana Configuration section for the next step.

Grafana Configuration

Grafana needs to be configured to use the PNP4Nagios API. Open your web browser to the following URL:

http://nagios_server:3000

Replace nagios_server with the DNS record or ip address of your Nagios Core server.

You will be prompted with a login page, the default username is admin and the password is admin.

You will be presented with the Home Dashboard and you'll see an Add data source icon, click it to continue.

On the next screen click the PNP button:

You will need to populate the following information:

  • HTTP
    • URL: http://localhost/pnp4nagios
    • Access: proxy
  • Auth: Leave settings as default (nothing selected)
    • IF you are using RHEL 6 | CentOS 6 | Oracle Linux 6
      • Tick the box Basic Auth
      • Under Basic Auth Details populate the username and password as per the steps earlier (grafana / ANAFARG)

Once populated click the Save & Test button. When the screen refreshes, if all settings are correct you will be notified that the Data source is working.

The next step is to create a dashboard & graph.

Create Dashboard + Graph

Now that Grafana has been configured you need to create a dashboard and then add a graph to the dashboard.

On the left navigation men hover over the + icon and select Create > Dashboard.

This creates an empty dashboard that needs panels added to it, this example will add a Graph panel.

An empty graph is added to the dashboard, to add data points to the graph click the Panel Title and select Edit.

This opens the editor interface for the panel. At the bottom you can see a list of tabs and the Metrics tab is selected by default. On this tab you will be able to add metric(s) to the graph using queries. This example is going to show you how create a graph for the localhost object that has the Current Load service. This is being used because the Current Load service has three separate data sources that need to be added to the graph.

  • Metrics tab
    • Next to Host click select host and select localhost
    • Next to Service click select service and select Current Load
    • Next to Label click select performance label and select load1
    • You will now see this metric has been added to the graph**
      **
    • Underneath this query click the Add Query button
    • Repeat the steps above to add the load5 and load15 metrics
  • General Tab
    • Give it the title localhost Current Load

After making those choices click the Back to dashboard button at the top right of the screen. You will exit the edit mode and the graph will now appear with the metrics you just added.

Click the Save icon in the top right corner of the screen and provide a name when prompted.

This completes the steps required for using Grafana With PNP4Nagios on Nagios Core.

Additional Reading

To get the most out of Grafana and PNP4Nagios you should check out the documentation:

http://docs.grafana.org/guides/getting_started/

https://github.com/sni/grafana-pnp-datasource

Final Thoughts

For any support related questions please visit the Nagios Support Forums at:

http://support.nagios.com/forum/

Nagios Enterprises, LLC

© All rights reserved. 2026