|
|
Forums-> Help-> Step by Step installation guide - Nagios Invokes Perfparse Method
kukulkan
|
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 .
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=\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$
service_perfdata_file_template=\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:
*****************************************************
# '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
}
# '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:
*****************************************************
# Database managment :
# ====================
Use_Storage_Mysql = "yes"
No_Raw_Data = "no"
No_Bin_Data = "no"
# 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.cgi 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.
|
|
|
|
[ Execution time: 0.09 secs ] [ Memory usage: 3.34MB ] [ GZIP Enabled ] [ Server load: 0.01 ]
|