Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Nagios on Ubuntu 14.04 to monitor the server

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to install Nagios on Ubuntu 14.04 for monitoring servers. Xiaobian thinks it is quite practical, so share it with you as a reference. I hope you can gain something after reading this article.

preface

Nagios 4 is a popular open source monitoring system. This article describes how to install the system on Ubuntu 14.04 and some basic configuration, after which you can monitor your host from its Web interface. This article will also cover optimization of the Nagios Remote Plugin Executor (NRPE) plug-in installed as an agent on the host that needs to be monitored.

With Nagios, we can check the resource usage of the host at any time and ensure that important services are running properly. Such monitoring services are essential tools for production environments.

preparations

First you need an Ubuntu 14.04 cloud host configured as a regular user with sudo privileges (see this article for configuration tutorials).

The LAMP software stack also needs to be installed on this host. For LAMP installation, refer to this tutorial.

This tutorial assumes that the host is using a Private Cloud, but you can also use the host's public IP address to complete this tutorial.

Install Nagios 4

The Nagios 4 installation is described below. This step only needs to be done once.

Create Nagios users and user groups

Create the "nagios" user and the "nagcmd" user group for running Nagios processes and add nagios users to the nagcmd user group:

sudo useradd nagiossudo groupadd nagcmdsudo usermod -a -G nagcmd nagios

1

2

3

4

installation dependency

We will build Nagios Core from source code, which requires installing some dependent development libraries first. In addition we will install apache2-utils for setting up Nagios Web interface.

First update the apt-get package list:

sudo apt-get update

1

2

Then install the following packages:

sudo apt-get install build-essential libgd2-xpm-dev openssl libssl-dev xinetd apache2-utils unzip

1

2

Install Nagios Core

Get the source code download address for the latest version of Nagios Core from the Nagios official download page.

The most recent version of Nagios at the time of writing is Nagios 4.1.1, which can be downloaded from:

cd ~curl -L -O https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz

1

2

3

Unpack the package:

tar xvf nagios-*.tar.gz

1

2

Enter the decompressed directory:

cd nagios-*

1

2

There are a few things you need to configure before you build:

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

1

2

If you need to use postfix, you'll also need to add--with-mail=/usr/sbin/sendmail to the end of the above command.

It can now be compiled:

make all

1

2

Then, run the following command to install Nagios, initialize the script, and generate a sample configuration file:

sudo make installsudo make install-commandmodesudo make install-initsudo make install-configsudo /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-available/nagios.conf

1

2

3

4

5

6

Because Nagios needs to be accessed using the Web interface, we also need to add www-data users to the nagcmd user group:

sudo usermod -G nagcmd www-data

1

2

Install Nagios plugin

The latest Nagios plugins are available from the Nagios Plugins Download page. Copy the download address.

The latest version at the time of this writing is Nagios Plugins 2.1.1, which can be downloaded from:

cd ~curl -L -O http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz

1

2

3

Unpack the package:

tar xvf nagios-plugins-*.tar.gz

1

2

Enter the decompressed directory:

cd nagios-plugins-*

1

2

Do some configuration:

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

1

2

Then compile:

make

1

2

Install with the following command:

sudo make install

1

2

Install NRPE

Get the download address for the latest stable version of NRPE on this page. The latest version at the time of writing is version 2.15, which can be downloaded from:

cd ~curl -L -O http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz

1

2

3

Decompression:

tar xvf nrpe-*.tar.gz

1

2

Enter directory:

cd nrpe-*

1

2

Do some configuration:

./ configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu

1

2

Build and install NRPE and its xinetd startup script:

make allsudo make installsudo make install-xinetdsudo make install-daemon-config

1

2

3

4

5

Open xinetd startup script:

sudo vi /etc/xinetd.d/nrpe

1

2

Modify the only_from line to add the IP address of your Nagios server (the address used in this article is 10.132.224.168, you need to replace it with your server address):

only_from = 127.0.0.1 10.132.224.168

1

2

Save exit. Now, only Nagios servers can communicate with NRPE.

Restart xinetd service to start NRPE:

sudo service xinetd restart

1

2

Configure Nagios

This section describes Nagios configuration. These configuration operations only need to be performed once on Nagios servers.

Organizing Nagios Configuration Items

Open Nagios 'main profile:

sudo vi /usr/local/nagios/etc/nagios.cfg

1

2

Find the following line and delete the hashtags:

#cfg_dir=/usr/local/nagios/etc/servers

1

2

Save exit.

Create a new directory to hold configuration files, a separate configuration file for each server you want to monitor:

sudo mkdir /usr/local/nagios/etc/servers

1

2

Configure Nagios Address Book

Open Nagios address book profile:

sudo vi /usr/local/nagios/etc/objects/contacts.cfg

1

2

Find the Email line and change the email to your own email address:

email nagios@localhost ;

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report