When trying out the Nagios server monitoring software on a CentOS machine using the Fedora Quickstart documentation to install it, I was getting "The requested URL /nagios/cgi-bin/trends.cgi was not found on this server" errors when accessing the Reporting -> Trends function. This post looks at the solution.
Nagios needs gd-devel, png-devel and jpeg-devel packages
The issue is that Nagios needs the gd-devel, png-devel and jpeg-devel packages installed in order to generate these graphs. When running the configure command check the output to see if the GD library has been found. If it can’t be found, you’ll see a message like the one below and won’t be able to access any of the scripts that require the GD library.
checking for gdImagePng in -lgd (order 1)... no checking for gdImagePng in -lgd (order 2)... no checking for gdImagePng in -lgd (order 3)... no checking for gdImagePng in -lgd (order 4)... no *** GD, PNG, and/or JPEG libraries could not be located... ********* Boutell's GD library is required to compile the statusmap, trends and histogram CGIs. Get it from http://www.boutell.com/gd/, compile it, and use the --with-gd-lib and --with-gd-inc arguments to specify the locations of the GD library and include files. NOTE: In addition to the gd-devel library, you'll also need to make sure you have the png-devel and jpeg-devel libraries installed on your system. NOTE: After you install the necessary libraries on your system: 1. Make sure /etc/ld.so.conf has an entry for the directory in which the GD, PNG, and JPEG libraries are installed. 2. Run 'ldconfig' to update the run-time linker options. 3. Run 'make clean' in the Nagios distribution to clean out any old references to your previous compile. 4. Rerun the configure script. NOTE: If you can't get the configure script to recognize the GD libs on your system, get over it and move on to other things. The CGIs that use the GD libs are just a small part of the entire Nagios package. Get everything else working first and then revisit the problem. Make sure to check the nagios-users mailing list archives for possible solutions to GD library problems when you resume your troubleshooting.
To install these libraries on a CentOS/Fedora or Red Hat Enterprise Linux box with yum, do this:
yum install gd-devel png-devel jpeg-devel
It will probably have to install a whole bunch of dependencies as well, but when it’s done you can re-configure your Nagios install and make then make install:
./configure --with-command-group=nagcmd
Check the output and you’ll find this about GD this time assuming everything worked OK:
checking for gdImagePng in -lgd (order 1)... no checking for gdImagePng in -lgd (order 2)... yes GD library was found!
and then do the make part of the process:
make all make install
Once make install has finished the scripts should be in place at /usr/local/nagios/sbin and you should be able to view the reports and associated graphs.