FreeBSD 下用nagios來監控網路伺服器和網路服務(7)

此時是不是多了一個主機和它下面的服務呢?那是肯定的,添加主機和服務可能出現的問題有如下情況:

1:配置參數出現問題,如果你沒有檢查配置就啟動nagios,可能會啟動成功,但是顯示會不正常;

解決方法:調整配置參數

2:Connection refused

當出現這個問題的時候,俺開始以為是ssh的無密碼登錄沒有成功,但是其實俺的伺服器沒有啟動該服務造成的,啟動服務即可。

 

但是這些是有埠的服務,沒有使用埠的狀態任何檢測?

使用nrpe,ok,俺們現在在伺服器上安裝nrpe:

一、遠程主機的配置

1、安裝nrpe與配置

fetch ]http://ufpr.dl.sourceforge.net/sourceforge/nagios/nrpe-2.5.2.tar.gz

tar zxvf nrpe-2.5.2.tar.gz

cd nrpe-2.5.2

./configure –enable-ssl –enable-command-args

make all

mkdir -p /usr/local/nagios/etc

mkdir /usr/local/nagios/bin

mkdir /usr/local/nagios/libexec

pw addgroup nagios

pw useradd nagios -g nagios -d /usr/local/nagios/ -s /sbin/nologin

chown -R nagios:nagios /usr/local/nagios

cp ./sample-config/nrpe.cfg /usr/local/nagios/etc

cp src/nrpe /usr/local/nagios/bin

2、啟動nrpe,埠為5666

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

netstat -ant | grep 5666

tcp4     0     0 *.5666           *.*             LISTEN

 

二、監控伺服器上的配置

1、安裝nrpe(主要是使用check_nrpe模塊)

fetch http://ufpr.dl.sourceforge.net/sourceforge/nagios/nrpe-2.5.2.tar.gz

tar zxvf nrpe-2.5.2.tar.gz

cd nrpe-2.5.2

./configure –enable-ssl –enable-command-args

make all

cp src/check_nrpe /usr/local/nagios/libexec

2、nagios文件的配置

vi checkcommands.cfg

定義check_nrpe命令

# ‘check_nrep’ command definition

define command{

command_name check_nrpe

command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

}

三、上面俺們已經配置了一部分參數,下面是配置的最終結果:

define host{

use               generic-host         ; Name of host template to use

host_name           test_nrpe

alias             client

address           10.5.1.156

check_command       check-host-alive

max_check_attempts     1

check_period         24×7

notification_interval   120

notification_period   24×7

notification_options   d,r

contact_groups admins

}

 

# ‘check_load’ command definition

define command{

command_name   check_load

command_line   $USER1$/check_load -w $ARG1$ -c $ARG2$

}

 

# ‘check_load’ command definition

define command{

command_name   check_disk

command_line   $USER1$/check_disk -w $ARG1$ -c $ARG2$

}

define service{

use                   generic-service       ; Name of service template to use

host_name               test_nrpe

service_description         PING

is_volatile               0

check_period             24×7

max_check_attempts         1

normal_check_interval       1

retry_check_interval         1

contact_groups             admins

notification_options         w,u,c,r

notification_interval       960

notification_period         24×7

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

}

 

define service{

use                   generic-service       ; Name of service template to use

host_name               test_nrpe

service_description         apache

is_volatile               0

check_period             24×7

max_check_attempts         1

normal_check_interval       1

retry_check_interval         1

contact_groups             admins

notification_options         w,u,c,r

notification_interval       960

notification_period         24×7

check_command             check_http!100.0,20%!500.0,60%

}

 

define service{

use                   generic-service       ; Name of service template to use

host_name               test_nrpe

以下文章點擊率最高

Loading…

     

如果這文章對你有幫助,請掃左上角微信支付-支付寶,給於打賞,以助博客運營