Nagios

How to install Nagiosgraph on CentOS 7

Share on Social Media

Learn how to install Nagiosgraph on CentOS 7 with this comprehensive guide. Enhance your Nagios monitoring by adding advanced graphing capabilities. #centlinux #linux #nagios

Problem Statement

Nagios Core has limited native support for graphical representation of metrics. Nagiosgraph is very useful plugin, that extends the functionality of Nagios Core and display historical graphs. Nagiosgraph parses output and performance data collected by Nagios and stores that data in RRD (Round Robin Data) files. Nagiosgraph creates graphs and generates HTML pages with graphical reports from the data.

What is Nagiosgraph?

Nagiosgraph is an add-on for Nagios that provides graphing capabilities for the performance data collected by Nagios. It processes the performance data output from Nagios checks and plugins, stores it, and generates graphs to help visualize trends and metrics over time. Here are some key features of Nagiosgraph:

  1. Performance Data Collection: Captures performance data from Nagios plugins and checks.
  2. Data Storage: Stores the collected data in a format that can be used for generating graphs.
  3. Graphing: Automatically generates graphs from the stored performance data, making it easy to visualize and analyze trends.
  4. Integration with Nagios: Seamlessly integrates with Nagios, providing a web interface to view the graphs alongside Nagios alerts and status information.
  5. Customization: Allows users to customize the appearance and configuration of graphs to suit their monitoring needs.

Nagiosgraph enhances the functionality of Nagios by providing a powerful tool for visualizing performance data, helping administrators to better understand system performance, identify issues, and optimize their infrastructure.

Before moving forward, it is required to have basic concepts of Nagios Core 4. Therefore, it is highly recommended that you should have Learning Nagios – Third Edition (PAID LINK). It will be really helpful for you during your Nagios journey.

Read Also: How to install Nagios on CentOS 8

Nagios Server Specification

In this article, we will install Nagiosgraph plugin to our preconfigured Nagios Core server on CentOS 7.

We have configured a CentOS 7 virtual machine with Nagios Core 4.2 Server and following specifications.

  • CPU – 2.4 Ghz (2 Core)
  • Memory – 1 GB
  • Storage – 20 GB
  • Swap – 2 GB
  • Operating System – CentOS 7.6
  • Nagios Version – Nagios Core 4.4

Install Nagiosgraph on CentOS 7

Access the Nagios Core’s web interface to check its status.

Nagios Server – Current Network Status

Install the prerequisite packages using yum command.

# yum -y install perl-GD php-gd rrdtool-perl rrdtool-php rrdtool perl-CGI perl-Time-HiRes

Create a directory and download Nagiosgraph 1.5.2 (the latest version at the time of this writeup) from Nagiosgraph – Official Page.

# mkdir -p /soft/nagios
# cd /soft/nagios
# wget https://sourceforge.net/projects/nagiosgraph/files/nagiosgraph/1.5.2/nagiosgraph-1.5.2.tar.gz

Extract the contents of Nagiosgraph tarball.

# cd /soft/nagios
# tar xvf nagiosgraph-1.5.2.tar.gz

Check prerequisites and install Nagiosgraph.

# cd /soft/nagios/nagiosgraph-1.5.2
# ./install.pl --check-prereq
# ./install.pl --layout overlay --prefix /usr/local/nagios

During the installation, set the paths as follows:
(If you define the paths correctly, then most of the configurations will be automatically make by Nagiosgraph installer)

Destination directory (prefix)? [/usr/local/nagios]
Location of configuration files (etc-dir)? [/usr/local/nagios/etc/nagiosgraph]
Location of executables? [/usr/local/nagios/libexec]
Location of CGI scripts? [/usr/local/nagios/sbin]
Location of documentation (doc-dir)? [/usr/local/nagios/docs/nagiosgraph]
Location of examples? [/usr/local/nagios/docs/nagiosgraph/examples]
Location of CSS and JavaScript files? [/usr/local/nagios/share]
Location of utilities? [/usr/local/nagios/docs/nagiosgraph/util]
Location of state files (var-dir)? [/var/nagios] /usr/local/nagios/var
Location of RRD files? [/usr/local/nagios/var/rrd]
Location of log files (log-dir)? [/var/nagios] /usr/local/nagios/var
Path of log file? [/usr/local/nagios/var/nagiosgraph.log]
Path of CGI log file? [/usr/local/nagios/var/nagiosgraph-cgi.log]
Base URL? [/nagios]
URL of CGI scripts? [/nagios/cgi-bin]
URL of CSS file? [/nagios/nagiosgraph.css]
URL of JavaScript file? [/nagios/nagiosgraph.js]
URL of Nagios CGI scripts? [/nagios/cgi-bin]
Path of Nagios performance data file? [/tmp/perfdata.log] /usr/local/nagios/var/service-perfdata.log
username or userid of Nagios user? [nagios]
username or userid of web server user? [apache]

Edit /usr/local/nagios/etc/nagios.cfg file and comment (#) all the performance related parameters.

# vi /usr/local/nagios/etc/nagios.cfg

Set following parameters, to enable Nagios to keep history of performance data.

# process nagios performance data using nagiosgraph
process_performance_data=1
service_perfdata_file=/usr/local/nagios/var/service-perfdata.log
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
service_perfdata_file_processing_command=process-service-perfdata-for-nagiosgraph

Edit /usr/local/nagios/etc/objects/commands.cfg.

# vi /usr/local/nagios/etc/objects/commands.cfg

Add following command to to enable storage of performance metrics.

define command {
  command_name process-service-perfdata-for-nagiosgraph
  command_line /usr/local/nagios/libexec/insert.pl
}

Check Nagios configurations now.

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.2.0
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-01-2016
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
        Checked 8 services.
        Checked 1 hosts.
        Checked 1 host groups.
        Checked 0 service groups.
        Checked 1 contacts.
        Checked 1 contact groups.
        Checked 25 commands.
        Checked 5 time periods.
        Checked 0 host escalations.
        Checked 0 service escalations.
Checking for circular paths...
        Checked 1 hosts
        Checked 0 service dependencies
        Checked 0 host dependencies
        Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check

Restart nagios and httpd services to reload new configurations.

# systemctl restart nagios
# systemctl restart httpd

Open URL  http://192.168.229.129/nagios/cgi-bin/showconfig.cgi in the browser, to see the configurations. (Replace the IP address in the URL, with your CentOS 7 Server IP address).

Display Nagios Server Configurations

You can see that Nagiosgraph has been integrated with Nagios Core.

Edit /usr/local/nagios/etc/objects/templates.cfg file.

# vi /usr/local/nagios/etc/objects/templates.cfg

Add following code to define a service graphed-service to be used to display Nagiosgraph graphs.

define service {
name graphed-service
action_url /nagios/cgi-bin/show.cgi?host=$HOSTNAME&service=$SERVICEDESC
onMouseOver='showGraphPopup(this)'
onMouseOut='hideGraphPopup()'
rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME&service=$SERVICEDESC&period=week&rrdopts=-w+450+-j
register 0
}

And append graphed-service in use parameter of the services, for which you want to draw graphs. We have added it to some services, one service syntax is given below for reference.

define service{
        use                             local-service,graphed-service    ; Name of service template to use
        host_name                       localhost
        service_description             HTTP
        check_command                   check_http
        notifications_enabled           0
        }

Restart nagios service.

# systemctl restart nagios

Now, open the Nagios web interface in browser, you may see the small graph icon infront of the services for which you have enabled graphs.

Nagios Server after integrating Nagiosgraph

Click on the graph icon to open graphs’ page.

Nagiosgraph Graph

Adjust the parameters on the top right side panel to draw graphs according to your needs.

We have successfully installed Nagiosgraph plugin for Nagios Core on CentOS 7. PNP4Nagios is another addon to display graphs in Nagios Core server. You might like our next article Install PNP4Nagios on Nagios Core over CentOS 7.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

Final Thoughts

Installing Nagiosgraph on CentOS 7 adds advanced graphing capabilities to your Nagios monitoring setup, allowing you to visualize performance data effectively. By following this guide, you can set up Nagiosgraph smoothly and enhance your system monitoring.

If you need further assistance or prefer professional help with the installation, I’m here to assist! Check out my Fiverr service for expert support in setting up Nagiosgraph and other server-related tasks.

Alaric Bird

Alaric Bird is a seasoned Linux System Administrator with over a decade of experience in managing and optimizing Linux-based servers and infrastructure. Known for his expertise in server deployment, security hardening, and performance tuning, Alaric has a deep understanding of various Linux distributions, including Ubuntu, CentOS, and Red Hat Enterprise Linux. His skills extend to cloud platforms like AWS, where he effectively manages virtual private servers and services. Alaric is also proficient in scripting languages such as Bash and Python, which he uses to automate routine tasks, enhancing efficiency and reliability. With a strong commitment to continuous learning, he stays updated with the latest developments in open-source technologies and best practices. His problem-solving abilities, combined with excellent communication skills, make him a valuable asset to any IT team. In addition to his technical expertise, Alaric is passionate about mentoring junior administrators and fostering a collaborative environment.

View Comments

Share
Published by
Alaric Bird

Recent Posts

Change Apache Document Root in Linux

Learn how to change Apache document root in Linux by following this step-by-step guide. Adjust…

2 weeks ago

How to Change Apache Port in Linux

Discover how to change Apache port in Linux easily. Follow our simple guide to modify…

2 weeks ago

How to Create Virtual Host in Apache Server

Learn how to create a virtual host in Apache Server with this comprehensive guide. Set…

3 weeks ago

10 Practical Tasks for RHCSA Exam with Solutions

Discover 10 practical tasks for the RHCSA exam with step-by-step solutions. Boost your Linux skills…

3 weeks ago

Ultimate Fail2ban Configuration Guide

Discover the ultimate Fail2ban configuration guide. Learn how to set up, customize, and optimize Fail2ban…

3 weeks ago

VPS Server: The Ultimate Guide to Virtual Private Servers

Explore the ultimate guide to VPS servers and learn everything about Virtual Private Servers, including…

4 weeks ago

This website uses cookies.