Nagios Setup and Configuration

Source: Internet
Author: User

Nagios Setup and Configuration


Experimental environment centos6.5 two sets


Experimental steps


I. Installing Nagios dependencies:

Yum-y Install httpd gcc glibc glibc-common gd gd-devel php php-mysql mysql mysql-devel mysql-server xinetd


Two. Install and configure Nagios (monitor this machine)

  1. Add the users and groups required for Nagios to run:

    Useradd Nagios


  2. Add Apache to the Nagios group

    Usermod-a-G Nagios Apache


  3. Upload Nagios package and install Nagios after pressurization:

    TAR-ZXF nagios-4.0.3.tar.gz

    CD nagios-4.0.3

    ./configure--with-command-group=nagios--enable-event-broker

    Make all (compile all)

    Make install (install)

    Make Install-init (Generate startup script file)

    Make Install-commandmode (Set execution permissions for the group)

    Make install-config (build config file)

    Make install-webconf (install Nagios Web files into the CONF.D directory of httpd)


  4. Specify the email address you want to use to receive Nagios warning messages, by default, the Nagios user of this computer:

    Vim/usr/local/nagios/etc/objects/contacts.cfg


  5. Modify configuration email [email protected] This is the default setting


  6. Create a user who logs in to the Nagios Web program, which is used by the Web login for Nagios authentication later: htpasswd-c/usr/local/nagios/etc/htpasswd.users nagiosadmin


  7. You need to start httpd after the above process configuration is complete:

    /ETC/INIT.D/HTTPD start


  8. compiling, installing nagios-plugins (plugin)

    TAR-ZXF nagios-plugins-1.5.tar.gz

    CD nagios-plugins-1.5

    ./configure--with-nagios-user=nagios--with-nagios-group=nagios

    Make

    Make install

  9. Check that the syntax for the master configuration file is correct:

    /usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg


  10. If there is no problem with the syntax check above, then you can formally start the Nagios service: Service Nagios start

    Close Selinux:setenforce 0

    Shut down firewall: Service iptables stop

    To modify the local monitoring profile: vim/usr/local/nagios/etc/objects/localhost.cfg


  11. View Nagios through the Web interface:

    Http://your_nagios_IP/nagios

    This time the Linux native can be monitored. Browser test: ' IP address '/nagios


Three. Monitoring remote Linux hosts based on Nrpe (bridge)


    1. Configuration-monitoring Side


1). Install Nrpe

TAR-XF nrpe-2.12.tar.gz

CD nrpe-2.12

./configure--with-nrpe-user=nagios \

--with-nrpe-group=nagios \

--with-nagios-user=nagios \

--with-nagios-group=nagios \

--enable-command-args \

--enable-ssl

Make all

Make Install-plugin (Set plugin permissions)


2). Add Policy

Vim/usr/local/nagios/etc/objects/commands.cfg

Added: Define command{

Command_name Check_nrpe

Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C $ARG 1$

}


3). Define the Monitoring object and copy a template cp localhost.cfg linux.cfg

To edit a module file:

Vim Linux.cfg (:%s/localhost/linux/g[modify localhost to Linux])

HOST_NAME Linux

Address the IP of the monitored side

To comment out the five Elements

Define Hostgroup{

Hostgroup_name linux-servers; The name of the HostGroup

Alias Linux Servers; Long Name of the group

Members Linux; Comma separated list of hosts that belong to this group

}

Modify the Check_command to Check_nrpe_procs (the middle part does not move the last part only)

4). Add Module


Vim/usr/local/nagios/etc/objects/commands.cfg

Add to:

Define Command{

Command_name Check_nrpe_disk

Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C "Check_disk"

}


Define Command{

Command_name check_nrpe_users

Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C "Check_users"

}

Define Command{

Command_name Check_nrpe_procs

Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C "Check_procs"

}

Define Command{

Command_name Check_nrpe_load

Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C "Check_load"

}

Define Command{

Command_name Check_nrpe_swap

Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C "Check_swap"

}

Vim vim/usr/local/nagios/etc/nagios.cfg Add a

Cfg_file=/usr/local/nagios/etc/objects/linux.cfg

CD objects/


5). Give Permission:

Chown Nagios.nagios linux.cfg chmod 664 linux.cfg


6). Start the service:

Service Nagios Restart


2. Installation configuration-Monitored side


1) Add Nagios users First

Useradd-s/sbin/nologin Nagios


2) Nrpe depends on nagios-plugins, so you need to install Nagios-plugins first

TAR-ZXF nagios-plugins-1.5.tar.gz

CD nagios-plugins-1.5

./configure--with-nagios-user=nagios--with-nagios-group=nagios

Make all

Make install


3) Install Nrpe

TAR-XF nrpe-2.12.tar.gz

CD nrpe-2.12.tar.gz

./configure--with-nrpe-user=nagios \

--with-nrpe-group=nagios \

--with-nagios-user=nagios \

--with-nagios-group=nagios \

--enable-command-args \

--enable-ssl

Make all

Make Install-plugin

Make Install-daemon

Make Install-daemon-config

Make install-xinetd (Generate temporary service)


4). Modify the file:

Vim/etc/xinetd.d/nrpe

only-from=127.0.0.1 10.1.1.2 (This is the IP of the monitor-side Nagios) (Nrpe allows the above IP machine to query the service via Nrpe)

Vim/etc/services

The file is added at the end of the article: Nrpe 5666/tcp Nrpe


5). Start the daemon process

Service xinetd Start


6). Configure Nrpe

Vim/usr/local/nagios/etc/nrpe.cfg


Log_facility=daemon

Pid_file=/var/run/nrpe.pid

server_address= IP on the monitored side

server_port=5666

Nrpe_user=nagios

Nrpe_group=nagios

allowed_hosts= IP on the monitor side

Command_timeout=60

connection_timeout=300

Debug=0

Command[check_disk]=/usr/local/nagios/libexec/check_disk-w 20%-C 10%-P/(Remember to modify!) )

Command[check_procs]=/usr/local/nagios/libexec/check_procs-w 150-c 200 (Remember to change!) )

Add one: Command[check_swap]=/usr/local/nagios/libexec/check_disk-w 40%-C 20%


7). Start Nrpe

/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg–d (Temporary start)

or define the following as a vim/etc/init.d/nrped script:

!/bin/bash

chkconfig:2345 88 12

Description:nrpe DAEMON


Nrpe=/usr/local/nagios/bin/nrpe

Nrpeconf=/usr/local/nagios/etc/nrpe.cfg


Case "$" in

Start

Echo-n "Starting NRPE daemon ..."

$NRPE-C $NRPECONF-D

echo "Done."

;;

Stop

Echo-n "Stopping NRPE daemon ..."

Pkill-u Nagios Nrpe

echo "Done."

;;

Restart

$ stop

Sleep 2

$ start

;;

*)

echo "Usage: $ start|stop|restart"

;;

Esac

Exit 0

Chmod-r 777/etc/init.d/nrped

8). Start the service

/etc/init.d/nrped start

Service xinetd Restart


This article is from the "Road Wonderland" blog, please be sure to keep this source http://luxiaoqi.blog.51cto.com/10607310/1709619

Nagios Setup and Configuration

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.