Skip to content

How to Install Nagiosgraph to Display Graphs in Nagios?

install nagiosgraph

In the previous article, we explained about displaying graphics in Nagios using pnp4nagios. In this article, we will use a Nagiosgraph to display graphs in Nagios.




How to install nagiosgraph to display graphs in Nagios?




Nagiosgraph is an add-on to Nagios to display graphs and was first released in 2004. It is written in Perl, parses output and performance data from Nagios plugins, and stores the data in RRD files. Nagiosgraph displays data in Nagios trends, as pop-ups for hosts and services, or in separate reports. Graphs are generated and managed via CGI scripts, with a small amount of JavaScript and CSS. As of this writing, the last version of Nagiosgraph is 1.5.2. Here is a workflow drawing of nagiosgraph:


Nagiosgraph workflow


Here are the ways to install Nagiosgraph:

1. Install the required packages

Install the required packages based on the OS you are using:



yum install -y rrdtool perl-Time-HiRes php-gd php-xml perl-CPAN rrdtool-perl perl-CGI-*

cd /tmp
tar -xf nagiosgraph-1.5.2.tar.gz
cd nagiosgraph-1.5.2



sudo apt-get update
sudo apt-get install -y rrdtool librrdp-perl php-gd php-xml libcgi-pm-perl librrds-perl

cd /tmp
tar -xf nagiosgraph-1.5.2.tar.gz
cd nagiosgraph-1.5.2



zypper --non-interactive install rrdtool php-gd php-zlib php-sockets rrdtool-devel perl-rrdtool perl-CGI-Session

cd /tmp
tar -xf nagiosgraph-1.5.2.tar.gz
cd nagiosgraph-1.5.2



2. Configure Nagiosgraph

Next, copy the command below to configure files and folders of nagiosgraph:

mkdir /usr/local/nagios/nagiosgraph
mkdir /usr/local/nagios/nagiosgraph/var
mkdir /usr/local/nagios/nagiosgraph/var/rrd
cp -r etc /usr/local/nagios/nagiosgraph/
sed -i "s#/opt/nagiosgraph/etc#/usr/local/nagios/nagiosgraph/etc#g" cgi/*cgi
sed -i "s#/opt/nagiosgraph/etc#/usr/local/nagios/nagiosgraph/etc#g" lib/

cp lib/ /usr/local/nagios/libexec
cp cgi/*.cgi /usr/local/nagios/sbin
cp share/nagiosgraph.css /usr/local/nagios/share
cp share/nagiosgraph.js /usr/local/nagios/share
cp /usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf /usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf.ori
cp /usr/local/nagios/etc/nagios.cfg /usr/local/nagios/etc/nagios.cfg.bkp


Open the file share/nagiosgraph.ssi and change it to be like below script:

<script type="text/javascript" src="/nagios/nagiosgraph.js"></script>


and then copy the file using the below command:

cp share/nagiosgraph.ssi /usr/local/nagios/share/ssi/common-header.ssi
chown nagios:nagios /usr/local/nagios/share/ssi/common-header.ssi


Next, change the /usr/local/nagios/nagiosgraph/etc/nagiosgraph.conf file to be like this:

# Location of output from nagiosgraph data processing
logfile = /usr/local/nagios/nagiosgraph/var/nagiosgraph.log

# Location of output from nagiosgraph CGI scripts
cgilogfile = /usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log

# Location of nagios performance data log file.
perflog = /usr/local/nagios/var/perfdata.log

# Directory in which to store RRD files
rrddir = /usr/local/nagios/nagiosgraph/var/rrd

# File containing regular expressions to identify service and perf data
mapfile = /usr/local/nagios/nagiosgraph/etc/map

# Nagiosgraph CGI URL.
nagiosgraphcgiurl = /nagios/cgi-bin

# JavaScript: URL to the nagiosgraph javascript file.
javascript = /nagios/nagiosgraph.js

# Stylesheet: URL to the nagiosgraph stylesheet.
stylesheet = /nagios/nagiosgraph.css

# Location of showgroup control file (required for showgroup.cgi)
groupdb = /usr/local/nagios/nagiosgraph/etc/groupdb.conf


and then set nagiosgraph file’s permissions using the commands below:

chown -R nagios:nagios /usr/local/nagios/nagiosgraph
chmod 755 /usr/local/nagios/nagiosgraph/var/rrd
touch /usr/local/nagios/nagiosgraph/var/nagiosgraph.log
chmod 664 /usr/local/nagios/nagiosgraph/var/nagiosgraph.log
touch /usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log
chown apache /usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log
chmod 664 /usr/local/nagios/nagiosgraph/var/nagiosgraph-cgi.log


Next, open your browser and insert the URL below:



You should see the display like the image below:

Requirement of nagiosgraph


3. Configure Nagios

Next, edit the /usr/local/nagios/etc/nagios.cfg file like this below script:



After that, copy the nagiosgraph icon:

cp -f share/graph.gif /usr/local/nagios/share/images/action.gif


And then copy the below script and paste it to the /usr/local/nagios/share/side.php file under Trends word:

<li><a href="<?php echo $cfg["cgi_base_url"];?>/trends.cgi" target="<?php echo $link_target;?>">Trends</a>
<li><a href="<?php echo $cfg["cgi_base_url"];?>/show.cgi" target="<?php echo $link_target;?>">Graphs</a></li>
<li><a href="<?php echo $cfg["cgi_base_url"];?>/showhost.cgi" target="<?php echo $link_target;?>">Graphs by Host</a></li>
<li><a href="<?php echo $cfg["cgi_base_url"];?>/showservice.cgi" target="<?php echo $link_target;?>">Graphs by Service</a></li>
<li><a href="<?php echo $cfg["cgi_base_url"];?>/showgroup.cgi" target="<?php echo $link_target;?>">Graphs by Group</a></li>


And the last result of the side.php file is like in the below image:

Copy the scripts below Trends word



4. Integrate Nagios with Nagiosgraph

After that, we want to integrate Nagiosgraph with Nagios. You can choose the method you used to integrate Nagiosgraph with Nagios from the 3 methods below:




If your display is like the below when you want to see the graph in Nagios:

No data in rrd directory /usr/local/nagios/nagiosgraph/var/rrd

No data in rrd directory


Wait longer for the nagiosgraph graph to appear in the browser. But if you feel you have waited a long time but the graphics still don’t appear in the browser, then usually I reboot my server and then the graphics will appear. But if the graph still doesn’t appear, then check the log.




1. Like in pnp4nagios, if you want to reset the graphics, then you just stay in the /usr/local/nagios/nagiosgraph/var/rrd folder and there will be several hosts in that folder. If we want to delete the graphics on the vps1 host then use the following command:

rm -rf /usr/local/nagios/nagiosgraph/var/rrd/localhost/*


2. In nagiosgraph, if Nagios can not monitor the host then there is no graph like in the image below:

Display of nagiosgraph when the host does not connect

While in pnp4nagios, the graph is still displayed even though the host cannot be monitored by Nagios so it might confuse the sysadmin if they have to analyze an event like in the image below:

Display of pnp4nagios when the host can not be monitored by Nagios



Print Friendly, PDF & Email

6 thoughts on “How to Install Nagiosgraph to Display Graphs in Nagios?”

  1. “/usr/local/nagios/etc/objects/vps1/vps1.cfg”
    my client host name is “cl1” , i could not find any file on this path both nagios server and client server . can you help me to resolve this

    1. Hi Harisan,

      Can you see in the log if there is an error between the Nagios server and the client?
      Or you made a mistake while following this tutorial or maybe you have to wait longer for the graph to come out of the client.

      I think there are many reasons why that happens.

    1. Hi Harish,

      I have changed the writing in the third step of this article so that
      it can be more easily understood by the readers of this article.

  2. I followed your instructions for Ubuntu 22.04 Server, AMD64, compiled NagiosĀ® Coreā„¢ 4.4.7. This was very helpful. It made my day. Thank you.
    To make it even better, I recommend:
    add “apt install libcgi-pm-perl” to the Ubuntu part of the description.

    1. Hi Budnick,

      Glad to help.
      And thanks for your suggestion.
      I have already added your command to my article.

Leave a Reply

Your email address will not be published. Required fields are marked *