Difference between revisions of "Nagios"

From ArchWiki
Jump to: navigation, search
(Configure Nagios)
(Configure Nagios)
Line 23: 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
 +
cp /etc/nagios/source.cfg.sample /etc/nagios/resource.cfg
 +
 
</pre>
 
</pre>
  

Revision as of 15:01, 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
cp /etc/nagios/source.cfg.sample /etc/nagios/resource.cfg

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

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

Change owner/group of the nagios-plugins you installed, for some reason they were all owned by root:root in my installation:

chown -R nagios:nagios /usr/share/nagios

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!