Difference between revisions of "Nagios"

From ArchWiki
Jump to: navigation, search
(This is a small guide on how to install nagios on arch.)
 
Line 3: Line 3:
 
This was tested using nagios 3.2.0-1, as of Jan 10th, 2010. You will need a web server (I used apache), and php (I used php5)
 
This was tested using nagios 3.2.0-1, as of Jan 10th, 2010. You will need a web server (I used apache), and php (I used php5)
  
Install nagios and nagios-plugins using yaourt:
+
==Tips for install==
  
 +
While root rights may not be necessary to execute all the commands, I suggest you su to root to follow this installation tutorial, if you are in a hurry you can then simply copy-paste the commands below without getting access permission errors.
 +
 +
==Install nagios and nagios-plugins using yaourt==
 +
 +
<pre>
 
yaourt -S nagios nagios-plugins
 
yaourt -S nagios nagios-plugins
 +
</pre>
  
 +
==Configure Nagios==
 
Change the sample config files to "real" config files:
 
Change the sample config files to "real" config files:
 
+
<pre>
 
cp /etc/nagios/cgi.cfg.sample /etc/nagios/cgi.cfg
 
cp /etc/nagios/cgi.cfg.sample /etc/nagios/cgi.cfg
 
cp /etc/nagios/nagios.cfg.sample /etc/nagios/nagios.cfg
 
cp /etc/nagios/nagios.cfg.sample /etc/nagios/nagios.cfg
Line 16: Line 23:
 
cp /etc/nagios/objects/templates.cfg.sample /etc/nagios/objects/templates.cfg
 
cp /etc/nagios/objects/templates.cfg.sample /etc/nagios/objects/templates.cfg
 
cp /etc/nagios/objects/timeperiods.cfg.sample /etc/nagios/objects/timeperiods.cfg
 
cp /etc/nagios/objects/timeperiods.cfg.sample /etc/nagios/objects/timeperiods.cfg
 +
</pre>
  
 
Create htpasswd.users file with any username, ex: nagiosadmin, use any password, ex: secret:
 
Create htpasswd.users file with any username, ex: nagiosadmin, use any password, ex: secret:
  
 +
<pre>
 
htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
 
htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
 +
</pre>
  
Configure Apache
+
==Configure Apache==
 
Edit /etc/httpd/conf/httpd.conf, add the following to the end of the file:
 
Edit /etc/httpd/conf/httpd.conf, add the following to the end of the file:
  
 +
<pre>
 
# nagios
 
# nagios
 
Include /etc/httpd/conf/extra/nagios.conf
 
Include /etc/httpd/conf/extra/nagios.conf
 +
</pre>
  
 
Add the apache user http to the group nagios, otherwise you will get the following error when using nagios: Could not open command file '/var/nagios/rw/nagios.cmd' for update!:
 
Add the apache user http to the group nagios, otherwise you will get the following error when using nagios: Could not open command file '/var/nagios/rw/nagios.cmd' for update!:
  
 +
<pre>
 
usermod -G nagios -a http
 
usermod -G nagios -a http
 +
</pre>
  
Configure Php
+
==Configure Php==
 
Edit /etc/php/php.ini to include /usr/share/nagios in the open_basedir directive, mine looks like this:
 
Edit /etc/php/php.ini to include /usr/share/nagios in the open_basedir directive, mine looks like this:
  
 +
<pre>
 
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps:/etc/webapps:/usr/share/nagios
 
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps:/etc/webapps:/usr/share/nagios
 +
</pre>
  
 
Start nagios:
 
Start nagios:
  
 +
<pre>
 
/etc/rc.d/nagios start
 
/etc/rc.d/nagios start
 +
</pre>
  
 
Start/Restart apache:
 
Start/Restart apache:
  
 +
<pre>
 
/etc/rc.d/httpd restart
 
/etc/rc.d/httpd restart
 +
</pre>
  
 
Now you should be able to access nagios through your webbrowser using the username and password you have created above using htpasswd:
 
Now you should be able to access nagios through your webbrowser using the username and password you have created above using htpasswd:
  
 +
<pre>
 
http://localhost/nagios
 
http://localhost/nagios
 +
</pre>
  
 
Have fun!
 
Have fun!

Revision as of 13:57, 10 January 2010

This is a small guide on how to install nagios on arch.

This was tested using nagios 3.2.0-1, as of Jan 10th, 2010. You will need a web server (I used apache), and php (I used php5)

Tips for install

While root rights may not be necessary to execute all the commands, I suggest you su to root to follow this installation tutorial, if you are in a hurry you can then simply copy-paste the commands below without getting access permission errors.

Install nagios and nagios-plugins using yaourt

yaourt -S nagios nagios-plugins

Configure Nagios

Change the sample config files to "real" config files:

cp /etc/nagios/cgi.cfg.sample /etc/nagios/cgi.cfg
cp /etc/nagios/nagios.cfg.sample /etc/nagios/nagios.cfg
cp /etc/nagios/objects/commands.cfg.sample /etc/nagios/objects/commands.cfg
cp /etc/nagios/objects/contacts.cfg.sample /etc/nagios/objects/contacts.cfg
cp /etc/nagios/objects/localhost.cfg.sample /etc/nagios/objects/localhost.cfg
cp /etc/nagios/objects/templates.cfg.sample /etc/nagios/objects/templates.cfg
cp /etc/nagios/objects/timeperiods.cfg.sample /etc/nagios/objects/timeperiods.cfg

Create htpasswd.users file with any username, ex: nagiosadmin, use any password, ex: secret:

htpasswd -c /etc/nagios/htpasswd.users nagiosadmin

Configure Apache

Edit /etc/httpd/conf/httpd.conf, add the following to the end of the file:

# nagios
Include /etc/httpd/conf/extra/nagios.conf

Add the apache user http to the group nagios, otherwise you will get the following error when using nagios: Could not open command file '/var/nagios/rw/nagios.cmd' for update!:

usermod -G nagios -a http

Configure Php

Edit /etc/php/php.ini to include /usr/share/nagios in the open_basedir directive, mine looks like this:

open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps:/etc/webapps:/usr/share/nagios

Start nagios:

/etc/rc.d/nagios start

Start/Restart apache:

/etc/rc.d/httpd restart

Now you should be able to access nagios through your webbrowser using the username and password you have created above using htpasswd:

http://localhost/nagios

Have fun!