Step 01 : Install the required packages
Make sure you have installed the following packages on your Ubuntu system before continuing.
Apache 2
PHP
GCC compiler and development libraries
GD development libraries
If you did not install then please run the following commands:
Step 02 Create Account Information for nagios user
Create a new nagios user account and give it a password.
Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.
Step 03 Download and install Nagios core service
Create a directory for storing the downloads.
Download the source code for both Nagios core by following commands.
After extracting cd to nagios-4.4.3 directory and install using configure and make command.
Now copy event handlers scripts under libexec directory. These binaries provides multiple events triggers for your Nagios web interface.
create an Apache configuration file for your Nagios server as below:
Step 5 – Installing Nagios Plugins
Download and extract the Nagios source code from tar as following.
Step 06: Verify settings
Use the Nagios commands to verify the Nagios installation and configuration setting.
Total Warnings: 0
Total Errors: 0
Start nagios service
Also configure Nagios to auto start on system boot.
Step 7 – Access Nagios Web Interface
Enter the following url into the browser , it will ask to enter username and password. In this configuration we have username as nagiosadmin and password also as nagios admin.
Sample configuration files have now been installed in its default location /usr/local/nagios/etc directory. Before procceding ahead edit the /usr/local/nagios/etc/objects/contacts.cfg file to place your email address.
Email address should be associated with nagiosadmin contact definition on which you would like to receive email alerts.
Step 9 Other Modifications
If you want to receive email notifications for Nagios alerts, you need to install the mailx (Postfix) package.
You'll have to edit the Nagios email notification commands found in /usr/local/nagios/etc/objects/commands.cfg and change any '/bin/mail' references to '/usr/bin/mail'. Once you do that you'll need to restart Nagios to make the configuration changes live.
Make sure you have installed the following packages on your Ubuntu system before continuing.
Apache 2
PHP
GCC compiler and development libraries
GD development libraries
If you did not install then please run the following commands:
sudo apt-get update
sudo apt-get install wget build-essential unzip openssl libssl-dev
sudo apt-get install apache2 php libapache2-mod-php php-gd libgd-dev
sudo apt-get install wget build-essential unzip openssl libssl-dev
sudo apt-get install apache2 php libapache2-mod-php php-gd libgd-dev
Need personal assistance on Nagios? Please contact me at immukesh72@gmail.comat very nominal charges |
---|
Step 02 Create Account Information for nagios user
Create a new nagios user account and give it a password.
sudo adduser nagios
Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to the group.
sudo groupadd nagcmd or /usr/sbin/groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data
Step 03 Download and install Nagios core service
Create a directory for storing the downloads.
mkdir ~/downloads
cd ~/downloads
cd ~/downloads
Download the source code for both Nagios core by following commands.
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.3.tar.gz
tar xzf nagios-4.4.3.tar.gz
tar xzf nagios-4.4.3.tar.gz
After extracting cd to nagios-4.4.3 directory and install using configure and make command.
cd nagios-4.4.3
sudo ./configure --with-command-group=nagcmd
sudo make all
sudo make install
sudo make install-init
sudo make install-daemoninit
sudo make install-config
sudo make install-commandmode
sudo make install-exfoliation
sudo ./configure --with-command-group=nagcmd
sudo make all
sudo make install
sudo make install-init
sudo make install-daemoninit
sudo make install-config
sudo make install-commandmode
sudo make install-exfoliation
Now copy event handlers scripts under libexec directory. These binaries provides multiple events triggers for your Nagios web interface.
cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
Step 04: Setup Apache with Authenticationchown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
create an Apache configuration file for your Nagios server as below:
sudo vi /etc/apache2/conf-available/nagios.conf
Paste the following content in nagios.cfg and save
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
Alias /nagios "/usr/local/nagios/share"
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you will need it later.Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
Alias /nagios "/usr/local/nagios/share"
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Restricted Area"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Now enable Apache configuration and restart Apache service to make the new settings take effect.
sudo a2enconf nagios
sudo a2enmod cgi rewrite
sudo service apache2 restart (or) /etc/init.d/apache2 reload
sudo a2enmod cgi rewrite
sudo service apache2 restart (or) /etc/init.d/apache2 reload
Step 5 – Installing Nagios Plugins
Download and extract the Nagios source code from tar as following.
tar -zxvf nagios-plugins-2.2.1.tar.gz
cd nagios-plugins-2.2.1
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
sudo make
sudo make install
cd nagios-plugins-2.2.1
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
sudo make
sudo make install
Step 06: Verify settings
Use the Nagios commands to verify the Nagios installation and configuration setting.
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
You should get following output at end.Total Warnings: 0
Total Errors: 0
Start nagios service
service nagios start
Also configure Nagios to auto start on system boot.
sudo systemctl enable nagios
Step 7 – Access Nagios Web Interface
Enter the following url into the browser , it will ask to enter username and password. In this configuration we have username as nagiosadmin and password also as nagios admin.
http://localhost/nagios/
or
http://Ip_addreess_of_nagios_server/nagios/
Step 8 Customize Configurationor
http://Ip_addreess_of_nagios_server/nagios/
Sample configuration files have now been installed in its default location /usr/local/nagios/etc directory. Before procceding ahead edit the /usr/local/nagios/etc/objects/contacts.cfg file to place your email address.
Email address should be associated with nagiosadmin contact definition on which you would like to receive email alerts.
vi /usr/local/nagios/etc/objects/contacts.cfg
Step 9 Other Modifications
If you want to receive email notifications for Nagios alerts, you need to install the mailx (Postfix) package.
sudo apt-get install mailx
sudo apt-get install postfix
sudo apt-get install postfix
You'll have to edit the Nagios email notification commands found in /usr/local/nagios/etc/objects/commands.cfg and change any '/bin/mail' references to '/usr/bin/mail'. Once you do that you'll need to restart Nagios to make the configuration changes live.
sudo /etc/init.d/nagios restart
Need personal assistance on Nagios? Please contact me at immukesh72@gmail.comat very nominal charges |
---|
No comments:
Post a Comment