Loading...
 

Minimal environment nagios 2.9 and perfparsed reading from a pipe



Intro


This page shows a example installation with nagios 2.9 compiled with some extra options for perfparse and configured to work out of the box. Base system is Suse 10.2. Everywhere where this is relevant i will try to put a note there.

Compiling and basic setup for nagios 2.9


(should work with other nagios 2.X versions too)

First create a nagios user and group (both called "nagios"):

groupadd nagios
useradd -d /usr/local/nagios -g nagios nagios


Then get the source, unpack it and then run this configure (change the --with-command-group to meet the apache's group):

./configure --prefix=/usr/local/nagios --enable-event-broker --enable-nanosleep \
                --enable-embedded-perl --with-nagios-user=nagios --with-nagios-group=nagios \
                --with-command-user=nagios --with-command-group=www \
                --with-htmurl=/nagios --with-cgiurl=/nagios/cgi-bin --with-perlcache


We need the perl-swithes for perfparse and the prefix for the tutorial, the other things may not be needed at the moment.

If everything went fine, run

make all


If everything went fine, get root and run

make install && make install-init && make install-commandmode && make install-config


Rename all sample config files to make nagios runnable:

cd /usr/local/nagios/etc
for i in *-sample ; do mv $i ${i/-sample/} ; done


Edit the option to filter plugin characters like in FAQ: http://perfparse.de/tiki-view_faq.php?faqId=8#q32Question.

Try to start nagios with

/etc/init.d/nagios start


If something goes wrong - ask the nagios guys :-)

Optionally configure nagios to start at boot-time:
chkconfig -a nagios


Then you should get the default nagios plugins from http://sourceforge.net/project/showfiles.php?group_id=29880Question and compile them:

cd nagios-plugins-1.4.10
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install


Configuring Apache

(based on the original nagios documentation)

Create a file called /etc/apache2/conf.d/nagios.conf with content (this is for Suse 10.X installations. Other distributions may use other config files for apache):

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin

<Directory "/usr/local/nagios/sbin">
    Options ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users
    Require valid-user
</Directory>

Alias /nagios /usr/local/nagios/share

<Directory "/usr/local/nagios/share">
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /usr/local/nagios/etc/htpasswd.users
    Require valid-user
</Directory>


Restart Apache to make the changes take effect:

/etc/init.d/apache2 restart


You should als make apache start at boot:
chkconfig -a apache2


To be able to access the nagios cgis you should uncomment the "authorized_..." options in /usr/local/nagios/etc/cgi.cfg file. Then we create a apache password file:

htpasswd2 -c  /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: 
Re-type new password: 
Adding password for user nagiosadmin


You should now be able to point your browser to http://localhost/nagiosQuestion and see a running nagios system.

Compiling perfparse 1.0


Get perfparse and compile it with:

./configure --prefix=/usr/local/nagios --with-http_image_path=/nagios/images --with-apacheuser=wwwrun
make
make install



Configuring Mysql and Schema load


If not yet done start mysql and make it start at boot time:
/etc/init.d/mysql start
chkconfig -a mysql


create a database called "perfparse" and user called "ppuser" for perfparse and grant permissions:

mysql -u root
mysql> create database perfparse;
mysql> grant all on perfparse.* to ppuser@localhost identified by 'pp_password';
mysql> exit


Load the schema into the database. You can find the schema file in the "scripts" directory in the perfparse source tree:

mysql -uppuser -ppp_password perfparse < mysql_create.sql



Configuring Perfparse(d)


Create a file called /usr/local/nagios/etc/perfparse.cfg with content:

Service_Log = "|/usr/local/nagios/var/serviceperf.log"
Service_Log_Save_Position = "no"

Storage_Modules_Load = "mysql"
DB_User = "ppuser"
DB_Name = "perfparse"
DB_Pass = "pp_password"
DB_Host = "127.0.0.1"
DB_Type = "mysql"


You can create a annotated config file if you execute the commands:
/usr/local/nagios/bin/perfparsed --show_config > /usr/local/nagios/etc/perfparse.cfg.new
mv /usr/local/nagios/etc/perfparse.cfg.new /usr/local/nagios/etc/perfparse.cfg


You should now be able to see the perfparse main menu when you point your browser to http://localhost/nagios/phpui/perfparse.phpQuestion. If you see php code, you should install and activate the php apache module.

Integrating perfparse in nagios


Edit the file /usr/local/nagios/etc/commands.cfg. At the end of the file change the definitions of the commands process-host-perfdata and process-service-perfdata to:


define command{
        command_name    process-host-perfdata
        command_line    /usr/local/nagios/bin/perfparse_nagios_pipe_command.pl \
/usr/local/nagios/var/serviceperf.log "$TIMET$" "$HOSTNAME$" "$HOSTDESC$" "$HOSTOUTPUT$" \
"$HOSTSTATE$" "$HOSTPERFDATA$"
        }


define command{
        command_name    process-service-perfdata
        command_line    /usr/local/nagios/bin/perfparse_nagios_pipe_command.pl \
/usr/local/nagios/var/serviceperf.log "$TIMET$" "$HOSTNAME$" "$SERVICEDESC$" "$SERVICEOUTPUT$" \
"$SERVICESTATE$" "$SERVICEPERFDATA$"
        }


(Nagios config files do not support multiline configuration options. For better readability i habe added Line breaks and marked the line breaks with backslashes: "\". Please remove the backslashes and join the lines there if you want to copy and paste this examples)

In /usr/local/nagios/etc/nagios.cfg change/activate the parameters:

process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata


Now nagios should be able to write to a fifo called /usr/local/nagios/var/serviceperf.log. To create the pipe (fifo) we use a script that also starts the perfparse daemon (perfparsed). The script is located in the "scripts" directory in the perfparse source tree:

cp scripts/perfparsed.sh /etc/init.d/perfparsed
/etc/init.d/perfparsed start
chkconfig -a perfparsed


Now we just need to restart nagios to get all working:
/etc/init.d/nagios restart


If you want to use perfprase from the main nagios menu, then edit /usr/local/nagios/share/side.html:

....
  <tr>
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="logfile-dot"></td>
    <td nowrap>
       <a href="/nagios/cgi-bin/showlog.cgi" target="main" inhibited_MouseOver="switchdot('logfile-dot',1)" 
          inhibited_MouseOut="switchdot('logfile-dot',0)" class="NavBarItem">Event Log</a></td>
  </tr>
  <tr>
    <td width=13><img src="images/greendot.gif" width="13" height="14" name="perfparse-dot"></td>
    <td nowrap>
        <a href="/nagios/phpui/perfparse.php" target="main" inhibited_MouseOver="switchdot('perfparse-dot',1)"
          inhibited_MouseOut="switchdot('perfparse-dot',0)" class="NavBarItem">PerfParse</a></td>
  </tr>
  <tr>
    <td colspan="2" height="10"></td>
  </tr>
</table>
....


(only 4 lines are added, line breaks are added here for better display of the wiki page).

That's all!


The lastest version of perfparse available from sourceforge doesn't seem to contain the perfparsed.sh file in the scripts directory of the source distribution — ScottTFrazer

Contributors to this page: redflo and ScottTFrazer .
Page last modified on Friday 16 of May, 2008 14:03:58 UTC by redflo.

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.