{{Article summary text|A short installation and configuration guide for the service and network monitoring program Nagios}}

+

−

{{Article summary end}}

+

−

+

[http://www.nagios.org/ Nagios] 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.

[http://www.nagios.org/ Nagios] 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.

The following installation and configuration were tested using nagios 3.2.0-1, [[Apache]] web server 2.2.14-2, and [[PHP]]5 5.3.1-3 by [http://bbs.archlinux.org/viewtopic.php?id=88461 awayand].

+

The following installation and configuration were tested using nagios 3.2.0-1, [[Apache]] web server 2.2.14-2, and [[PHP]]5 5.3.1-3 by [https://bbs.archlinux.org/viewtopic.php?id=88461 awayand].

==Webserver==

==Webserver==

According to the [http://nagios.sourceforge.net/docs/3_0/about.html official documentation] a webserver is not required, but if you wish to use any of the CGI features then a webserver (apache preferred), PHP ([[Apache#PHP|php-apache]]) for it and the gd library are required. This is assumed for this installation

According to the [http://nagios.sourceforge.net/docs/3_0/about.html official documentation] a webserver is not required, but if you wish to use any of the CGI features then a webserver (apache preferred), PHP ([[Apache#PHP|php-apache]]) for it and the gd library are required. This is assumed for this installation

−

==Installation==

+

===Installation===

−

Install [https://aur.archlinux.org/packages.php?ID=12306 nagios] from the [[AUR]].

+

−

Users may also want to install [https://aur.archlinux.org/packages.php?ID=12307 nagios-plugins].

+

Before installation, it's a good idea to make sure you have prerequisites installed, e.g. if you're using nginx then: nginx, php, php-fpm, fcgiwrap might be a good start.

−

==Nagios Configuration==

+

Install {{AUR|nagios}} from the [[AUR]].

+

+

Users may also want to install {{Pkg|monitoring-plugins}}. When you do, make sure to edit {{ic|/etc/nagios/resource.cfg}} later to reflect the new paths:

+

#$USER1$=/usr/share/nagios/libexec

+

$USER1$=/usr/lib/monitoring-plugins

+

+

===Nagios Configuration===

Copy the sample config files as root:

Copy the sample config files as root:

{{bc|

{{bc|

Line 54:

Line 54:

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

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

}}

}}

+

+

If you do not want to install apache-tools, you can run following command

You can also add a different user, but before you can do anything with it in Nagios, you will need to edit {{ic|/etc/nagios/cgi.cfg}}. You can replace 'nagiosadmin' with the desired user, or, you can append it with comma: nagiosadmin,yourusername,yournextusername etc.

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

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

Line 63:

Line 71:

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

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

−

==Apache Configuration==

+

===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:

{{bc|

{{bc|

+

LoadModule php5_module modules/libphp5.so

+

+

{{Note|cgi scripts failed for me until i uncommented

+

LoadModule cgi_module modules/mod_cgi.so}}

+

# Nagios

# Nagios

Include "conf/extra/nagios.conf"

Include "conf/extra/nagios.conf"

Line 72:

Line 85:

# PHP

# PHP

Include "conf/extra/php5_module.conf"

Include "conf/extra/php5_module.conf"

+

}}

}}

−

{{note| As of 3.4.1-4 the example conf is in etc/webapps/nagios/apache.example.conf }}

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:

−

{{bc|

+

http://localhost/nagios

−

http://localhost/nagios

+

−

}}

+

==Monitor an Archlinux host==

+

You will need {{Pkg|monitoring-plugins}} and {{Pkg|nrpe}} to monitor your host.

+

+

As always when monitoring, the configuration is done in /etc/nrpe/nrpe.cfg and the interesting files to monitor will be in /usr/share/nagios/libexec/ . Do not forget to edit nrpe.cfg as it is mostly empty after install.

==Plugin check_rdiff==

==Plugin check_rdiff==

Line 166:

Line 246:

Quote from the check_rdiff script content:

Quote from the check_rdiff script content:

−

''The above command checks the repository (-r) which is defined as the destination of the backup, or more specifically, the directory above the rdiff-backup-data directory. It will return warning if the backup hasn't finished by 8am and critical by 10am. It will also return warning if the TotalDestinationSizeChange is greater than 500Mb. It also get the period set to 24hrs (-p). This is important as the plugin will throw a critical if the backup doesn't start in time.''

+

''The above command checks the repository (-r) which is defined as the destination of the backup, or more specifically, the directory above the rdiff-backup-data directory. It will return warning if the backup has not finished by 8am and critical by 10am. It will also return warning if the TotalDestinationSizeChange is greater than 500Mb. It also get the period set to 24hrs (-p). This is important as the plugin will throw a critical if the backup does not start in time.''

Finally, restart nagios:

Finally, restart nagios:

−

{{bc|

+

# systemctl restart nagios

−

/etc/rc.d/nagios restart

+

−

}}

+

You can now see the rdiff-backup status by clicking on Services on the left side of the nagios web interface control panel.

You can now see the rdiff-backup status by clicking on Services on the left side of the nagios web interface control panel.

==Forks==

==Forks==

−

*[[Icinga]] is a Nagios fork. More details about the fork can be found at [https://www.icinga.org/faq/why-a-fork/ Icinga FAQ: Why a fork?]

+

*[[Icinga]] is a Nagios fork. More details about the fork can be found at [https://www.icinga.org/icinga/faq/icinga-vs-nagios/ Icinga FAQ: Why a fork?]

+

+

*[[Naemon]] is the new monitoring suite that aims to be faster and more stable, while giving you a clearer view of the state of your network. [http://www.naemon.org/project.html Naemon FAQ: Why a fork?]

==See also==

==See also==

Latest revision as of 16:55, 13 August 2016

Nagios 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.

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

Webserver

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), PHP (php-apache) for it and the gd library are required. This is assumed for this installation

Installation

Before installation, it's a good idea to make sure you have prerequisites installed, e.g. if you're using nginx then: nginx, php, php-fpm, fcgiwrap might be a good start.

You can also add a different user, but before you can do anything with it in Nagios, you will need to edit /etc/nagios/cgi.cfg. You can replace 'nagiosadmin' with the desired user, or, you can append it with comma: nagiosadmin,yourusername,yournextusername etc.

If the owner/group of the nagios-plugins you installed are root:root, 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:

Monitor an Archlinux host

As always when monitoring, the configuration is done in /etc/nrpe/nrpe.cfg and the interesting files to monitor will be in /usr/share/nagios/libexec/ . Do not forget to edit nrpe.cfg as it is mostly empty after install.

Plugin check_rdiff

A small guide on monitoring rdiff-backups using a plugin called check_rdiff.

Edit /etc/nagios/objects/localhost.cfg to include checking of rdiff-backup on localhost, for example:

define service{
use local-service ; Name of service template to use
host_name localhost
service_description rdiff-backup
check_command check_rdiff!/home/x/rdiffbackup!8!10!500!24
}

Quote from the check_rdiff script content:

The above command checks the repository (-r) which is defined as the destination of the backup, or more specifically, the directory above the rdiff-backup-data directory. It will return warning if the backup has not finished by 8am and critical by 10am. It will also return warning if the TotalDestinationSizeChange is greater than 500Mb. It also get the period set to 24hrs (-p). This is important as the plugin will throw a critical if the backup does not start in time.

Finally, restart nagios:

# systemctl restart nagios

You can now see the rdiff-backup status by clicking on Services on the left side of the nagios web interface control panel.