Steps for installing and configuring Nagios 4.0.5 in Ubuntu 12.04

Source: Internet
Author: User
Tags socket python script


The installation record is as follows:
= Server =
Install the dependency package: (the installation can be successful even if it is not installed, that is, some features will be disabled)

Sudo apt-get install build-essential libssl-dev \
Libgd2-xpm-dev libpng12-dev php5-gd libgd2-xpm
User group:


Sudo adduser -- system -- no-create-home -- disabled-login -- group nagios
Sudo groupadd nagcmd
Sudo usermod-G nagcmd nagios
Sudo usermod-a-G nagcmd www-data
Download unzip from http://www.nagios.org/download:

Cd/tmp
Mkdir nagios
Cd nagios
Wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.5.tar.gz
Wget http://www.nagios-plugins.org/download/nagios-plugins-2.0.1.tar.gz
Tar zxf nagios-4.0.5.tar.gz
Tar zxf nagios-plugins-2.0.1.tar.gz
Compile and install:

Cd/tmp/nagios/nagios-4.0.5
./Configure -- prefix =/opt/nagios -- sysconfdir =/etc/nagios \
-- With-nagios-user = nagios -- with-nagios-group = nagios \
-- With-command-user = nagios -- with-command-group = nagcmd
Make all
Sudo make install
Sudo make install-init
Sudo make install-config
Sudo make install-commandmode
Create htpasswd. users. If the command htpasswd is installed in apache2, you can use a python script:
(If the server does not want to install python, you can find a server with python, or find a machine with apache installed to run htpasswd, or install an httpd without starting it)
(The generated htpasswd. users is a text file that is copied to/etc/nagios/htpasswd. users on the server)


Wget http://trac.edgewall.org/export/10791/trunk/contrib/htpasswd.py
Chmod + x htpasswd. py
./Htpasswd. py-c-B/etc/nagios/htpasswd. users nagiosadmin "password"
Modify the contact email in the email address of contacts. cfg (34 rows)


Sudo vi/etc/nagios/objects/contacts. cfg
Install the package required for mail alarm notification (select "Internet Site" during installation; enter the domain name)
(Note: Do not install this mail package to compile the nagios-plugins-2.0.1 will error, but it is okay to compile the nagios-plugins-2.0 ...)


Sudo apt-get install mailutils postfix
Sudo ln-s/usr/bin/mail
Install plug-ins:


Cd/tmp/nagios/nagios-plugins-2.0.1
./Configure -- prefix =/opt/nagios -- with-nagios-user = nagios -- with-nagios-group = nagios
Make
Sudo make install
Sudo chown-R nagios: nagios/opt/nagios
Start nagios


Sudo ln-s/etc/init. d/nagios/etc/rcS. d/S99nagios
Sudo service nagios start
Install fcgi


Sudo apt-get install spawn-fcgi fcgiwrap
Edit nginx. conf

Sudo vi/etc/nginx/sites-enabled/nagios
The addresses starting with "/nagios/" are rewritten. (many pages in nagios are written to the beginning of "/nagios/", which leads to crashes such as images and css)

Server {
Server_name nagios.bianbian.org;
Access_log/var/log/nginx/nagios. access. log;
Error_log/var/log/nginx/nagios. error. log;
 
Auth_basic "Restricted Nagios Area! ";
Auth_basic_user_file/etc/nagios/htpasswd. users;
 
Root/opt/nagios/share /;
 
Location ~ ^/Nagios /{
Rewrite ^/nagios/(. *)/$1 permanent;
  }
 
Location ~ \. Php $ {
Include fastcgi_params;
Fastcgi_pass unix:/var/run/php5-fpm.socket;
  }
 
Location ~ \. Cgi $ {
Root/opt/nagios/sbin /;
Rewrite ^/cgi-bin/(. *) \. cgi/$ 1.cgi break;
Fastcgi_param AUTH_USER $ remote_user;
Fastcgi_param REMOTE_USER $ remote_user;
Include fastcgi_params;
Fastcgi_pass unix:/var/run/fcgiwrap. socket;
  }
}
Start the service


Sudo service nagios start

After logging on, you will see the monitoring interface of nagios.

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.