About NagiosGrapher (v1.7.1)

NagiosGrapher is a tool that fits in with Nagios and adds graphing capabilities. Anything that is reported by a Nagios check can be graphed. The software is available from NagiosForge.

NagiosGrapher uses RRDTool to maintain its data, so space is not typically an issue – old data that falls off the graph is not kept any longer. For example, details reported every 15 minutes don’t have to be kept beyond about 48 hours (two days).

Graphs are available for daily, weekly, monthly, and yearly reports.

If you install NagiosGrapher under a Red Hat system, you may have to tell it to use layout “red_hat” (as the automatic tool may discover “redhat” instead of “red_hat”). Once installed, there are a number of files and directories created.

/etc/init.d/nagios_grapher

This is the startup script for NagiosGrapher. Make sure that the location of the daemon is set correctly; I had to change it to read this way:

DAEMON=/usr/lib/nagios/plugins/contrib/collect2.pl

The script as delivered does not support Red Hat’s chkconfig utility; add these lines to make it support chkconfig (just under the top line):

#
# chkconfig: 345 99 01
# description: NagiosGrapher

Then these commands need to be run to activate NagiosGrapher:

# chkconfig --add nagios_grapher
# chkconfig nagios_grapher on

Next time the system starts NagiosGrapher should start as well.

/etc/nagios/ngraph.ncfg

This is the general configuration file for NagiosGrapher itself. Perhaps the main thing to edit in this file is the option log_level (a bit-mapped value). This may be set high initially. I have it set to 63; it could probably be reduced further.

/var/log/nagios/ngraph.log

This is where the NagiosGrapher log is stored. The log details the operations of NagiosGrapher and the amount of detail is directly related to the log_level value in /etc/nagios/ngraph.ncfg.

/var/log/nagios/service-perfdata*

These files are the performance data stored by Nagios. These are actually Nagios files (not NagiosGrapher files) but are read by NagiosGrapher to create its information. If these start building up, then NagiosGrapher is not reading them appropriately; it may be worthwhile to restart the service using the initiliazation script.

/etc/nagios/ngraph.d

This directory contains the graph configuration. This configuration data is used to create the actual graphs. Many of these items will directly correlate with RRDTool commands and their options.

The defaults are set in nmgraph.ncfg, and the specific graphs can be found under the templates directory. To disable a graph configuration, just add the word _diabled on the end. Presumably this works because the file no longer ends in .ncfg (the standard NagiosGrapher configuration file ending). Likewise, to enable a disabled configuration remove the _disabled from the end of it (and make sure it ends in .ncfg.

/etc/nagios/serviceext

This is a directory where NagiosGrapher stores appropriate configurations for each host that it reads from the performance data that it handles. These files are created automatically; to get the configuration to be loaded into Nagios, Nagios must be reloaded.

/usr/lib/nagios/plugins/contrib/

NagiosGrapher adds several files to this directory: udpecho, fifo_write.pl, fifo_write, collect2.pl, and the directory perl (which contains library files for NagiosGrapher). The most notable of these is collect2.pl: this is the actual program that runs and which scans the performance data for appropriate details.

/usr/lib/nagios/cgi/

NagiosGrapher adds several files to this directory as well: graphs.cgi, rrd2-graph.cgi, and rrd2-system.cgi.

I found that rrd2-system.cgi would not work: it would not present any PNG graphs. Adding this “fix” took care of the problem:

--- rrd2-system.cgi     2009-02-04 15:34:39.000000000 -0600
+++ /usr/lib/nagios/cgi/rrd2-system.cgi 2009-02-04 18:47:23.000000000 -0600
@@ -97,6 +97,7 @@
        $image_bin =~ s/^(\[.*?\])//;
 }

+if (1 == 0) {
 if ($image_format eq 'PNG' && $code == 0 && !$only_graph && !$no_legend) {
        $ng->time_need(type => 'start');
        # Adding brand
@@ -128,6 +129,7 @@
                $image_bin = $blobs[0];
        $ng->time_need(type => 'stop', msg => 'Adding PerlMagick');
 }
+}

 # no buffered operations
 STDOUT->autoflush(1);

It is rather a brute force fix, but I didn’t want to haggle with it. The fix just removes some stuff that isn’t needed for working operation of NagiosGrapher. It would have been nice to actually fix the problem, though.

/var/lib/nagios/rrd/

This is where the RRDTool files are kept. All RRD files are kept in a directory by hostname, and each has a hexadecimal name with the extension .rrd. The seemingly random names are correlated to services by the file index.ngraph, also in this directory.

Powered by ScribeFire.

5 thoughts on “About NagiosGrapher (v1.7.1)”

  1. Dear,

    I am newbie to Nagios, I have installed NagiosGrapher and it is working fine for Active Check for following services;

    Ping
    WWW
    CPU
    Memory
    Disk Space Availability

    But I couldn’t make it working for passive checks since passive checks send data in different form.

    Hope I am writing at accurate place where I am sure get update.

    Thanks,
    Sajnay Santoki

    1. NagiosGrapher depends on the performance output being present in a Nagios plugin. You can see this data when you run a plugin: it comes after the vertical bar (|) in the plugin output. If there is no vertical bar, then no performance output is being generated.

      If there is no plugin output, then there will be no data for NagiosGrapher and thus no graph. In my experience, this is the most common problem. This page in the Nagios 3.0 manual describes the format of passive checks in more detail.

  2. Hello,

    Output is coming but it is different than normal output since it has been generated by NSCA client (NSClient). Is there any way to define the output format for NSCA results?

    Thanks,
    Sanjay Santoki

Leave a comment