Install Nagios in Ubuntu source code to monitor local hosts
Source: Internet
Author: User
1. this guide attempts to allow you to monitor local hosts by installing Nagios source programs on Ubuntu within 20 minutes using simple commands. More advanced settings are not discussed-only some basic operations, but this is enough for 95% of users to start Nagios. 1. this guide attempts to allow you to monitor local hosts by installing Nagios source programs on Ubuntu within 20 minutes using simple commands. More advanced settings are not discussed-only some basic operations, but this is enough for 95% of users to start Nagios.
These commands are written in Ubuntu 6.10 (Desktop Edition)-based systems.
What Youll End Up
If you follow the instructions in this tutorial, the result is as follows:
Nagios and plug-ins will be installed in/usr/local/nagios
Nagios will be configured to monitor several main services of the local system (CPU load, disk utilization, etc)
The Nagios Web interface is http: // localhost/nagios/
2. required software packages
Make sure that the following software package has been installed on your installed system.
Apache2
GCC compiler and development Library
GD library and development Library
You can use the apt-get command to install these software packages. type the command:
Sudo apt-get install apache2
Sudo apt-get install build-essential
Sudo apt-get install libgd2-dev
3. operation process
1) create an account
Switch to root user
Sudo-s
Create an account named nagios and give a logon password
/Usr/sbin/useradd nagios
Passwd nagios
In Ubuntu Server version (6.01 or later), create a user group named nagios (not created by default ). Skip this step on Ubuntu desktop.
/Usr/sbin/groupadd nagios
/Usr/sbin/usermod-G nagios
Create a user group named nagcmd to execute external commands from the Web interface. Add both nagios users and apache users to this group.
Mkdir ~ /Downloads
Cd ~ /Downloads
Download the software packages for Nagios and Nagios plug-ins (visit http://www.nagios.org/download/ ). when writing this document, the latest Nagios software version is 3.0rc1 and The Nagios plug-in version is 1.4.11.
Wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0rc1.tar.gz
Wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz
3) compile and install Nagios
Expand Nagios source package
Cd ~ /Downloads
Tar xzf nagios-3.0rc1.tar.gz
Cd nagios-3.0rc1
Run the Nagios configuration script and use the previously opened users and user groups:
Make all
Install binary programs, initialization scripts, configuration file samples, and set running directory permissions
Make install
Make install-init
Make install-config
Make install-commandmode
Not yet able to start Nagios-some other work to be done... 4) custom configuration
The configuration file of the sample is installed in the directory/usr/local/nagios/etc by default. you can configure Nagios to run the sample file properly. you only need to make a simple modification...
Use the editor software you are good at to edit this/usr/local/nagios/etc/objects/contacts. in the cfg configuration file, change the email information in the contact definition information of the e-mail address nagiosadmin to your EMail information to receive alerts.
Vi/usr/local/nagios/etc/objects/contacts. cfg
5) configure the WEB interface
Install the Nagios WEB configuration file to the conf. d Directory of Apache.
Make install-webconf
Create a nagiosadmin user for logging on to Nagios WEB interface. Write down the logon password you set and you will use it later.
Htpasswd-c/usr/local/nagios/etc/htpasswd. users nagiosadmin
Restart the Apache service to make the settings take effect.
/Etc/init. d/apache2 reload
6) compile and install the Nagios plugin
Expand the source package of the Nagios plug-in
Cd ~ /Downloads
Tar xzf nagios-plugins-1.4.11.tar.gz
Cd nagios-plugins-1.4.11
Compile and install the plug-in
./Configure -- with-nagios-user = nagios -- with-nagios-group = nagios
Make
Make install
7) start Nagios
Add Nagios to the service list to enable it automatically when the system starts.
Ln-s/etc/init. d/nagios/etc/rcS. d/S99nagios
Verify the Nagios sample configuration file
/Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg
If no error is reported, you can start the Nagios service.
/Etc/init. d/nagios start
8) log on to the WEB interface
Now you can access the Nagios WEB interface through the WEB. you need to enter your username (nagiosadmin) and password at the prompt. what you just set, use the default browser installed by the system, and use the hyperlink below
Http: // localhost/nagios/
Click "service details" to view the monitoring details of your local machine. You may need some time for Nagios to detect the services on your machine because the detection takes some time.
9) Other changes
To receive Nagios EMail alerts, you need to install the (Postfix) package.
Sudo apt-get install mailx
You need to edit the e-mail notification sending command in Nagios, which is located in/usr/local/nagios/etc/commands. in the cfg file, replace/bin/mail with/usr/bin/mail. Once configured, you need to restart Nagios for the configuration to take effect.
Sudo/etc/init. d/nagios restart
The alarm item configured for EMail exceeds the content of this document. point to your system file and use the website NagiosCommunity.org wiki to find more information, so that the Ubuntu system can send EMail information to external addresses.
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.