ubuntu16.04 Installation Configuration Nagios

Source: Internet
Author: User

Reference post: https://www.howtoing.com/ubuntu-nagios/

This blog post is really valid for reference, follow the steps, basically can be successful

I. Prerequisites for installation

sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd libgd-dev sendmail Unzip

Two. User and group configuration

Useradd Nagios
Groupadd Nagcmd
Usermod-a-G Nagcmd Nagios
Usermod-a-G Nagios,nagcmd www-data

Three. Install Nagios

1. Download and extract Nagios core

CD ~
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz
Tar-xzf nagios*.tar.gz
CD nagios-4.2.0

2. Compiling Nagios

./configure--with-nagios-group=nagios--with-command-group=nagcmd

Make all
sudo make install
sudo make Install-commandmode
sudo make Install-init
sudo make Install-config
/usr/bin/install-c-M 644 sample-config/httpd.conf/etc/apache2/sites-available/nagios.conf

and copy the Evenhandler directory to the Nagios directory:

Cp-r contrib/eventhandlers//usr/local/nagios/libexec/
Chown-r nagios:nagios/usr/local/nagios/libexec/eventhandlers

3. Installing the Nagios Plugin

Download the Extract Nagios plugin:

CD ~
wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz
Tar-xzf nagios-plugins*.tar.gz
CD NAGIOS-PLUGIN-2.1.2/

The following command installs the Nagios plugin:

./configure--with-nagios-user=nagios--with-nagios-group=nagios--with-openssl
Make
Make install

4. Configure Nagios

After the installation phase is complete, you can find the default configuration of Nagios in/Usr/local/nagios/.

We will configure the Nagios and Nagios contacts.

Use Vim to edit the default Nagios configuration:

Vim/usr/local/nagios/etc/nagios.cfg

Uncomment the line to be configured for the host monitor.

Cfg_dir=/usr/local/nagios/etc/servers

Save and exit.

Add a new folder named Servers:

Mkdir-p/usr/local/nagios/etc/servers

You can configure Nagios contacts in the Contact.cfg file. Open it using:

Vim/usr/local/nagios/etc/objects/contacts.cfg

Then replace the default e-mail message with your own e-mail.

Iv. Configuring Apache

1. Enable the Apache module

sudo a2enmod rewrite
sudo a2enmod CGI

You can use the HTPASSWD command to configure user nagiosadmin for the Nagios Web interface:

sudo htpasswd-c/usr/local/nagios/etc/htpasswd.users nagiosadmin

and enter the password

2. Enable Nagios Virtual Host

sudo ln-s/etc/apache2/sites-available/nagios.conf/etc/apache2/sites-enabled/

3. Launch Apache and Nagios

Service Apache2 Restart
Service Nagios Start

When Nagios starts, you may see the following error:

Starting(via Systemctl): nagios.  Servicefailed

cd/etc/init.d/
Cp/etc/init.d/skeleton/etc/init.d/nagios

Vim/etc/init.d/nagios

and add the following code:
DESC="Nagios"
NAME=Nagios
DAEMON=/usr/local/nagios/bin/$NAME
Daemon_args="-d/usr/local/nagios/etc/nagios.cfg"
pidfile=/usr/local/nagios/var/$NAME. Lock

Make it executable and start Nagios:

chmod +x/etc/init.d/nagios
Service Apache2 Restart
Servuce Nagios Start

V. Test Nagios Server

In my case, open your browser and access the Nagios server IP: http : //192.168.126.130/nagios .

Nagios logs in with Apache HTPASSWD

 user name defaults to nagiosadmin 
Password is what you previously did by executing that sudo htpasswd-c/usr/local/nagios/etc/ Htpasswd.users nagiosadmin Command input password

VI, add host monitoring
in my other ip:192.168.126.128
Connect my other host

1.  Connect to Ubuntu host
SSH [email protected]
2. Install the Nrpe service
sudo apt-get install nagios-nrpe-server nagios-plugins
3. Configure Nrpe
Vim/etc/nagios/nrpe.cfg
and add the Nagios server IP 192.168.126.130 to server_aaddress

Server_ Address = 192.168.126.130
4. Restart Nrpe
Service nagios-nrpe-server Restart
5. Add an Ubuntu host to the Nagios server
Please connect to the Nagios server:
SSH [email protected]

and then /usr/local/nagios/etc/servers/Host with Create a new file.
Vim/usr/local/nagios/etc/servers/ubuntu_host.cfg
Add the following:
# Ubuntu Host Configuration Filedefine host {use Linux-server host_name        Ubuntu_host alias Ubuntu host address 192.168.1.10 Register 1}define Service {host_name ubuntu_host Service_descripti              On PING Check_command check_ping!100.0,20%!500.0,60% max_check_attempts 2 Check_interval 2 Retry_interval 2 check_period 24           X7 check_freshness 1 contact_groups Admins notification_interval 2 Notification_period 24x7 notifications_enabled 1 Register 1 }define Service {host_name ubuntu_host service_description Check Users C Heck_command CHECK_LOCAL_USERS!20!50 max_check_attempts 2 Check_interval 2 retry_interval                  2 Check_period 24x7 check_freshness 1 contact_groups Admins notification_interval 2 notification_period 24x7 Notifications_e Nabled 1 Register 1}define service {host_name Ubuntu_hos T service_description Local Disk check_command check_local_disk!20%!10%!/Max _check_attempts 2 Check_interval 2 retry_interval 2 Check_pe Riod 24x7 check_freshness 1 contact_groups Admins Notif Ication_interval 2 notification_period 24x7 notifications_enabled 1 registe                       R 1}define Service {host_name ubuntu_host service_description Check SSH C      Heck_command check_ssh max_check_attempts 2 check_interval 2      Retry_interval 2 Check_period 24x7 check_freshness 1      Contact_groups Admins notification_interval 2 notification_period 24x7                       Notifications_enabled 1 Register 1}define Service {HOST_NAME Ubuntu_host service_description Total Process check_command CHECK_LOCAL_PR ocs!250!400!       RSZDT max_check_attempts 2 Check_interval 2 Retry_interval 2 Check_period 24x7 check_freshness 1 contact_groups ADM INS notIfication_interval 2 notification_period 24x7 notifications_enabled 1 regis Ter 1}

You can find many check_command in the/usr/local/nagios/etc/objects/commands.cfg file . If you want to add more services, such as Dhcp,pop, see

Now check the configuration:

/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg

6. Restart all services

Start the Nrpe service on the Ubuntu host:

Service Nagios-nrpe-server Restart

... On the Nagios server, start Apache and Nagios:

Service Apache2 Restart
Service Nagios Restart

7. Test Ubuntu Host

Open the Nagios server from the browser and view the monitored ubuntu_host.

The Ubuntu host is available on the monitored host.

 

ubuntu16.04 Installation Configuration Nagios

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.