Deployment of Nagios in RedHatLinux

Source: Internet
Author: User
System Environment: RedHat-5.4-linux-x86_64-DVD experiment process: 1. build a clean environment (production machine is enough). Running nagios requires support from apache and php. check whether the nagios source code package matches the nrpe source code package version. (If the nagios, nagios-plugin, and nrpe versions do not match, ERROR-couldnotcompleteSSLhandshake may occur ). Install these 3 on the host

System Environment: RedHat-5.4-linux-x86_64-DVD

Experiment process:
1. Build a clean environment (production machine is enough). Running nagios requires the support of apache and php.
2. Check whether the nagios source code package matches the nrpe source code package version. (If the nagios, nagios-plugin, and nrpe versions do not match, ERROR-cocould not complete will occur.
SSL handshake ). Install the three source code packages on the host.
3. Install the nagios-plugin and nrpe source code packages on the monitoring extension. You do not need to install the nagios client.
4. Open the web browser http://www.linuxidc.com/nagios page on the host and click the server in Current Status to view the monitored service running Status.

Procedure:
 
1. Set up the running environment of nagios:

Nagios server [192.168.126.90]
1. yum-y install php
Yum-y install httpd
Yum-y install gd-devel glib-common gcc openssl
2. Create users and groups for nagios
Useradd nagios
Groupadd nagcmd
Usermod-G nagcmd nagios
Usermod-G nagcmd apache
 
3. Install nagios
Tar zxvf nagios-3.2.0.tar.gz
Cd nagios-3.2.0
./Configure -- with-command-group = nagcmd
Make all
Make install & make install-init & make install-commandmode & make install-config & make install-webconf
Ls/etc/httpd/conf. d/nagios. conf


--/Etc/httpd/conf. d/nagios. conf
Htpasswd-c/usr/local/nagios/etc/htpasswd. users nagiosadmin # Add a user to the webpage and set a password.
Service httpd start # activate the httpd service to provide services for nagios
Http: // localhost/nagios # enter the user name and password To Go To The nagios page.

4. Install nagios-plugin # After the installation is complete, many monitoring commands similar to check_http will be generated to the/usr/local/nagios/libexec directory,
These commands are used to check the status of the corresponding service.
Tar xf nagios-plugins-1.4.13.tar.gz
Cd nagios-plugins-1.4.13
./Configure -- with-nagios-user = nagios -- with-nagios-group = nagios
Make
Make install
 
5. Install nrep-2.12 # He is a daemon

Tar-axvf nrpe-2.12.tar.gz
Cd nrpe2.12
./Configure
Make all
Make install-plugin
 
6. Start configuring nagios
First:
Vim/usr/local/nagios/etc/nagios. cfg # defines the nodes monitored by the nagios server host, which are divided into linux and windows.

# Definitions for monitoring the local (Linux) host # Add the $ HOST. cfg file here (the file name can be written as needed)
Export _file =/usr/local/nagios/etc/objects/192.168.126.23.cfg
Second: cd/usr/local/nagios/etc/objects/
Vim 192.168.126.23.cfg # edit this file to add

Define host {
Use linux-server; Name of host template to use
; This host definition will inherit all variable
S that are defined
; In (or inherited by) the linux-server host tem
Plate definition.
Host_name gmw-126.75
Alibaba gmw-126.75
Address 192.168.126.75
}


Define hostgroup {
Hostgroup_name linux-gmw-126.75; The name of the hostgroup
Alias Linux-gmw-126.75; Long name of the group
Members gmw-126.75; Comma separated list of hosts that belong to this group # general user (host_name), do not enter comment out
}

Define service {
Use local-service; Name of service template to use
Host_name gmw-126.75
Service_description port_59731
Check_command check_nrpe! Check_port_59731S
Notifications_enabled 2
}
...........
 

Vim/usr/local/nagios/etc/objects/command. cfg defines the check_nrpe command
Define command {
Command_name check_nrpe
Command_line $ USER1 $/check_nrpe-H $ HOSTADDRESS $-c $ ARG1 $
}

To enable SMS alarms, you can use the 139 mailbox.

========================================================== ======
Node:
192.168.126.75


Tar zxvf nagios-plugins-1.4.13.tar.gz Extract files
Cd nagios-plugins-1.4.13 into the file and compile
Useradd nagios
./Configure -- with-nagios-user = nagios -- with-nagios-group = nagios
Make
Make install
Chown nagios. nagios/usr/local/nagios
Chown-R nagos. nagios/usr/local/nagios/libexec
The rpm-q xinetd plug-in requires xinetd support. Therefore, check whether xinetd is installed or not.
Xinetd-2.3.14-10.el
Tar zxvf nrpe-2.12.tar.gz decompress this plug-in and compile it
./Configure
Make all
Make install-plugin
Make install-daemon
Make install-daemon-config
Make install-xinetd
Vim/etc/xinetd. d/nrpe Add the Server IP address to the local loopback in this folder
Only_from = 127.0.0.1 192.168.126.90
Vim/etc/services add the upper port here
Nrpe 5666/tcp # NRPE
Service xinetd restart xinetd
Stop xinetd: [OK]
Start xinetd: [OK]
Netstat-ntlp | grep 5666 check whether the port has been enabled
Tcp 0 0 0.0.0.0: 5666 0.0.0.0: * LISTEN 24966/xinetd
/Usr/local/nagios/libexec/check_nrpe-H localhost Use this command to check whether the local host information can be detected.
NRPE v2.12 appears, which means local information can be detected.

Vim/usr/local/nagios/etc/nrpe. cfg configure the nrpe File
Command [check_users] =/usr/local/nagios/libexec/check_users-w 5-c 10
Command [check_load] =/usr/local/nagios/libexec/check_load-w 15,10, 5-c 30,25, 20
Command [check_hda1] =/usr/local/nagios/libexec/check_disk-w 20%-c 10%-p/dev/hda1
Command [check_hda2] =/usr/local/nagios/libexec/check_disk-w 20%-c 10%-p/dev/hda2 Add a command to detect root partitions
Command [check_zombie_procs] =/usr/local/nagios/libexec/check_procs-w 5-c 10-s Z
Command [check_total_procs] =/usr/local/nagios/libexec/check_procs-w 150-c 200
Command [check_swap] =/usr/local/nagios/libexec/check_swap-w 20-c 10 added a command to detect swap partitions

Check whether information can be collected:

/Usr/local/nagios/libexec/check_nrpe-H localhost-c check_swap
Swap OK-100% free (2000 MB out of 2000 MB) | swap = 2000 MB; 0; 0; 2000


# Some servers have firewalls and you need to enable ports.


Note:
Nagios log file address:
/Usr/local/nagios/var/nagios. log
Nagios log archiving address:
/Usr/local/nagios/var/archives /...

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.