天天看點

dell poweredge系列伺服器的監控

參考官方文檔位址:

安裝openmanager

http://linux.dell.com/repo/hardware/latest/

安裝check_openmanage官檔

http://folk.uio.no/trondham/soft ... .html#main-features  

以下就是openmanage安裝和配置的過程:

#--------------------------------------------------------------- 

# DELL srvadmin install and server firmware update. 

#--------------------------------------------------------------- 

# Reference Website: 

http://linux.dell.com/repo/hardware/latest/  

1. Complete this step before any of the steps below. 

   [[email protected] ~]# wget -q -O -  http://linux.dell.com/repo/hardware/latest/bootstrap.cgi  | bash 

2. Installing OpenManage Server Administrator. //安裝OpenManager務器端程式

   [[email protected] ~]# yum -y install srvadmin-all 

   Exit terminal and then re-enter. 

   [ro[email protected] ~]# /opt/dell/srvadmin/sbin/srvadmin-services.sh start 

   [[email protected] ~]# netstat -nat | grep 1311 

3. Installing firmware-tools to manage BIOS and firmware updates.//安裝固件工具,c

   [[email protected] ~]# yum -y install dell_ft_install 

   [[email protected] ~]# yum -y install $(bootstrap_firmware) 

4. Managing BIOS and firmware updates //管理BIOS和更新固件

   # Inventory firmware version levels 

     [[email protected] ~]# inventory_firmware 

   # Install any applicable updates 

     [[email protected] ~]# update_firmware --yes 

5. Allow iptables access(add one line).//修改防火牆允許遠端通路 

   [[email protected] ~]# vi /etc/sysconfig/iptables 

                :RH-Firewall-1-INPUT - [0:0] //加載規則使下面兩條生效

           -A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT 

           -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1311 -j ACCEPT 

   [[email protected] ~]# /etc/init.d/iptables restart 

6. # Addad for Centos //設定服務開機啟動 

   [[email protected] ~]# yum -y remove OpenIPMI 

   [[email protected] ~]# yum -y install  OpenIPMI 

   [[email protected] ~]# chkconfig --level 3 dataeng on 

   [[email protected] ~]# service dataeng start 

   # Dell server admin access URL: https://ip:1311 //通過WEB通路,監控主機

7. Reboot the system. 

   [[email protected] ~]# reboot 重新開機 系統加載固件更新

完成這寫openmanager安裝好了,同過https://ip:1311我們就可以通路了

配合nagios,還能将openmanager server administrator的資訊發送給nagios處理,當伺服器出現警告時,能以郵件和短信的方式發送通知,非常的友善.

下面是使用nagios的dell openmanager插件來監控dell伺服器硬體的配置過程.

首先在被監控的linux伺服器上安裝 openmanage管理程式.

且安裝配置好 nagios用戶端程式 (nagios-plugins 和 nrpe).

伺服器端:192.168.20.230(已安裝好nagios伺服器程式)

用戶端:172.16.10.69(已安裝好openmanage管理程式)

用戶端安裝和配置 nagios用戶端程式 (nagios-plugins 和 nrpe)

Nagios-plugins下載下傳位址: http://www.nagios.org/download/plugins/

Nrpe下載下傳位址: http://www.nagios.org/download/addons/

1增加使用者

[[email protected] root]# useradd nagios

設定密碼

[[email protected] root]# passwd nagios

2安裝nagios-plugins插件

解壓縮

tar -zxvf nagios-plugins-1.4.16.tar.gz

cd nagios-plugins-1.4.16

編譯安裝

./configure

make

make install

這一步完成後會在/usr/local/nagios/下生成兩個目錄libexec和share

ls /usr/local/nagios/

libexec share

修改目錄權限

chown nagios.nagios /usr/local/nagios

chown -R nagios.nagios /usr/local/nagios/libexec

3安裝nrpe

解壓縮

tar -zxvf nrpe-2.14.tar.gz

cd nrpe-2.14

編譯

./configure

輸出如下

*** Configuration summary for nrpe 2.8.1 05-10-2007 ***:

General Options:

-------------------------

NRPE port: 5666

NRPE user: nagios

NRPE group: nagios

Nagios user: nagios

Nagios group: nagios

type 'make all' to compile the NRPE daemon and client.

可以看到NRPE的端口是5666,下一步是make all

make all

輸出如下

*** Compile finished ***

If the NRPE daemon and client compiled without any errors, you

can continue with the installation or upgrade process.

Read the PDF documentation (NRPE.pdf) for information on the next

steps you should take to complete the installation or upgrade.

接下來安裝NPRE插件,daemon和示例配置檔案

安裝check_nrpe這個插件

make install-plugin

之前說過監控機需要安裝check_nrpe這個插件,被監控機并不需要,我們在這裡安裝它是為了測試的目的

安裝deamon

make install-daemon

安裝配置檔案

make install-daemon-config

現在再檢視nagios目錄就會發現有4個目錄了

[[email protected] nrpe-2.8.1]# ls /usr/local/nagios/

bin etc libexec share

按照安裝文檔的說明,是将NRPE deamon作為xinetd下的一個服務運作的.在這樣的情況下xinetd就必須要先安裝好,不過一般系統已經預設裝了 ..

4.安裝xinetd腳本,如果機器沒有安裝xinetd,要用yum安裝

[[email protected] nrpe-2.8.1]# make install-xinetd

輸出如下

/usr/bin/install -c -m 644 sample-config/nrpe.xinetd /etc/xinetd.d/nrpe

可以看到建立了這個檔案/etc/xinetd.d/nrpe

編輯/etc/xinetd.d/nrpe這個腳本

vi /etc/xinetd.d/nrpe

# default: on

# description: NRPE (Nagios Remote Plugin Executor)

service nrpe

{

flags = REUSE

socket_type = stream

port = 5666

wait = no

user = nagios

group = nagios

server = /usr/local/nagios/bin/nrpe

server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd

log_on_failure += USERID

disable = no

only_from = 127.0.0.1在後面增加監控主機的位址0.111,以空格間隔

}

改後

only_from = 127.0.0.1 192.168.20.230

編輯/etc/services檔案,增加NRPE服務

vi /etc/services

增加如下

# Local services

nrpe 5666/tcp # nrpe

重新開機xinetd服務

[[email protected] nrpe-2.8.1]# service xinetd restart .

Stopping xinetd: [ OK ]

Starting xinetd: [ OK ]

檢視NRPE是否已經啟動

[[email protected] nrpe-2.8.1]# netstat -at|grep nrpe

tcp 0 0 *:nrpe *:* LISTEN

[[email protected] nrpe-2.8.1]# netstat -an|grep 5666

tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN

可以看到5666端口已經在監聽了

5.在本機上測試NRPE是否則正常工作

之前我們在安裝了check_nrpe這個插件用于測試,現在就是用的時候.執行

/usr/local/nagios/libexec/check_nrpe -H localhost

會傳回目前NRPE的版本

也就是在本地用check_nrpe連接配接nrpe daemon是正常的

在伺服器上執行

[[email protected] nrpe-2.8.1]# /var/www/html/nagios/libexec/check_nrpe -H 172.16.10.69 

NRPE v2.8.1

也就是在伺服器上check_nrpe連接配接nrpe daemon是正常的,nagios用戶端搭建完成

注:為了後面工作的順利進行,注意本地防火牆要打開5666能讓外部的監控機通路

vi /etc/sysconfig/iptables

  -A RH-Firewall-1-INPUT -p tcp -m tcp --dport 5666 -j ACCEPT

nagios

在被監控機上下載下傳openmanage for nagios的插件.

安裝check_openmanage官檔

http://folk.uio.no/trondham/soft ... .html#main-features

wget  http://folk.uio.no/trondham/soft ... anage-3.7.11.tar.gz   

tar zxvf check_openmanage-3.7.11.tar.gz  

cd check_openmanage-3.7.11 

[[email protected] ~/check_openmanage-3.5.7]# ls -lhtr  

total 3504  

-rw-r--r--  1 45150  55150    25K Mar 19  2010 check_openmanage.8  

-rwxr-xr-x  1 45150  55150   1.1K Mar 19  2010 install.sh  

-rwxr-xr-x  1 45150  55150   406B Mar 19  2010 install.bat  

-rw-r--r--  1 45150  55150    17K Mar 19  2010 check_openmanage.pod  

-rw-r--r--  1 45150  55150   6.5K Mar 19  2010 check_openmanage.php  

-rwxr-xr-x  1 45150  55150   147K Mar 19  2010 check_openmanage  

-rw-r--r--  1 45150  55150   2.7K Mar 19  2010 README  

-rw-r--r--  1 45150  55150   533B Mar 19  2010 INSTALL  

-rw-r--r--  1 45150  55150    34K Mar 19  2010 COPYING  

-rw-r--r--  1 45150  55150    19K Mar 19  2010 CHANGES  

-rwxr-xr-x  1 45150  55150   3.1M Mar 19  2010 check_openmanage.exe  

-rw-r--r--  1 45150  55150   4.4K Mar 19  2010 check_openmanage.spec  

解壓後就可以使用.

cp check_openmanage-3.5.7/check_openmanage /usr/local/nagios/libexec/  

cd /usr/local/nagios/libexec/  

chown nagios.nagios check_openmanage  

chmod 775 check_openmanage 

check_openmanage有兩種方式獲得Dell伺服器的硬體資訊.

1. 通過本地運作獲得.

2. 通過snmp的方式獲得.

我這裡用的是nrpe的插件調用的方式進行監控的.

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

# 添加一行.  

    command[check_openmanage]=/usr/local/nagios/libexec/check_openmanage  

/etc/init.d/xinetd restart 

這樣整個用戶端的openmanage for nagios的插件就安裝好了。

在nagios監控機上.我們增加配置

        Nagios程式安裝在/var/www/html/nagios

修改配置檔案

修改nagios的主配置檔案nagios.cfg

vi /var/www/html/nagios/etc/nagios.cfg

添加新主機的配置檔案位址

cfg_file= /var/www/html/nagios/etc/objects/web1.cfg

vi /var/www/html/nagios/etc/objects/comments.cfg

vi /usr/local/nagios/etc/commands.cfg

在最後面增加如下内容,添加check_nrpe指令

# 'check_nrpe ' command definition

define command{

command_name check_nrpe

command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

}

意義如下

command_name check_nrpe

定義指令名稱為check_nrpe,在services.cfg中要使用這個名稱.

command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

這是定義實際運作的插件程式.這個指令行的書寫要完全按照check_nrpe這個指令的用法.不知道用法的就用check_nrpe –h檢視

-c後面帶的$ARG1$參數是傳給nrpe daemon執行的檢測指令,之前說過了它必須是nrpe.cfg中所定義的那5條指令中的其中一條.在services.cfg中使用check_nrpe的時候要用!帶上這個參數

建立一個主機配置檔案

Vi /var/www/html/nagios/etc/objects/web1.cfg  

# 添加以下内容.  

# Check DEll Server.  

define host{

        use                     linux-server

        host_name                dell.web1

        alias                    dell_manage

        address                 172.16.10.69

        }

define service{  

        use                generic-service  

        host_name                dell.web1  

        service_description      DELL Server status  

        check_command         check_nrpe!check_openmanage  

        } 

配置完成後重新開機nagios服務

這樣就可以通過nagios監控到dell伺服器的硬體狀态了,有故障就會發送警報,很友善.   

附錄:

可以用/usr/local/nagios/libexec/check_nrpe –h檢視這個指令的用法

可以看到用法是check_nrpe –H 被監控的主機 -c要執行的監控指令

注意:-c後面接的監控指令必須是nrpe.cfg檔案中定義的.也就是NRPE daemon隻運作nrpe.cfg中所定義的指令

檢視NRPE的監控指令

cd /usr/local/nagios/etc

vi nrpe.cfg

找到下面這段話

# The following examples use hardcoded command arguments...

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_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

紅色部分是指令名,也就是check_nrpe 的-c參數可以接的内容,等号=後面是實際執行的插件程式(這與commands.cfg中定義指令的形式十分相似,隻不過是寫在了一行).也就是說check_users就是等号後面/usr/local/nagios/libexec/check_users -w 5 -c 10的簡稱.

我們可以很容易知道上面這5行定義的指令分别是檢測登陸使用者數,cpu負載,hda1的容量,僵屍程序,總程序數.各條指令具體的含義見插件用法(執行”插件程式名 –h”)

由于-c後面隻能接nrpe.cfg中定義的指令,也就是說現在我們隻能用上面定義的這五條指令.我們可以在本機實驗一下.執行

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_users

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_load

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_hda1

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_zombie_procs

/usr/local/nagios/libexec/check_nrpe -H localhost -c check_total_procs

監控腳本檔案:

#!/bin/bash

# Program : check_dell_omreport

# Version : 1.0

# Date    : Jul 28 2012

# Author  : huky - [email protected]

# Summary : a simple nagios/icinga plugin that checks the status of chassis &

#           storage on Dell PowerEdge servers with omreport in Dell Openmanager

# Licence : GPL - summary below, full text at http://www.fsf.org/licenses/gpl.txt

#這裡指定openmanager安裝路徑,預設是/opt/dell/srvadmin

DELL_SRV_DIR=/opt/dell/srvadmin

PATH=$PATH:$DELL_SRV_DIR/oma/bin:$DELL_SRV_DIR/bin:$DELL_SRV_DIR/sbin

#OMREPORT=`find $DELL_SRV_DIR -name omreport 2> /dev/null`

STOR_CTRL=/tmp/dell.storage.ctr

LOG_FILE=/tmp/dell_omreport.log

STATE_OK=0

STATE_WARNING=1

STATE_CRITICAL=2

STATE_UNKOWN=3

if [ ! -d $DELL_SRV_DIR ]; then

        echo "Please install OpenManger and define the PATH after DELL_SRV_DIR" && exit $STATE_UNKOWN

fi

/etc/init.d/dataeng status >> /dev/null

if [ ! $? -eq 0 ]; then

        echo "Please start the service dataeng" && exit $STATE_UNKOWN

fi

#check chassis

omreport chassis | grep ^[^Ok] | grep ":" | sed '/COMPONENT/d' > $LOG_FILE

#check storage

omreport storage controller | grep "^ID" | cut -d":" -f2 > $STOR_CTRL

if [ ! -s $STOR_CTRL ]; then

        echo "Have you installed the package for storage?" >> $LOG_FILE

fi

for CONTR_ID in `cat $STOR_CTRL`

do

        omreport storage controller controller=$CONTR_ID | grep -2 ^Status | sed '/--/d' | awk '{if (NR%5==0){print $0} else {printf"%s ",$0}}' | grep -v Ok | tr -s " *" " " >> $LOG_FILE

done

if [ -s $LOG_FILE ]; then

        paste -s $LOG_FILE > $LOG_FILE.2

        if [ `grep -c "Critical" $LOG_FILE` -eq `grep -c "\-Critical" $LOG_FILE` ]; then

                echo `cat $LOG_FILE.2` && exit $STATE_WARNING

        else

                echo `cat $LOG_FILE.2` && exit $STATE_CRITICAL

        fi

else

        echo "Machine is Health" && exit $STATUS_OK

fi

繼續閱讀