nagios setup

http://www.cnblogs.com/kaituorensheng/p/4682565.html 

How toset up Nagios Remote Plugin Executor (NRPE) in Linux

Last updated on March 25,2014 Authored by Sarmed Rahman1 Comment

As far asnetwork management is concerned, Nagios is oneof the most powerful tools. Nagios can monitor the reachability of remotehosts, as well as the state of services running on them. However, what if wewant to monitor something other than network services for a remote host? Forexample, we may want to monitor the disk utilization or CPU processor load of aremote host. Nagios Remote Plugin Executor (NRPE) is a tool that can help withdoing that. NRPE allows one to execute Nagios plugins installed on remotehosts, and integrate them with an existingNagios server.

This tutorial will cover how to set up NRPE on an existing Nagiosdeployment. The tutorial is primarily divided into two parts:

  • Configure remote hosts.
  • Configure a Nagios monitoring server.

We will then finish off by defining some custom commands that can be usedwith NRPE.

Configure Remote Hosts for NRPE

Step One: Installing NRPE Service

You need to install NRPE service on every remote host that you want tomonitor using NRPE. NRPE service daemon on each remote host will thencommunicate with a Nagios monitoring server.

Necessarypackages for NRPE service can easily be installed using apt-get or yum, subject to the platform. In case ofCentOS, we will need to add Repoforge repository as NRPEis not available in CentOS repositories.

On Debian, Ubuntu or Linux Mint:

# apt-get install nagios-nrpe-server

On CentOS, Fedora or RHEL:

# yum install nagios-nrpe

Step Two: Preparing Configuration File

Theconfiguration file /etc/nagios/nrpe.cfg issimilar for Debian-based and RedHat-based systems. The configuration file isbacked up, and then updated as follows.

# vim /etc/nagios/nrpe.cfg

## NRPE service port can be customized ##

server_port=5666

 

## the nagios monitoring server is permitted ##

## NOTE: There is no space after the comma ##

allowed_hosts=127.0.0.1,X.X.X.X-IP_v4_of_Nagios_server

 

## The following examples use hard-coded commandarguments.

## These parameters can be modified as needed.

 

## NOTE: For CentOS 64 bit, use /usr/lib64 instead of/usr/lib ##

 

command[check_users]=/usr/lib/nagios/plugins/check_users-w 5 -c 10

command[check_load]=/usr/lib/nagios/plugins/check_load -w15,10,5 -c 30,25,20

command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w20% -c 10% -p /dev/hda1

command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs-w 5 -c 10 -s Z

command[check_total_procs]=/usr/lib/nagios/plugins/check_procs-w 150 -c 200

Now that the configuration file is ready, NRPE service is ready to befired up.

Step Three: Initiating NRPE Service

For RedHat-based systems, the NRPE service needs to be added as a startupservice.

On Debian, Ubuntu, Linux Mint:

# service nagios-nrpe-server restart

On CentOS, Fedora or RHEL:

# service nrpe restart
# chkconfig nrpe on

Step Four: Verifying NRPE Service Status

Informationabout NRPE daemon status can be found in the system log. For a Debian-basedsystem, the log file will be /var/log/syslog. The log file for a RedHat-basedsystem will be/var/log/messages. A samplelog is provided below for reference.

nrpe[19723]: Starting up daemon

nrpe[19723]: Listening for connections on port 5666

nrpe[19723]: Allowing connections from: 127.0.0.1,X.X.X.X

In case firewall is running, TCP port 5666 should be open, which is usedby NRPE daemon.

# netstat -tpln | grep 5666

tcp    0    0   0.0.0.0:5666      0.0.0.0:*      LISTEN   19885/nrpe

Configure Nagios Monitoring Server for NRPE

The first step in configuring an existing Nagios monitoring server forNRPE is to install NRPE plugin on the server.

Step One: Installing NRPE Plugin

In case theNagios server is running on a Debian-based system (Debian, Ubuntu or LinuxMint), a necessary package can be installed using apt-get.

# apt-get install nagios-nrpe-plugin

After theplugin is installed, the check_nrpe command,which comes with the plugin, is modified a bit.

# vim /etc/nagios-plugins/config/check_nrpe.cfg

## the default command is overwritten ##

define command{

       command_name    check_nrpe

       command_line   /usr/lib/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -c '$ARG1$'

}

In case theNagios server is running on a RedHat-based system (CentOS, Fedora or RHEL), youcan install NRPE plugin using yum. On CentOS, adding Repoforge repository isnecessary.

# yum install nagios-plugins-nrpe

Now that the NRPE plugin is installed, proceed to configure a Nagiosserver following the rest of the steps.

Step Two: Defining Nagios Command for NRPE Plugin

First, we need to define a command in Nagios for using NRPE.

# vim /etc/nagios/objects/commands.cfg

## NOTE: For CentOS 64 bit, use /usr/lib64 instead of/usr/lib ##

define command{

       command_name    check_nrpe

       command_line   /usr/lib/nagios/plugins/check_nrpe -H '$HOSTADDRESS$' -c '$ARG1$'

}

Step Three: Adding Host and Command Definition

Next, define remote host(s) and commands to execute remotely on them.

The following shows sample definitions of a remote host a command toexecute on the host. Naturally, your configuration will be adjusted based onyour requirements. The path to the file is slightly different for Debian-basedand RedHat-based systems. But the content of the files are identical.

On Debian, Ubuntu or Linux Mint:

# vim /etc/nagios3/conf.d/nrpe.cfg

On CentOS, Fedora or RHEL:

# vim /etc/nagios/objects/nrpe.cfg

define host{

        use                     linux-server

       host_name               server-1

        alias                   server-1

       address                X.X.X.X-IPv4_address_of_remote_host

}

 

define service {

       host_name                      server-1

       service_description            Check Load

        check_command                   check_nrpe!check_load

       check_interval                  1

        use                             generic-service

}

Step Four: Restarting Nagios Service

Before restarting Nagios, updated configuration is verified with a dryrun.

On Ubuntu, Debian, or Linux Mint:

# nagios3 -v /etc/nagios3/nagios.cfg

On CentOS, Fedora or RHEL:

# nagios -v /etc/nagios/nagios.cfg

If everything goes well, Nagios service can be restarted.

# service nagios restart

Configuring Custom Commands with NRPE

Setup on Remote Servers

The followingis a list of custom commands that can be used with NRPE. These commands aredefined in the file /etc/nagios/nrpe.cfg locatedat the remote servers.

## Warning status when load average exceeds 1, 2 and 1for 1, 5, 15 minute interval, respectively.

## Critical status when load average exceeds 3, 5 and 3for 1, 5, 15 minute interval, respectively.

command[check_load]=/usr/lib/nagios/plugins/check_load -w1,2,1 -c 3,5,3

 

## Warning level 25% and critical level 10% for freespace of /home.

## Could be customized to monitor any partition (e.g./dev/sdb1, /, /var, /home)

command[check_disk]=/usr/lib/nagios/plugins/check_disk -w25% -c 10% -p /home

 

## Warn if number of instances for process_ABC exceeds10. Critical for 20 ##

command[check_process_ABC]=/usr/lib/nagios/plugins/check_procs-w 1:10 -c 1:20 -C process_ABC

 

## Critical if the number of instances for process_XYZdrops below 1 ##

command[check_process_XYZ]=/usr/lib/nagios/plugins/check_procs-w 1: -c 1: -C process_XYZ

Setup on Nagios Monitoring Server

To apply the custom commands defined above, we modify the servicedefinition at Nagios monitoring server as follows. The service definition couldgo to the file where all the services are defined (e.g., /etc/nagios/objects/nrpe.cfgor /etc/nagios3/conf.d/nrpe.cfg)

## example 1: check process XYZ ##

define service {

       host_name                      server-1

       service_description            Check Process XYZ

       check_command                   check_nrpe!check_process_XYZ

       check_interval                  1

        use                             generic-service

}

 

## example 2: check disk state ##

define service {

       host_name                      server-1

       service_description            Check Process XYZ

       check_command                  check_nrpe!check_disk

       check_interval                  1

        use                             generic-service

}

To sum up, NRPE is a powerful add-on to Nagios as it provides provisionfor monitoring a remote server in a highly configurable fashion. Using NRPE, wecan monitor server load, running processes, logged in users, disk states andother parameters.

Hope this helps.

 



基于STM32的循迹避障小车资料源码(高分项目),个人大四的毕业设计、经导师指导并认可通过的高分设计项目,评审分99分,代码完整确保可以运行,小白也可以亲自搞定,主要针对计算机相关专业的正在做毕设的学生和需要项目实战练习的学习者,也可作为课程设计、期末大作业。 基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(高分项目)基于STM32的循迹避障小车资料源码(
内容概要:本文详细介绍了SSM框架(Spring、SpringMVC、MyBatis)的相关知识,涵盖Maven项目管理工具、前端开发技术、HTTP协议及Tomcat服务器等内容。文章首先讲解了SSM框架的组成,包括Spring的IOC、DI、AOP等功能,SpringMVC的请求处理流程以及MyBatis的数据操作。接着介绍了Maven作为项目管理工具的作用,如依赖管理和项目构建,并详细描述了Maven的配置文件pom.xml的使用方法。此外,还探讨了HTTP协议的特点、请求响应格式,以及Web服务器Tomcat的基本概念和工作原理。最后,文章对前端开发技术进行了概述,包括HTML、CSS、JavaScript等基础知识,并简要介绍了Ajax技术。 适合人群:具备一定编程基础,特别是Java开发经验的研发人员,尤其是那些正在学习或使用SSM框架进行Web开发的工程师。 使用场景及目标:①理解SSM框架的工作原理及其各组成部分的功能;②掌握Maven的使用,包括项目创建、依赖管理、生命周期等;③熟悉HTTP协议的请求响应机制,能够处理常见的HTTP请求和响应;④掌握前端开发技术,如HTML、CSS、JavaScript等,能够进行简单的前端页面开发;⑤了解Tomcat服务器的工作原理及其配置方法。 阅读建议:本文内容丰富,涵盖了从后端到前端的多个方面,建议读者在学习过程中结合实际项目进行实践,尤其是在Maven项目管理和SSM框架的具体应用上,多动手操作,加深理解。同时,对于HTTP协议和前端开发技术,可以通过实际的网络请求和页面开发来巩固所学知识。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值