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.