Install and configure nagios in centos6.7
Nagios is an open-source free network monitoring tool that can effectively monitor the status of Windows, Linux and Unix hosts, network settings such as vswitches and routers, and printers. If the system or service status is abnormal, an email or text message alert will be sent immediately to the website O & M personnel. After the status is restored, a normal email or text message notification will be sent. Nagios can run on linux/unix platforms, and provides an optional browser-based WEB interface for administrators to view network status, various system problems, and logs.
1. installation environment. Nagios requires the support of apache and php. Therefore, you must first install Apache and php, load the php module into apache, and test whether it is correct. This is a test script, as shown below. Also need to install gd-devel-2.0.35-11.el6.x86_64 (yum installation)
[Root @ lys htdocs] # cat index. php
<H1> www.a.com
<? Php
Phpinfo ();
?>
2.The software package is nagios-4.0.8.tar.gz, and nagios-plugins-2.1.1.tar.gz.
3. In order not to affect opening the Page Test in the browser in the future, we temporarily clear iptables rules and temporarily disable SElinux.
[Root @ lys ~] # Iptables-F clear iptables rules
[Root @ lys ~] # Setenforce 0
4. Create a nagios user and group
[Root @ lys ~] # Useradd nagios
[Root @ lys ~] # Usermod-M-s/sbin/nologin
[Root @ lys ~] # Groupadd nagios
[Root @ lys ~] # Usermod-G nagios
5. Because I have downloaded the software package before, I will extract it directly.
[Root @ lys ~] # Tar xfnagios-4.0.8.tar.gz
[Root @ lys nagios] # cd nagios-4.0.8
[Root @ lys nagios-4.0.8] #
6. initialize and build the compiling environment. (Pay special attention to your installation path)
[Root @ lys nagios-4.0.8] #./configure -- prefix =/mnt/cellar/nagios/-- with-nagios-user = nagios -- with-nagios-group = nagios
[Root @ lys nagios-4.0.8] # make all
[Root @ lys nagios-4.0.8] # make install // install binary
[Root @ lys nagios-4.0.8] # make install-init // Initialization Script
[Root @ lys nagios-4.0.8] # make install-config // instance of the configuration file
[Root @ lys nagios-4.0.8] # make install-commandmode // Set Directory Permissions
After compilation and installation, switch to the/mnt/cellar/nagios/directory. The following directory is displayed, indicating that the installation is correct.
[Root @ lys nagios-4.0.8] # cd/mnt/cellar/nagios/
[Root @ lys nagios] # ll
Total 28
Drwxrwxr-x 2 nagios 4096 Nov 18 bin
Drwxrwxr-x 3 nagios 4096 Nov 18 etc
Drwxr-xr-x 2 root 4096 Nov 18 15:12 include
Drwxrwxr-x 3 nagios 4096 Nov 18 libexec
Drwxrwxr-x 2 nagios 4096 Nov 18 sbin
Drwxrwxr-x 11 nagios 4096 Nov 18 share
Drwxrwxr-x 5 nagios 4096 Nov 18 var
7. Install the web configuration file of nagios
[Root @ lys nagios-4.0.8] # make install-webconf // web configuration file for nagios
8. Use apache to create basic WEB authentication methods. Create an admin user to manage the nagios web interface and give the admin user a password.
[Root @ lys ~] # Htpasswd-c/mnt/cellar/nagios/etc/htpasswd. users admin
[Root @ lys ~] # Cat/mnt/cellar/nagios/etc/htpasswd. users
Admin: c77K8ehFMuAD6
Only Authenticated admin users can access the content under/mnt/cellar/nagios/share and/mnt/cellar/nagios/sbin through the WEB.
9.nagios: Install nagios-plugins-2.1.1.tar.gz from the context menu
[Root @ lys ~] # Tar xfnagios-plugins-2.1.1.tar.gz
[Root @ lys ~] # Cdnagios-plugins-2.1.1
[Root @ lys nagios-plugins-2.1.1] #./configure -- prefix =/mnt/cellar/nagios/-- with-nagios-user = nagios -- with-nagios-group = nagios
[Root @ lys nagios-4.0.8] # make & make install
10. Check whether the configuration file is correct after all configurations are installed.
[Root @ lys ~] #/Mnt/cellar/nagios/bin/nagios-v/mnt/cellar/nagios/etc/nagios. cfg // if no error is reported, the configuration file is correct.
11. Enable nagios to boot automatically
[Root @ lys ~] # Chkconfig -- add nagios
[Root @ lys ~] # Chkconfig nagios on
12. Start nagios
[Root @ lys ~] # Service nagios start
[Root @ lys ~] # Service nagios status
Nagios (pid 2769) is running...
13. After nagios is started, open the browser http: // 192.168.0.109/nagios/as shown below
After entering the user name and password:
When I do this, an error is reported on the nagios page:
Solution:
1. [root @ lys ~] # Cd/mnt/cellar/nagios/etc/
2. [root @ lys etc] # grep "use_authentication" *. cfg
Cgi. cfg: use_authentication = 1
3. [root @ lys etc] # vi cgi. cfg
Use_authentication = 1 # Change 1 to 0 and save it.
4. Restart the nagios service.