Install Nagios monitoring server and client

Source: Internet
Author: User
Tags cgi web

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

 
  1. View the Server installation environment (LAMP)
  2. # Rpm-qa | grephttpd
  3. # Rpm-qa | grepphp
  4. If not, install
  5. # Yum-yinstallgccglibcglibc-commongdgd-develphpopenssl-develhttpd
  6. Create a user:
  7. # Useradd-m-s/bin/bashnagios
  8. # Groupaddnagios
  9. # Usermod-Gnagiosnagios
  10. # Vi/etc/passwd
  11. Nagios: x: 500: 500:/home/nagios:/sbin/nologin
  12. Changed:
  13. Nagios: x: 500: 500:/home/nagios:/bin/bash
  14. Create a user group named nagcmd to execute External commands from the Web interface. Add both nagios users and apache users to this group.
  15. Because the CGI Web monitoring panel is used, we need to add a nagcmd group for CGI to execute related commands.
  16. #/Usr/sbin/groupaddnagcmd
  17. #/Usr/sbin/usermod-Gnagcmdnagios
  18. #/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:

 
  1. [Root @ server ~] # Cd/usr/local/src/tarbag/
  2. [Root @ servertarbag] # wgethttp: // prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.2.tar.gz
  3. [Root @ servertarbag] # wgethttp: // prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
  4. [Root @ servertarbag] # wgethttp: // prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz

Decompress and compile and install Nagios:

 
  1. #Tarxvzfnagios-3.2.2.tar.gz
  2. # Cdnagios-3.2.2

Run the Nagios configuration script and use the previously opened users and user groups:

 
  1. #./Configure -- prefix =/usr/local/nagios -- with-command-group = nagcmd

Compile the Nagios package source code:

 
  1. # Makeall

Install the binary program, initialize the script, configure the file sample, and set the running directory permissions:

 
  1. # Makeinstall
  2. # Makeinstall-init // install the startup script in/etc/rc. d/init. d.
  3. # Makeinstall-config // install the sample configuration file. The installation path is/usr/local/nagios/etc.
  4. # Makeinstall-commandmode // configure Directory Permissions
  5. # Ls/usr/local/nagios/
  6. 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.

 
  1. Vi/usr/local/nagios/etc/objects/contacts. cfg

1. Install the nagios plugin

 
  1. # Cd ../
  2. #Tarzxvfnagios-plugins-1.4.16.tar.gz
  3. # Cdnagios-plugins-1.4.16
  4. #./Configure -- with-nagios-user = nagios -- with-nagios-group = nagios -- prefix =/usr/local/nagios // specify the installation directory and users and groups
  5. # Make; makeinstall
  6. Configure httpd
  7. Generate the Apache configuration file for Nagios
  8. # Cdnagios-3.2.2
  9. # Makeinstall-webconf
  10. /Usr/bin/install-c-m644sample-config/httpd. conf/etc/httpd/conf. d/nagios. conf
  11. # Cdsample-config
  12. Add sample-config/httpd. conf to the httpd. conf configuration file of Apache.
  13. 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.
  14. #./Htpasswd-c/usr/local/nagios/etc/htpasswd. usersnagiosadmin
  15. Password: nagiosmonitor
  16. Restart the Apache service to make the settings take effect.
  17. 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.
  18. # Cd ..
  19. #Tarzxvfnrpe-2.14.tar.gz
  20. # Cdnrpe-2.14
  21. #./Configure -- with-nagios-user = nagios -- with-nagios-group = nagios -- prefix =/usr/local/nagios/
  22. # Makeall
  23. # Makeinstall-plugin; makeinstall-daemon-config
  24. # Ls/usr/local/nagios/libexec/
  25. Check_aptcheck_ftpcheck_mailqcheck_overcrcheck_tcp .......
  26. Verify the Nagios sample configuration file
  27. #/Usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios. cfg
  28. If no error is reported, you can start the Nagios service.
  29. Start and verify the httpd and nagios services
  30. # Chkconfig -- addnagios // set nagios and http to boot automatically
  31. # Chkconfignagioson
  32. # Chkconfighttpdon
  33. # Servicenagiosstart
  34. # Servicehttpdstart

2. Client installation

 
  1. # Useradd-s/sbin/nologinnagios // Add a nagios user
  2. Install nagios-plugins
  3. #Tar-zxvfnagios-plugins-1.4.15.tar.gz
  4. # Cdnagios-plugins-1.4.15
  5. #./Configure -- prefix =/usr/local/nagios
  6. # Make
  7. # Makeinstall
  8. # Chownnagios. nagios/usr/local/nagios/
  9. # Chown-Rnagios.nagios/usr/local/nagios/libexec/
  10. Install the nrpe plug-in
  11. #Tar-zxvfnrpe-2.12.tar.gz
  12. # Cdnrpe-2.12
  13. #./Configure -- prefix =/usr/local/nagios/
  14. # Makeall
  15. # Makeinstall-plugin install the check_nrpe plugin
  16. # Makeinstall-daemon install daemon
  17. # Makeinstall-daemon-config
  18. If an error is reported during installation: checkingforSSLheaders... configure: error: Cannotfindsslheaders
  19. # Rpm-qa | grepopenssl
  20. Openssl-devel-0.9.8e-12.el5_4.6
  21. Openssl-0.9.8e-12.el5_4.6
  22. Yuminstallopenssl-devel
  23. Or download: http://www.openssl.org/source/
  24. Tarzxvfopenssl-1.0.0a.tar.gz
  25. Cdopenssl-1.0.0a
  26. ./Config
  27. Make
  28. Maketest
  29. Makeinstall
  30. Modify the client configuration file
  31. Vi/usr/local/nagios/etc/nrpe. cfg
  32. Server_port: 5666
  33. Allowed_hosts = 127.0.0.1, 192.168.1.95 // Add a server IP Address
  34. 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.
  35. Modify the command section in nrpe. cfg.
  36. Start the NRPE daemon: (you can add this command to/etc/rc. local for Automatic startup)
  37. #/Usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe. cfg-d
  38. You can add this command to/etc/rc. local to enable automatic startup upon startup.
  39. Echo "/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe. cfg-d">/etc/rc. local
  40. # Netstat-utpln | grepnrpe // check whether the nrpe process has started properly
  41. #/Usr/local/nagios/libexec/check_nrpe-H127.0.0.1NRPEv2.14 // nrpe test results, the result is nrpe has been working properly
  42. Then test on the nagios Monitoring Server
  43. #/Usr/local/nagios/libexec/check_nrpe-H192.168.1.77 // ip address of the monitored host
  44. Return information about the NRPE version installed on the monitored server: NRPEv2.12

3. Define monitoring content

 
  1. # Vi/usr/local/nagios/etc/nrpe. cfg // define monitoring server content
  2. Command [check_users] =/usr/local/nagios/libexec/check_users-w5-c10 # monitor the number of login users
  3. Command [check_load] =/usr/local/nagios/libexec/check_load-w15, 10, 5-c30, 25, 20 # monitor CPU load
  4. 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
  5. 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
  6. Command [check_total_procs] =/usr/local/nagios/libexec/check_procs-w150-c200 # monitor all processes
  7. 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.

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.