Loading...
 

Help


Step by Step installation guide - Nagios Invokes Perfparse Method

Hi all! I've been using Perfparse for several years now, so I've become intimately familiar with how painful it can be to get it configured and running properly. It's a great tool, but the documentation for the project is old, and often poorly formatted or lacking detail. I wanted to add this as a guide within the Wiki, but for now I will settle for posting it here in the forums. Perhaps Redflo can give me permissions to add this as a regular wiki page if it proves to be useful; some markup would really help its readability.

Installation Method:
Nagios invokes Perfparse

Server Environment:
Ubuntu 8.04 Hardy Heron. Kernel - 2.6.24-26-server

Nagios Environment: (compiled manually):
Nagios 3.2.0
Nagios Plugins 1.4.13
NRPE 2.12

Description: Perfparse is invoked through a Nagios command which runs perfparse-log2mysql every time a log is generated.

Pros:
  • No delay between detection of data and parsing of data
  • Smaller risk of losing performance data

Cons:
  • Fork a new process for each line of performance data, which can slow Nagios
  • Nagios and Perfparse are very dependent one upon the other. If one is broken, the other will not work perfectly.

STEP 1: DOWNLOAD & UNPACK PERFPARSE

Obtain the Perfparse source files from the SourceForge project pageQuestion.

Once you've obtained the latest version, unpack it.

Code:
*****************************************************

tar -xvf perfparse-0.106.1.tar.gz

*****************************************************

Step 2. COMPILE PERFPARSE

a.) Now, let's go ahead and configure Perfparse with our desired options.
Here's what I used for my build:

Code:
*****************************************************

./configure prefix=/usr/local/nagios with-image-dir=/usr/local/nagios/share/perfparse/images --with-cgidir=/usr/local/nagios/sbin
with-http_image_path=/usr/local/nagios/share/images with-apache-user=nagios

*****************************************************

and here are the options my Nagios installation was compiled with:

Code:
*****************************************************

with-nagios-user=nagios with-nagios-group=nagios with-command-user=nagiosadmin with-command-group=nagcmd
with-default-perfdata with-htmurl= with-cgiurl=/cgi-bin enable-embedded-perl --with-perlcache

*****************************************************

  • Note: You may have noticed my Perfparse cgidir is set to "/" this is because Nagios is located at the root of my web server (hence the "with-htmurl=" option in my Nagios configuration as well). If you're not sure, you'll probably want to set your "with-cgidir" option to "/nagios" (double-check your Nagios install if you're not sure).

b.) Verify your configure settings by paying close attention to the summary once it completes.

It will look something like this:

Configuration options:

Prefix: /usr/local/nagios
Perfparse: Selected
DB tools: Selected
CGI: Selected
PHP interface: Selected

HTTP path for images: /nagios/images
Installation path for images: ${datadir}/perfparse/images
Installation path for CGIs: /usr/local/nagios/sbin

Using glib2.0: 2.16.6
Database support: mysql
Data source: Nagios

c.) Ok, our configure options look correct so now it's time to compile and install.

Code:
*****************************************************

sudo make && make install

*****************************************************

That's it! We've unpacked, compiled and installed but there's still more work to be done.

STEP 3. COPY EXAMPLE CONFIG FILES TO NAGIOS

  • Note: This step may not be necessary as I believe "make install" places copies in your working Nagios directory, but just in case let's run through it.

Now, we'll be copying over the example Perfparse config files to Nagios. For the Nagios invokes Perfparse method, we really only need to worry about, "perfparse.cfg."

(from your unpacked Perfparse dir)

Code:

*****************************************************

cd config/

sudo cp perfparse.cfg.example /usr/local/nagios/etc/perfparse.cfg

*****************************************************

Step 4. CREATE DATABASE & APPLY THE SCHEMA

a.) Create a database within mySQL (or postgresql), create a user and grant it full access to the new db you created. For the sake of these instructions, we'll assume our db, user & password are all named, "nagios".

b.) Ok now that we've set up the blank DB and user, we need to apply the schema so Perfparse can store the performance data it collects from Nagios.

(again, starting from your unpacked Perfparse dir)

Code:
*****************************************************

cd scripts/

cat mysql_create.sql | mysql -unagios -pnagios -Dnagios

*****************************************************

If you created your DB & user with the same name & password as the example above, you should now see around 18 tables in your DB.

  • Note: If you're using postgresql you'll need to use the postgresql_create.sql script.

STEP 5. ENABLE PERFORMANCE DATA

In order to collect the performance data we need to verify the following settings in the main nagios.cfg file:

Code:
*****************************************************

process_performance_data=1

host_perfdata_command=process-host-perfdata

service_perfdata_command=process-service-perfdata

perfdata_timeout=5

*****************************************************

Now, further down in nagios.cfg let's check the perfdata templates.

If your default templates do not match the examples below, you may need to modify them to match the following:

Code:
*****************************************************

host_perfdata_file_template=HOSTPERFDATA\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$

service_perfdata_file_template=SERVICEPERFDATA\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$

*****************************************************

  • Note: The URL markup in the forum is mangling the command definitions above. Make sure the "HOSTPERFDATA" & "SERVICEPERFDATA" strings are enclosed in brackets.

IMPORTANT NOTE:
If you're using the newer nagios-plugins builds (most likely), the default templates for the performance data in nagios.cfg are probably incorrect. This will cause the performance data to be written incorrectly and Perfparse will insert junk into your db. While this doesn't necessarily break anything, it's not what we want. So double check these settings! This is a common mistake people make when configuring Perfparse.

Step 6. CREATE NAGIOS COMMANDS TO INVOKE PERFPARSE

Next, we need to change a couple more settings in perfparse.cfg and misccommands.cfg and then we're off to the races!

a.) First, modify your misccommands.cfg file and add the following:

  • Note (make sure that you first comment out or replace the default nagios "process-service-hostdata" and "process-host-perfdata" commands with the definitions below).

Code:
*****************************************************

  1. 'process-service-perfdata' command definition
define command {
command_name process-service-perfdata
command_line /usr/bin/printf "%b" "$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEOUTPUT$\t$SERVICESTATE$\t$SERVICEPERFDATA$\n" | /usr/local/nagios/bin/perfparse-log2mysql -c /usr/local/nagios/etc/perfparse.cfg
}

  1. 'process-host-perfdata' command definition
define command {
command_name process-host-perfdata
command_line /usr/bin/printf "%b" "$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$HOSTOUTPUT$\t$SERVICESTATE$\t$HOSTPERFDATA$\n" | /usr/local/nagios/bin/perfparse-log2mysql -c /usr/local/nagios/etc/perfparse.cfg

*****************************************************

You can also substitute the path in your definitions with the $USER2$ resource, just ensure you have it properly set to your Perfparse installation directory in resources.cfg. You'll notice I used the new templates for the printf output in the command definitions too. Basically this tells Nagios how to output the performance data properly and pipe it to the perfparse-log2mysql command, then into the DB.

Finally, we need to ensure perfparse-log2mysql understands where to look for the data and how to insert it into our DB.

Verify the following settings in your perfparse.cfg file.

Code:
*****************************************************

Service_Log = "-"


*****************************************************

(remember, we're piping the data from Nagios directly into perfparse-log2mysql so just set the service log location to stdin.)

Near the bottom, make sure you've defined the proper settings to allow Perfparse to find and connect to the database we created earlier.

Code:
*****************************************************

  1. Database managment :
  2. ========
Use_Storage_Mysql = "yes"

No_Raw_Data = "no"
No_Bin_Data = "no"

  1. Database Authentication
DB_User = "nagios"
DB_Name = "nagios"
DB_Pass = "nagios"
DB_Host = "127.0.0.1"

*****************************************************

If you'd like, you can also customize your Perfparse error, drop and output log settings now.

Step 7. RESTART NAGIOS AND VERIFY PERFPARSE INSTALLATION

The last step is to restart Nagios and check to ensure Perfparse is working properly.

Code:

*****************************************************

sudo /etc/init.d/nagios restart


*****************************************************
Now point your browser to http://servername/cgi-bin/perfparse.cgiQuestion and hopefully you will see the Perfparse interface. As service checks fire off in Nagios, the graphs and raw output in Perfparse should begin updating automatically. Congratulations, you've successfully configured Perfparse!

STEP 8. CONCLUSION

The Nagios invokes Perfparse method isn't the most efficient, but it is probably the easiest to configure. Hopefully this guide will help others save some time. Please feel free to edit and improve on this guide. I know I didn't cover everything so I’d be happy to see refinements, additions and feeback. It could probably use a brief section on DB maintenance and how to add a link to Perfparse within Nagios, but I'll leave those items for another time.
Hi kukulkan!

I've just downloaded the latest CVS snapshot (perfparse-10-09-17.tar.bz2) and it has no "configure" file at all. I tried to build one with autoconf configure.ac >configure but when the resulting configure file runs it says:
./configure: line 3101: AC_LIBTOOL_DLOPEN: command not found
./configure: line 3102: AC_PROG_LIBTOOL: command not found
./configure: line 3116: syntax error near unexpected token `COND_PERFPARSE,'
./configure: line 3116: `AM_CONDITIONAL(COND_PERFPARSE, test "x${ENABLE_PERFPARSE}" != "xno" )'

and does nothing. Any advice?

Thanks!

P.S. I ran
libtoolize --force
aclocal --force
autoconf configure.ac >configure
and the result was mich better but still got the following error message from configure:
./configure: line 19558: syntax error near unexpected token `${ZLIB_DIR}/lib,z,gzopen,,'
./configure: line 19558: `AX_CHECK_LIB_DIR(${ZLIB_DIR}/lib,z,gzopen,,'
So I had to cut off these 3 lines from configure:
AX_CHECK_LIB_DIR(${ZLIB_DIR}/lib,z,gzopen,,
AC_SUBST(ZLIB_CFLAGS)
AC_SUBST(ZLIB_LIBS),AC_MSG_ERROR("zlib not found or unusable. Install zlib development files and rerun configure"))
and configuring came to almost the end but stuck again here:
config.status: creating intl/Makefile
config.status: creating po/Makefile.in
config.status: creating po/POTFILES
config.status: creating m4/Makefile
config.status: error: cannot find input file: m4/Makefile.in

Any ideas?

P.P.S. After trying to figure out a proper way to install PerfParse for 2 days I finally gave up and switched to another software.
 

Shoutbox

redflo, 14:25 UTC, Sun 10 of Apr, 2005: No, lneuxyuhje, this shall write to a pipe not to a file and so ">" is o.k.
lneuxyuhje, 15:14 UTC, Thu 07 of Apr, 2005: is ">" meant to be ">>" in /usr/local/perfparse/bin/perfparse_nagios_pipe_command.pl ?
redflo, 08:35 UTC, Tue 05 of Apr, 2005: fhdplbvjipsld, it works now. Permissions were wrong.
fhdplbvjipsld, 14:42 UTC, Wed 30 of Mar, 2005: How to post to Forums->Help?
benclewett, 09:27 UTC, Thu 03 of Feb, 2005: Hi Jon! I hope you like our wiki site.