This is Part-1 of complete article How to Setup Nagios Monitoring Server with NagiosQL on CentOS/RHEL 7/6, In this part, you will find the steps to setup Nagios Monitoring Server on CentOS, Redhat, and Fedora systems.
Step 1 – Install Required Packages
We assume that you have fresh installed CentOS, Red Hat or Fedora systems, So our first requirement is to install Apache and PHP first. Use the following commands to complete it. You can find detailed LAMP setup instruction here.
Install Packages:
yum install httpd php php-cli gcc unzip wget glibc glibc-common gd gd-devel net-snmp
Start Services:
service httpd start
Step 2 – Setup User Accounts
Now create a new nagios user account and setup a password to this account
useradd nagios passwd nagios
Now create a groud for nagios setup “nagcmd” and add nagios user to this group. Also add nagios user in apache group.
groupadd nagcmd usermod -a -G nagcmd nagios usermod -a -G nagcmd apache
Step 3 – Install Nagios Core Service
After installing the required dependencies and adding user accounts. Let’s start with the Nagios core installation. Download the latest Nagios core service from the official site.
cd /opt/ wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz tar xzf nagios-4.4.5.tar.gz cd nagios-4.4.5 ./configure --with-command-group=nagcmd make all make install make install-init make install-daemoninit make install-config make install-commandmode make install-exfoliation
Now use below command to setup Apache configuration for Nagios installation.
make install-webconf
Step 4 – Configure Apache Authentication
We need to setup apache authentication for user nagiosadmin. Do not change this username. else you would required more changes in configuration.
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Now restart Apache service to make the new settings take effect.
service httpd restart
Step 5 – Install Nagios Plugins
After installing and configuring Nagios core service, Download latest nagios-plugins source and install using the following commands.
cd /opt wget http://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz tar xzf nagios-plugins-2.2.1.tar.gz cd nagios-plugins-2.2.1
Now compile and install nagios plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios make make install
Step 6 – Verify and Start Nagios
First, verify the Nagios configuration file using the following command.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there is no error, let’s start the Nagios serivce
service nagios start
Step 7 – Access Nagios in Web Browser
Nagios creates its own apache configuration file /etc/httpd/conf.d/nagios.conf. There are no need to make any changes to it. Simply open below url in browser.
http://nagios.tecadmin.net/nagios/
Prompting for Apache Authentication Password –
Nagios After login screen –
Finally, you have successfully installed and configured Nagios core service in your system. Now go to article install NagiosQL3 web interface for managing Nagios.
Great information shared. Adding a few lines about Nagios, ” Nagios provides complete monitoring of Linux operating systems and distributions – including operating system metrics, service state, process state, file system usage, and more.”
Awesome!. Perfect guide.
Your first step successfully done[How to Install Nagios 4 (Monitoring Server) on CentOS/RHEL 7/6] & its very helpful to understand. Would u plz tell me process, how to add host? & what another services are need to installed ? Plz Note I am using centos7 .
Reagards
This is just a simple guide, but check some examples.
–Open this file
nano /usr/local/nagios/etc/nagios.cfg
—search and uncoment
#cfg_file=/usr/local/nagios/etc/objects/switch.cfg
—to
cfg_file=/usr/local/nagios/etc/objects/switch.cfg
—close file
—Open and add these command below (host and 2 services to monitoring)
nano /usr/local/nagios/etc/objects/switch.cfg
define host{
use generic-switch
host_name switchcore01
alias swtich main num 1
address 10.10.10.3
hostgroups switches
}
define service{
use generic-service
host_name switchcore01
service_description PING
check_command check_ping!200.0,20%!600.0,60%
normal_check_interval 5
retry_check_interval 1
}
define service {
use generic-service
host_name switchcore01
service_description Uptime
check_command check_snmp!-C MYCOMMUNITYHERE -o sysUpTime.0
}
—-close the file
—–checck the config
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
— now reload the service
sudo service nagios reload
—-You can see on the web browser.
Regards
am getting some warning while installing Nagios in centos through putty
Hi Rahul, may I know what is port number RRD database uses in Nagios.
Hi I followed all lines.
While i was writing command make make all
got error “make: *** No rule to make target `all’. Stop.”
make utility allready installed.
Please help in this.
hi i am serge
i have install nagios properly when i run nagios.service i have this message “job for nagios.service failed because the control process exited with error code” thanks for your help
i am getting Authorization Required problem
Hi Team,
I installed Nagios on Linux, with all the steps as mentioned above. but while logging I am not able to login. getting error like
” Authorization Required
This server could not verify that you are authorized to access the document requested. Either you supplied the wrong credentials (e.g., bad password), or your browser doesn’t understand how to supply the credentials required.
Apache/2.2.15 (Red Hat) Server at 172.29.218.194 Port 80″
Can some one help on this please.