Documente Academic
Documente Profesional
Documente Cultură
Article Number: 803 | Rating: Unrated | Last Updated: Sun, Mar 18, 2018 at 8:16 PM
Na g io s C o r e - Us ing G r a f a na W it h P NP 4 Na g io s
This documentation explains how to install and configure G r a fa na to generate performance graphs with an existing PNP4Nagios solution. This guide relies on having installed and
configured PNP4Nagios using the following documentation:
If you don't have PNP4Nagios installed and want to use Grafana then you might be interested in this alternate solution:
I MP O RTANT
D O NO T fo llo w this guide if yo u are us ing Nagio s XI. This guide is intended fo r Nagio s Co re o nly.
This guide is broken up into several sections and covers different Linux distributions and operating systems (OS). 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.
N o te : This guide is based on Nagios Core being installed using the following KB article:
CentOS
Oracle Linux
Ubuntu
Debian
Raspbian
Fedora
Arch Linux
Gentoo
FreeBSD
C e nt O S | RHEL | O r a c le L inux
This documentation works on CentOS / RHEL / Oracle Linux version 6+. We were unable to get this solution working on versions prior to 6.x.
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:
You need to allow port 3000 inbound traffic on the local firewall so you can reach the Grafana web interface:
Ins t all P NP C o m p o ne nt s
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.
The following command will add the user grafana with the password ANAFARG to htpasswd.users:
Please proceed to the Grafana Configuration section for the next step.
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:
The Apache httpd service needs to be restarted for this change to take affect:
Please proceed to the Grafana Configuration section for the next step.
Ub unt u
This documentation works on Ubuntu version 16+. We were unable to get this solution working on versions prior to 16.x.
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.
Ins t all P NP C o m p o ne nt s
Ins t all P NP C o m p o ne nt s
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:
The Apache apache2 service needs to be restarted for this change to take affect:
Please proceed to the Grafana Configuration section for the next step.
S US E S L ES | o p e nS US E L e a p
This documentation was tested on SUSE SLES 12.2+ and openSUSE Leap 42.2+.
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:
You need to allow port 3000 inbound traffic on the local firewall so you can reach the Grafana web interface:
Ins t all P NP C o m p o ne nt s
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:
The Apache apache2 service needs to be restarted for this change to take affect:
De b ia n | Ra s p b ia n
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
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:
You need to allow port 3000 inbound traffic on the local firewall so you can reach the Grafana web interface.
Ins t all P NP C o m p o ne nt s
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:
The Apache apache2 service needs to be restarted for this change to take affect:
Please proceed to the Grafana Configuration section for the next step.
Fe d o r a
Ins t all G r af ana
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:
Ins t all P NP C o m p o ne nt s
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:
The Apache httpd service needs to be restarted for this change to take affect:
Please proceed to the Grafana Configuration section for the next step.
A r c h L inux
Ins t all G r af ana
Once installed, execute the following commands to start the service and ensure it is enabled to start on boot:
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.
Ins t all P NP C o m p o ne nt s
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:
The Apache httpd service needs to be restarted for this change to take affect:
The Apache httpd service needs to be restarted for this change to take affect:
Please proceed to the Grafana Configuration section for the next step.
G e nt o o
Ins t all G r af ana
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:
Gentoo does not have a firewall enabled in a fresh installation. Please refer to the Gentoo documentation on allowing TCP port 3000 inbound.
Ins t all P NP C o m p o ne nt s
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:
The Apache apache2 service needs to be restarted for this change to take affect:
Please proceed to the Grafana Configuration section for the next step.
Fr e e B S D
Ins t all G r af ana
Once installed, execute the following commands to start the service and ensure it is enabled to start on boot:
FreeBSD does not have a firewall enabled in a fresh installation. Please refer to the FreeBSD documentation on allowing TCP port 3000 inbound.
Ins t all P NP C o m p o ne nt s
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:
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:
Please proceed to the Grafana Configuration section for the next step.
G r a f a na C o nf ig ur a t io n
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 Ad d d a ta s o ur c e icon, click it to continue.
You will need to populate the following information:
Name: PNP
Type: PNP
HTTP
URL: http://localhost/pnp4nagios
Access: proxy
Auth: Leave settings as default (nothing selected)
IF you are using CentOS | RHEL | Oracle Linux 6.x
Tick the box B a s ic Auth
Under B a s ic Auth De ta ils populate the username and password as per the steps earlier (grafana / ANAFARG)
Once populated click the S a ve & T e s t button. When the screen refreshes, if all settings are correct you will be notified that the Da ta s o ur c e is w o r king .
C r e a t e Da s hb o a r d + G r a p h
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 C r e a te > Da s hb o a r d .
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 P a ne l T itle and select Ed it .
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
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 lo c a lho s t object that has the C ur r e nt Lo a d 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 Ho s t click s e le c t ho s t and select lo c a lho s t
Next to S e r vic e click s e le c t s e r vic e and select C ur r e nt Lo a d
Next to La b e l click s e le c t p e r fo r ma nc e la b e l and select lo a d 1
You will now see this metric has been added to the graph
Underneath this query click the Ad d Q ue r y button
Repeat the steps above to add the lo a d 5 and lo a d 15 metrics
General Tab
Give it the title lo c a lho s t C ur r e nt Lo a d
After making those choices click the B a c k to d a s hb o a r d 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 S a ve icon in the top right corner of the screen and provide a name when prompted.
Click the S a ve 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.
A d d it io na l Re a d ing
To get the most out of Grafana and PNP4Nagios you should check out the documentation:
http://docs.grafana.org/guides/getting_started/
Fina l T ho ug ht s
For any support related questions please visit the Nagios Support Forums at:
http://support.nagios.com/forum/
Posted by: tle a - Wed, Mar 7, 2018 at 5:40 PM. This article has been viewed 1936 times.