Mix
-------
[root@ns ~]# vi /etc/httpd/conf.d/nagios.conf
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER## This file contains examples of entries that need# to be incorporated into your Apache web server# configuration file. Customize the paths, etc. as# needed to fit your system.ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"<Directory "/usr/local/nagios/sbin"># SSLRequireSSL Options ExecCGI AllowOverride None <IfVersion >= 2.3> <RequireAll> Require all granted# Require host 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </RequireAll> </IfVersion> <IfVersion < 2.3> Order allow,deny Allow from all# Order deny,allow# Deny from all# Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </IfVersion></Directory>Alias /nagios "/usr/local/nagios/share"<Directory "/usr/local/nagios/share"># SSLRequireSSL Options None AllowOverride None <IfVersion >= 2.3> <RequireAll> Require all granted# Require host 127.0.0.1# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER## This file contains examples of entries that need# to be incorporated into your Apache web server# configuration file. Customize the paths, etc. as# needed to fit your system.ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"<Directory "/usr/local/nagios/sbin"># SSLRequireSSL Options ExecCGI AllowOverride None <IfVersion >= 2.3> <RequireAll> Require all granted# Require host 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </RequireAll> </IfVersion> <IfVersion < 2.3> Order allow,deny Allow from all# Order deny,allow# Deny from all# Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </IfVersion></Directory>Alias /nagios "/usr/local/nagios/share"<Directory "/usr/local/nagios/share"># SSLRequireSSL Options None AllowOverride None <IfVersion >= 2.3> <RequireAll> Require all granted# Require host 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </RequireAll> </IfVersion> <IfVersion < 2.3> Order allow,deny Allow from all# Order deny,allow# Deny from all# Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </IfVersion></Directory># Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </IfVersion></Directory>Alias /nagios "/usr/local/nagios/share"<Directory "/usr/local/nagios/share"># SSLRequireSSL Options None AllowOverride None <IfVersion >= 2.3> <RequireAll> Require all granted# Require host 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </RequireAll> </IfVersion> <IfVersion < 2.3> Order allow,deny Allow from all# Order deny,allow# Deny from all# Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user </IfVersion></Directory>
-------------------------X---------------------
NRPE on CentOS
Install EPEL Repository
NRPE packages and plugins are available under EPEL yum repository, Enable EPEL repository using one of below commands.
### On CentOS/RHEL - 7 ### rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm ### On CentOS/RHEL - 6 ### rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Step 2 – Install NRPE and Nrpe-plugins
After enabling EPEL repository, use following commands to install NRPE and plugins in your system.
yum --enablerepo=epel -y install nrpe nagios-plugins
We also need to install commands which NRPE executes for monitoring services. Use the following command to get a list of available commands packages. Install the required packages on your remote system.
yum --enablerepo=epel -y list nagios-plugins* Installed Packages nagios-plugins.x86_64 2.2.1-4git.el7 @epel Available Packages nagios-plugins-all.x86_64 2.2.1-4git.el7 epel nagios-plugins-apt.x86_64 2.2.1-4git.el7 epel nagios-plugins-bacula.x86_64 5.2.13-23.1.el7 base nagios-plugins-bonding.x86_64 1.4-3.el7 epel nagios-plugins-breeze.x86_64 2.2.1-4git.el7 epel nagios-plugins-by_ssh.x86_64 2.2.1-4git.el7 epel nagios-plugins-check-updates.x86_64 1.6.18-2.el7 epel nagios-plugins-cluster.x86_64 2.2.1-4git.el7 epel nagios-plugins-dbi.x86_64 2.2.1-4git.el7 epel nagios-plugins-dhcp.x86_64 2.2.1-4git.el7 epel nagios-plugins-dig.x86_64 2.2.1-4git.el7 epel nagios-plugins-disk.x86_64 2.2.1-4git.el7 epel nagios-plugins-disk_smb.x86_64 2.2.1-4git.el7 epel nagios-plugins-dns.x86_64 2.2.1-4git.el7 epel [...]
Step 3 – Configure NRPE
First, we need to edit NRPE configuration file and start the configuration to work properly.
vim /etc/nagios/nrpe.cfg
Add your Nagios server ip with allowed_hosts like below, For example Nagio server ip is 192.168.1.110.
allowed_hosts=127.0.0.1, 192.168.1.110
After adding above entry you will see that Nagios server is able to connect NRPE client. Let add commands to monitor services. Add new commands or update existing commands like below in the same file.
command[check_root_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p / command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
You can add more commands like above as per requirement of monitoring.
Step 4 – Start NRPE Service
After making all changes, reboot NRPE once to read new configuration, Also configure NRPE to autostart on system boot.
sudo systemctl enable nrpe.service sudo systemctl start nrpe.service
Step 5 – Test NRPE from Nagios Server
Login to Nagios server and execute the following command to verify that Nagios server is able to connect to clients NRPE services. On successful connection, it will show version of clients NRPE package. For example, your remote system IP is 192.168.1.20 with NRPE installed.
check_nrpe -H 192.168.1.20 NRPE v3.1
-----------------X--------------------
Adding a Windows host to Nagios Monitoring Server
We will firstly setup the client machine & then will make changes to nagios server. For adding a windows host for monitoring on Nagios, we will need a software called NSClient++. We can download it from https://sourceforge.net/projects/nscplus/files/latest/download, once downloaded we will start the setup by double clicking the downloaded .msi file.
1- Hit ‘Next’ on the first screen, once the installation starts
2- Now, accept the license agreement & hit ‘Next’
3- On the next screen, click on ‘Typical’
4- Leave the following screen as it is & hit ‘Next’
5- Here on this screen, enter the IP address of Nagios server (for us it’s 192.168.0.20) & press ‘Next’
6- Click on ‘Install’ & wait for the installation to complete. Once its complete, hit ‘Finish’
Changes on Nagios server
Once the settings on the client side are complete, we need to make changes to configuration file of nagios. Open the file /usr/local/nagios/etc/nagios.cfg
[root@linuxtechi ~]# vi /usr/local/nagios/etc/nagios.cfg
Uncomment the following line
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
Save file and exit. Next open the file /usr/local/nagios/etc/objects/windows.cfg
[root@linuxtechi ~]# vi /usr/local/nagios/etc/objects/windows.cfg
This file contains a host definition which can be used as a reference to create the host definition for our window client machine. Edit the hostname & IP address to match your own windows machine, below the host definition are some Service Definitions, here we can add more services definition. Make sure that hostname is changed to your windows client name in all the services. Once done making changes, save file & exit.
Now restart your nagios server & check if the windows host has been added or not to nagios for monitoring, by browsing to ‘HOSTS‘ under current status.
Our host has been successfully added to nagios for monitoring. Similarly we can add more servers in nagios for monitoring & once any service is affected, nagios will show the status on web console & will also send an alert notification to email the address mentioned in contacts.cfg file.
-----