Nagios (package, file type)

Source: Internet
Author: User

* * First, install Nagios (source code)

1, Installation Preparation:

Compiling tools

#yum-y Install gcc gcc-c++

Create users and Groups

#useradd Nagios

#groupadd Nagcmd

#usermod-G Nagcmd Nagios


2, Packaging:

Configuration:

#./configure--with-nagios-user=nagios --with-nagios-group=nagcmd--with-command-user=nagios

--with-command-group=nagcmd


Compile:

# make All




Pack:


# Make Install #安装主程序

# make Install-init #安装启动脚本

# make Install-commandmode#安装命令模块

# make Install-config#安装配置文件模版

# make install-webconf#安装apache相关配置文件

# make install-exfoliation#Web服务器的界面风格


# 3, view the installation directory and configuration file description

Home directory/usr/local/nagios The root path of the following path is in the home directory


/bin/nagios#验证配置信息

/bin/nagiostats#显示监控状态信息


/etc/*.cfg#配置文件

/etc/objects/*.cfg #配置文件


/libexec/*#存储监控插件


/sbin/*.cgi#编译好的脚本文件


/share/*#网页信息


/var/*#存放日志文件


4. Install the monitoring plugin nagios-plugins-2.1.4

./configure && make && make install


5. Start the Nagios monitoring service:

1) Set the user name (nagiosadmin) and password (custom) of the Access Monitoring page

Vim/etc/httpd/conf.d/nagios.conf

#主配置文件


Alias/nagios "/usr/local/nagios/share"

#当访问/HTTP/server Ip/nagios jump to a Web page file in the corresponding directory


Authuserfile/usr/local/nagios/etc/htpasswd.users

#记录存储用户的配置文件


Htpasswd-c/usr/local/nagios/etc/htpasswd.users Nagiosadmin

#创建访问监控页面的用户名和密码

#创建完用户后重启 Web service to load the corresponding file for the Web service


2) Start service /etc/rc.d/init.d/nagios start

#默认监控本机:

CPU Load

Number of users logged into the system

WEB Service Run State

Ping

Root partition

SSH Service

Swap partition

Total number of processes


#监控状态

Ok

Warning#警告

Unknown#配置文件有问题

Critical#有严重问题

Pending#正在监控


Ii. Configuring Nagios Services

1. Monitoring process

The Nagios service runtime loads the master profile Ngaios.cfg calls the monitoring plug-in in the configuration file, and the operator can set the monitoring threshold (warning value, error value) of the monitoring plug-in;

The Nagios service plug-in compares the monitored data to the monitoring threshold, and displays the monitoring status based on the comparison results.

The monitored data value is less than the warning value status is normal OK

The monitored data value is greater than the warning value tangent is less than the error value status is warning Warning

Critical error Critical the monitored data value is greater than the error value status



2, monitoring plug-in use

/libexec/check_loadCPU Load

-W 1 minutes, 5 minutes, 15 minutes-C 1 minutes, 5 minutes, 15 minutes

Check_load [-R]-W wload1,wload5,wload15-c cload1,cload5,cload15

/libexec/check_users Number of users logged into the system

-W Warning Value-C error value

Check_users-w <users>-C <users>

/libexec/check_httpWeb service Run state

-H Web server ip-p port does not specify default 80

/libexec/check_pingPing

-H host Ip-w warning value, packet drop rate%-C error value, packet loss%-P packet count-t timeout time -4|-6

-H

[-P packets] [-t timeout] [ -4|-6]

/libexec/check_disk Root partition

-W Warning Value%-C error value%-P mount point, disk Path

/libexec/check_sshSSH Service

-H IP Address-p port default 22 port

/libexec/check_swap Swap partition

-W Warning Value%-C error value%

/libexec/check_procs Total Process Quantity

-W Warning Value-C error value-s status

Status: R run Z zombie s hibernate

/LIBEXEC/CHECK_TCPTCP protocol

-H IP address-p port



3. Configuration file Description

1) Verifying the configuration file

/bin/nagios-v configuration file path #验证配置文件修改是否正确

/bin/nagiostats-c configuration file path #在命令行显示检测结果


2) master configuration file

/etc/nagios.cfg


3) macro Definition file

/ETC/RESOURCE.CFG Macro definition file: Defines the plug-in storage path


4) Command Store

/etc/objects/commands.cfg#定义监控命令

Define Command{

Command_name command name

Command_line Path/Plugin Name parameter

}


5) Monitor the native configuration file

/etc/objects/localhost.cfg#监控本机的

Define Host{

Use Linux-server #监控主机时使用的模版

host_name localhost#主机名

Alias localhost#主机名的描述信息, can omit do not write

Address 127.0.0.1#主机IP

}

Define Service{

Use Local-service#监控资源时使用的模版

host_name localhost#主机名

Service_description PING#监控项的描述信息

Check_command check_ping!100.0,20%!500.0,60%

}#调用的监控命令

#! interval Command parameters


6) e-mail address for receiving alarm information

/etc/objects/contacts.cfg


7) Define the monitoring time template configuration file

/etc/objects/timeperiods.cfg


8) Define the monitor template profile

/etc/objects/templates.cfg

Check_interval 5 #每隔5分钟监控一次

Retry_interval 1 #断开连接后每1分钟冲试一次

Max_check_attempts #最大重试10次


Define Service{

Name Local-service

Use Generic-service

Max_check_attempts 4

Normal_check_interval 5

Retry_check_interval 1

Register 0

}****


Nagios (package, file type)

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.