Nagios is a monitoring system that monitors system running status and network information. Nagios can monitor specified local or remote hosts and services, and provide exception notification functions. Nagios can run on Linux/Unix platforms, at the same time, an optional browser-based WEB interface is provided to facilitate system administrators to view the network status, various system problems, and logs.
I. MAIN FEATURES OF Nagios:
- Monitoring Network Services (SMTP, POP3, HTTP, NNTP, PING, etc)
- Monitor host resources (processes, disks, etc)
- The monitoring function of Nagios can be easily expanded with Simple plug-in design.
- Concurrent processing of services and other monitoring
Prepare the software package:
- Nagios Core nagios-3.2.2.tar.gz
- Nagios Plugins nagios-plugins-1.4.15.tar.gz
- Nagios Addons nrpe-2.12.tar.gz
Ii. Server Installation
- View the Server installation environment (LAMP)
- # Rpm-qa | grephttpd
- # Rpm-qa | grepphp
- If not, install
- # Yum-yinstallgccglibcglibc-commongdgd-develphpopenssl-develhttpd
- Create a user:
- # Useradd-m-s/bin/bashnagios
- # Groupaddnagios
- # Usermod-Gnagiosnagios
- # Vi/etc/passwd
- Nagios: x: 500: 500:/home/nagios:/sbin/nologin
- Changed:
- Nagios: x: 500: 500:/home/nagios:/bin/bash
- Create a user group named nagcmd to execute External commands from the Web interface. Add both nagios users and apache users to this group.
- Because the CGI Web monitoring panel is used, we need to add a nagcmd group for CGI to execute related commands.
- #/Usr/sbin/groupaddnagcmd
- #/Usr/sbin/usermod-Gnagcmdnagios
- #/Usr/sbin/usermod-a-gnag1_daemon (because apache is compiled and installed, it is run by the daemon user by default)
Download the related software packages. The server needs to install the following three packages. The client only needs to install the last two plug-in packages:
- [Root @ server ~] # Cd/usr/local/src/tarbag/
- [Root @ servertarbag] # wgethttp: // prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.2.tar.gz
- [Root @ servertarbag] # wgethttp: // prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
- [Root @ servertarbag] # wgethttp: // prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
Decompress and compile and install Nagios:
- #Tarxvzfnagios-3.2.2.tar.gz
- # Cdnagios-3.2.2
Run the Nagios configuration script and use the previously opened users and user groups:
- #./Configure -- prefix =/usr/local/nagios -- with-command-group = nagcmd
Compile the Nagios package source code:
- # Makeall
Install the binary program, initialize the script, configure the file sample, and set the running directory permissions:
- # Makeinstall
- # Makeinstall-init // install the startup script in/etc/rc. d/init. d.
- # Makeinstall-config // install the sample configuration file. The installation path is/usr/local/nagios/etc.
- # Makeinstall-commandmode // configure Directory Permissions
- # Ls/usr/local/nagios/
- Binetclibexecsbinsharevar
3. Configure nagios
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
1. Install the nagios plugin
- # Cd ../
- #Tarzxvfnagios-plugins-1.4.16.tar.gz
- # Cdnagios-plugins-1.4.16
- #./Configure -- with-nagios-user = nagios -- with-nagios-group = nagios -- prefix =/usr/local/nagios // specify the installation directory and users and groups
- # Make; makeinstall
- Configure httpd
- Generate the Apache configuration file for Nagios
- # Cdnagios-3.2.2
- # Makeinstall-webconf
- /Usr/bin/install-c-m644sample-config/httpd. conf/etc/httpd/conf. d/nagios. conf
- # Cdsample-config
- Add sample-config/httpd. conf to the httpd. conf configuration file of Apache.
- Create a nagiosadmin user for logging on to the Apache interface of Nagios. Write down the logon password you set and you will use it later.
- #./Htpasswd-c/usr/local/nagios/etc/htpasswd. usersnagiosadmin
- Password: nagiosmonitor
- Restart the Apache service to make the settings take effect.
- Install the NRPE plug-in. To obtain more detailed information on the client, you must also install the NRPE plug-in on the server and client.
- # Cd ..
- #Tarzxvfnrpe-2.14.tar.gz
- # Cdnrpe-2.14
- #./Configure -- with-nagios-user = nagios -- with-nagios-group = nagios -- prefix =/usr/local/nagios/
- # Makeall
- # Makeinstall-plugin; makeinstall-daemon-config
- # Ls/usr/local/nagios/libexec/
- Check_aptcheck_ftpcheck_mailqcheck_overcrcheck_tcp .......
- 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.
- Start and verify the httpd and nagios services
- # Chkconfig -- addnagios // set nagios and http to boot automatically
- # Chkconfignagioson
- # Chkconfighttpdon
- # Servicenagiosstart
- # Servicehttpdstart
2. Client installation
- # Useradd-s/sbin/nologinnagios // Add a nagios user
- Install nagios-plugins
- #Tar-zxvfnagios-plugins-1.4.15.tar.gz
- # Cdnagios-plugins-1.4.15
- #./Configure -- prefix =/usr/local/nagios
- # Make
- # Makeinstall
- # Chownnagios. nagios/usr/local/nagios/
- # Chown-Rnagios.nagios/usr/local/nagios/libexec/
- Install the nrpe plug-in
- #Tar-zxvfnrpe-2.12.tar.gz
- # Cdnrpe-2.12
- #./Configure -- prefix =/usr/local/nagios/
- # Makeall
- # Makeinstall-plugin install the check_nrpe plugin
- # Makeinstall-daemon install daemon
- # Makeinstall-daemon-config
- If an error is reported during installation: checkingforSSLheaders... configure: error: Cannotfindsslheaders
- # Rpm-qa | grepopenssl
- Openssl-devel-0.9.8e-12.el5_4.6
- Openssl-0.9.8e-12.el5_4.6
- Yuminstallopenssl-devel
- Or download: http://www.openssl.org/source/
- Tarzxvfopenssl-1.0.0a.tar.gz
- Cdopenssl-1.0.0a
- ./Config
- Make
- Maketest
- Makeinstall
- Modify the client configuration file
- Vi/usr/local/nagios/etc/nrpe. cfg
- Server_port: 5666
- Allowed_hosts = 127.0.0.1, 192.168.1.95 // Add a server IP Address
- Specify the nagios monitoring host ip address. Multiple ip addresses are separated by commas (,). The following ip address is the ip address of the nagios server. That is to say, only the specified ip address can be used to obtain information about the local machine through the port 5666 opened by nrpe.
- Modify the command section in nrpe. cfg.
- Start the NRPE daemon: (you can add this command to/etc/rc. local for Automatic startup)
- #/Usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe. cfg-d
- You can add this command to/etc/rc. local to enable automatic startup upon startup.
- Echo "/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe. cfg-d">/etc/rc. local
- # Netstat-utpln | grepnrpe // check whether the nrpe process has started properly
- #/Usr/local/nagios/libexec/check_nrpe-H127.0.0.1NRPEv2.14 // nrpe test results, the result is nrpe has been working properly
- Then test on the nagios Monitoring Server
- #/Usr/local/nagios/libexec/check_nrpe-H192.168.1.77 // ip address of the monitored host
- Return information about the NRPE version installed on the monitored server: NRPEv2.12
3. Define monitoring content
- # Vi/usr/local/nagios/etc/nrpe. cfg // define monitoring server content
- Command [check_users] =/usr/local/nagios/libexec/check_users-w5-c10 # monitor the number of login users
- Command [check_load] =/usr/local/nagios/libexec/check_load-w15, 10, 5-c30, 25, 20 # monitor CPU load
- Command [check_sda2] =/usr/local/nagios/libexec/check_disk-w20 %-c10 %-p/dev/sda2 # monitor disk utilization, where sda2 must be the actual hard disk partition, you can use fdisk-l to query
- Command [check_swap] =/usr/local/nagios/libexec/check_swap-w20-c10 # monitor swap space command [check_zombie_procs] =/usr/local/nagios/libexec/check_procs-w5-c10-sZ # monitor botnets in the process
- Command [check_total_procs] =/usr/local/nagios/libexec/check_procs-w150-c200 # monitor all processes
- Note: The content in the brackets after the command is the defined variable. The variable name can be specified at will. It only needs to be consistent with that in the server configuration file.