Difference between revisions of "Nagios"

From ArchWiki
Jump to: navigation, search
(Configure Nagios)
(Created introduction, external links, and adjusted layout, more needs to be done (I haven't verified the installation/config guide))
Line 1: Line 1:
This is a small guide on how to install nagios on arch.
+
[Nagios http://www.nagios.org/] is an open source host, service and network monitoring program. It monitors specified hosts and services, alerting you to any developing issues, errors or improvements. This article describes the installation and configuration of Nagios.
  
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==
+
Some of Nagios' features include[http://nagios.sourceforge.net/docs/3_0/about.html#whatis 1]:
 +
*Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
 +
*Monitoring of host resources (processor load, disk usage, etc.)
 +
*Simple plugin design that allows users to easily develop their own service checks
 +
*Parallelized service checks
 +
*Ability to define network host hierarchy using "parent" hosts, allowing detection of and distinction between hosts that are down and those that are unreachable
 +
*Contact notifications when service or host problems occur and get resolved (via email, pager, or user-defined method)
 +
*Ability to define event handlers to be run during service or host events for proactive problem resolution
 +
*Automatic log file rotation
 +
*Support for implementing redundant monitoring hosts
 +
*Optional web interface for viewing current network status, notification and problem history, log file, etc.
  
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==
+
The following installation and configuration were tested using nagios 3.2.0-1, [[Apache]] web server, and [[PHP]]5 by [http://bbs.archlinux.org/viewtopic.php?id=88461 awayand].
 +
 
 +
==Requirements==
 +
From the PKGBUILD: [http://archlinux.org/packages/search/?q=freetype2 freetype2] [http://archlinux.org/packages/search/?q=gd gd] [http://archlinux.org/packages/search/?q=glib2 glib2] [http://archlinux.org/packages/search/?q=libtool libtool].
 +
According to the official documentation a webserver is not required, but if you wish to use any of the CGI features then a webserver (apache preferred) and the gd library are required. This is assumed for this installation
 +
 
 +
==Installation==
 +
Nagios can be found in [http://aur.archlinux.org/packages.php?ID=12306 AUR] (see [[AUR]] and [AUR User Guidelines]]), and any of the [[AUR Helpers]] can be used to build and install Nagios. The below example assumes [Yaourt] is installed.
  
 
<pre>
 
<pre>
yaourt -S nagios nagios-plugins
+
$ yaourt -S nagios nagios-plugins
 
</pre>
 
</pre>
  
==Configure Nagios==
+
==Nagios Configuration==
Change the sample config files to "real" config files:
+
Copy the sample config files as root:
 
<pre>
 
<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
cp /etc/nagios/objects/commands.cfg.sample /etc/nagios/objects/commands.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/contacts.cfg.sample /etc/nagios/objects/contacts.cfg
cp /etc/nagios/objects/localhost.cfg.sample /etc/nagios/objects/localhost.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/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>
  
Create htpasswd.users file with any username, ex: nagiosadmin, use any password, ex: secret:
+
Create htpasswd.users file with a username and password, eg. nagiosadmin and secretpass
  
 
<pre>
 
<pre>
htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
+
# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
 
</pre>
 
</pre>
  
Change owner/group of the nagios-plugins you installed, for some reason they were all owned by root:root in my installation:
+
If the owner/group of the nagios-plugins you installed are root:root, as encountered by andaway the following needs to be done:
  
 
<pre>
 
<pre>
chown -R nagios:nagios /usr/share/nagios
+
# chown -R nagios:nagios /usr/share/nagios
 
</pre>
 
</pre>
  
==Configure Apache==
+
Once Nagios is configured, it is time to configure the webserver.
 +
 
 +
==Apache Configuration==
 
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:
  
Line 47: Line 62:
 
</pre>
 
</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:  
 +
<pre>Could not open command file '/var/nagios/rw/nagios.cmd' for update!:  
 +
</pre>
  
 
<pre>
 
<pre>
usermod -G nagios -a http
+
# usermod -G nagios -a http
 
</pre>
 
</pre>
  
==Configure Php==
+
==PHP Configuration==
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.
 +
 
 +
Example configuration:
  
 
<pre>
 
<pre>
Line 79: Line 98:
  
 
Have fun!
 
Have fun!
 +
 +
==References==
 +
#[http://nagios.sourceforge.net/docs/3_0/about.html#whatis] Description of Nagios
 +
 +
==External Links==
 +
#[http://www.nagios.org/ Nagios] Official website
 +
#[http://www.nagiosplugins.org/ Nagios Plugins] the home of the official plugins
 +
#[[Wikipedia:Nagios] Wikipedia article
 +
*[http://www.nagiosexchange.org NagiosExchange] overview of plugins, addons, mailing lists for Nagios
 +
*[http://www.nagiosforge.org/ NagiosForge] a repository for ad
 +
#[http://www.libgd.org/Main_Page] GD Library homepage, required for image manipulation

Revision as of 15:58, 10 January 2010

[Nagios http://www.nagios.org/] is an open source host, service and network monitoring program. It monitors specified hosts and services, alerting you to any developing issues, errors or improvements. This article describes the installation and configuration of Nagios.


Some of Nagios' features include1:

  • Monitoring of network services (SMTP, POP3, HTTP, NNTP, PING, etc.)
  • Monitoring of host resources (processor load, disk usage, etc.)
  • Simple plugin design that allows users to easily develop their own service checks
  • Parallelized service checks
  • Ability to define network host hierarchy using "parent" hosts, allowing detection of and distinction between hosts that are down and those that are unreachable
  • Contact notifications when service or host problems occur and get resolved (via email, pager, or user-defined method)
  • Ability to define event handlers to be run during service or host events for proactive problem resolution
  • Automatic log file rotation
  • Support for implementing redundant monitoring hosts
  • Optional web interface for viewing current network status, notification and problem history, log file, etc.


The following installation and configuration were tested using nagios 3.2.0-1, Apache web server, and PHP5 by awayand.

Requirements

From the PKGBUILD: freetype2 gd glib2 libtool. According to the official documentation a webserver is not required, but if you wish to use any of the CGI features then a webserver (apache preferred) and the gd library are required. This is assumed for this installation

Installation

Nagios can be found in AUR (see AUR and [AUR User Guidelines]]), and any of the AUR Helpers can be used to build and install Nagios. The below example assumes [Yaourt] is installed.

$ yaourt -S nagios nagios-plugins

Nagios Configuration

Copy the sample config files as root:

# 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 a username and password, eg. nagiosadmin and secretpass

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

If the owner/group of the nagios-plugins you installed are root:root, as encountered by andaway the following needs to be done:

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

Once Nagios is configured, it is time to configure the webserver.

Apache Configuration

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

PHP Configuration

Edit /etc/php/php.ini to include /usr/share/nagios in the open_basedir directive.

Example configuration:

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!

References

  1. [1] Description of Nagios

External Links

  1. Nagios Official website
  2. Nagios Plugins the home of the official plugins
  3. [[Wikipedia:Nagios] Wikipedia article
  1. [2] GD Library homepage, required for image manipulation