Nagios provides complete monitoring of Linux operating systems and distributions – including operating system metrics, service state, process state, file system usage, and more. When you use Nagios to monitor your Linux environment, you're using one of the most powerful Linux monitoring tools on the planet.
Services
This Tutorial describes how you can monitor “private” services and attributes of Linux/UNIX servers, such as:
Attributes:
- CPU load ,Memory usage ,Disk usage ,Logged in users ,Running processes ,etc.
Private Services:
HTTP ,FTP ,SSH ,SMTP etc.
Installing the Nagios, the system needs to meet the requirements . So install the Web Server (httpd), PHP, compilers and development libraries.
We can Install all packages required in a single command.
yum -y install httpd php gcc glibc glibc-common wget perl gd gd-devel unzip zip
Now we have to create a nagios user and nagcmd group for allowing the external commands to be executed through the web interface, add the nagios and apache user to be a part of nagcmd group.
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
Download latest Nagios Core.
cd /tmp/
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.2.tar.gz
tar -zxvf /tmp/nagios-4.*.tar.gz
cd /tmp/nagios-4.*
Now we have to compile and install Nagios.
./configure --with-nagios-group=nagios --with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
Install and configure Nagios web Interface
Now we Install the Nagios web configuration using the following command
make install-webconf
Now we Run the following command to install a Nagios exfoliation theme
make install-exfoliation
Now we create a user account (nagiosadmin) for logging into the Nagios web interface. Remember the password that you assign to this user – we will need it later.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Now we have to restart Apache web server to make the new settings take effect.
systemctl restart httpd.service
systemctl enable httpd.service
Now to configure Nagios
Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. we will need to make just one change before we proceed.
Now we have to edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your vim editor and change the email address associated with the nagiosadmin contact definition to the address we like to use for receiving alerts.
vi /usr/local/nagios/etc/objects/contacts.cfg
Change the Email address field to receive the notification
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email admin@pcfunda.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
Now we will download Nagios Plugins to /tmp directory
cd /tmp
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
tar -zxvf /tmp/nagios-plugins-*.tar.gz
cd /tmp/nagios-plugins-*
Now we compile and install the Nagios plugins.
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
Now we will start Nagios server .
But before verify sample Nagios configuration files.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are no errors, then we will start the Nagios service
service nagios start
Start Nagios on system startup.
chkconfig nagios on
We have to see now that selinux is either in permissive mode or off.
getenforce
If SELINUX is in enforcing mode we can put it in permissive mode or off
setenforce 0
Now we have to make sure we can access we server through firewall for that we can add rules to firewall using following command .
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --reload
Now we can access the Nagios web interface using the following URL. We will be prompted for the username (nagiosadmin) and password you specified earlier.
http://you-ip-address/nagios
Install Nagios 4.3.2 on Redhat 7 – Home Page
0 on: "How to Install Nagios on CentOS 7 and RHEL 7"