Index.
- Introduction.
- Core installation.
- Nginx configuration.
- Client installation.
- Windows client.
- Nagios configuration.
- Download.
11-Dec-2011: initial release. 18-Jan-2011: Added nginx configuration.
Introduction.
Nagios is a IT infrastructure monitoring program. On the Home Server it can be useful to check the state of the virtual servers and services that are available for your external users. If there is a service problem you can be notified by email, sms or page.
Core installation.
You could install Nagios on it’s own server, but for these articles I will install the Nagios core on the Home Server. Remote instances will be installed on the gateway and the web server. The installation on the server goes like this:
[root@homsrv ~]# pacman -S nagios nagios-nrpe_plugin nagios-plugins resolving dependencies... looking for inter-conflicts... Targets (3): nagios-3.3.1-4 nagios-nrpe_plugin-2.13-1 nagios-plugins-1.4.15-2 Total Download Size: 1.21 MB Total Installed Size: 8.13 MB Proceed with installation? [Y/n] :: Retrieving packages from mbse-extra... nagios-3.3.1-4-i686 947.1K 1877.4K/s 00:00:01 [######################] 100% nagios-nrpe_plugin... 7.5K 2.9M/s 00:00:00 [######################] 100% nagios-plugins-1.4... 279.7K 1306.1K/s 00:00:00 [######################] 100% (3/3) checking package integrity [######################] 100% (3/3) checking for file conflicts [######################] 100% (1/3) installing nagios [######################] 100% --> Sample config files are installed with .sample extension. --> Remember, these are *SAMPLE* config files. You'll need to read --> the documentation for more information on how to actually define --> services, hosts, etc. to fit your particular needs. (2/3) installing nagios-nrpe_plugin [######################] 100% (3/3) installing nagios-plugins [######################] 100% Optional dependencies for nagios-plugins net-snmp: for SNMP checking. [root@homsrv ~]# cd /etc/nagios [root@homsrv nagios]# htpasswd -c htpasswd.users nagiosadmin New password: Re-type new password: Adding password for user nagiosadmin [root@homsrv nagios]# htpasswd htpasswd.users admin New password: Re-type new password: Adding password for user admin [root@homsrv nagios]# htpasswd htpasswd.users mbroek New password: Re-type new password: Adding password for user mbroek [root@homsrv nagios]#
Right after the installation the password file for the web interface was created. To make Nagios known to the httpd server already running on this server add the following line somewhere at the bottom of /etc/httpd/conf/httpd.conf :
Include conf/extra/nagios.conf
In /etc/php/php.ini add the following to the open_basedir = line:
/usr/share/nagios/share/
Then, restart the httpd service.
Nginx configuration.
When you use the nginx webserver the easiest way to run the web interface is to give nagios it’s own domain so you can run a virtual server. Add the FQDN name nagios.wpl.ym to the DNS server with IPv4 address 10.126.160.253 and IPv6 address 2001:1af8:fecf:7ea0::203. Add that IPv6 address to the interface br0 in /etc/rc.conf so that this address is available.
Add the virtual server to /etc/nginx/conf/nginx.conf and reload nginx:
# nagios.wpl.ym
server {
listen 10.126.160.253:80;
listen [2001:1af8:fecf:7ea0::203]:80;
server_name nagios.wpl.ym;
root /usr/share/nagios/share;
access_log logs/nagios_access_log;
error_log logs/nagios_error_log;
auth_basic "Nagios Access";
auth_basic_user_file /etc/nagios/htpasswd.users;
index index.php;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass php;
}
location ~ ^/nagios/cgi-bin/(.*\.cgi)$ {
root /usr/share/nagios/sbin/;
rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_USER $remote_user;
include fastcgi.conf;
fastcgi_pass cgi;
}
# Strange path offsets.
rewrite ^/nagios/images/(.*) /images/$1;
rewrite ^/nagios/stylesheets/(.*) /stylesheets/$1;
}
Client installation.
On the gateway and web server install the nagios remote and plugins like this:
[root@gateway ~]# pacman -S nagios-nrpe nagios-plugins resolving dependencies... looking for inter-conflicts... Targets (2): nagios-nrpe-2.13-1 nagios-plugins-1.4.15-2 Total Download Size: 0.29 MB Total Installed Size: 2.05 MB Proceed with installation? [Y/n] :: Retrieving packages from mbse-extra... nagios-nrpe-2.13-1... 18.7K 596.5K/s 00:00:00 [######################] 100% nagios-plugins-1.4... 279.7K 1288.0K/s 00:00:00 [######################] 100% (2/2) checking package integrity [######################] 100% (2/2) checking for file conflicts [######################] 100% (1/2) upgrading nagios-nrpe [######################] 100% (2/2) upgrading nagios-plugins [######################] 100% [root@gateway ~]#
The nrpe service is called via xinetd, so edit /etc/xinetd.d/nrpe and set the right IP address of the Nagios server in that file. Then restart xinetd:
[root@gateway ~]# rc.d restart xinetd :: Stopping xinetd [DONE] :: Starting xinetd [DONE] [root@gateway ~]#
The only configuration part on the client is that you need to add all the commands that you want to execute. For example on the gateway server add the file /etc/nrpe/conf.d/gateway.cfg:
# gateway commands # command[check_ipv6]=/usr/share/nagios/libexec/check_ping -6 -H 2001:1af8:fe00:2a b::1 -w 250.0,20% -c 1500.0,60% -p5 command[check_users]=/usr/share/nagios/libexec/check_users -w 3 -c 5 command[check_load]=/usr/share/nagios/libexec/check_load -w 5,4,3 -c 10,8,6 command[check_root]=/usr/share/nagios/libexec/check_disk -w 20% -c 10% -p /dev/s da3 command[check_boot]=/usr/share/nagios/libexec/check_disk -w 20% -c 10% -p /dev/s da1 command[check_home]=/usr/share/nagios/libexec/check_disk -w 20% -c 10% -p /dev/s da4 command[check_swap]=/usr/share/nagios/libexec/check_swap -w 40% -c 20% command[check_zombie_procs]=/usr/share/nagios/libexec/check_procs -w 5 -c 10 -s Z command[check_total_procs]=/usr/share/nagios/libexec/check_procs -w 80 -c 100
You can now test these commands from the Home Server like this:
[root@homsrv ~]# /usr/share/nagios/libexec/check_nrpe -H gateway -c check_load OK - load average: 0.00, 0.01, 0.05|load1=0.000;5.000;10.000;0; load5=0.010;4.00 0;8.000;0; load15=0.050;3.000;6.000;0; [root@homsrv ~]#
Windows client.
If you use some windows machines as servers you can install NSClient++ on these machines. Download the .msi installer file and install NSClient++. In the NSCLient++ Configuration screen add the IP address of the Nagios server and select “Enable common check plugins”, “Enable NRPE server (check_nrpe)” and “Enable WMI checks”.
After it is installed you must edit C:\Program Files\NSCLient++\NSC.ini and set allow_arguments=1 in the [nrpe] section. After that you need to restart the NSCLient++ service.
Nagios configuration.
There is a lot of documentation about how to setup and configure a Nagios server. If you start with copies of the sample configuration files you can come far. Of coarse all the configuration files that I have used are in the download archive.
Download.
