天天看點

分布式監控之Zabbix-Agent

Zabbix agent安裝配置文檔

1. 環境準備:

Zabbix需要在被監控的host上安裝agent,在zabbix官網上下載下傳相應平台的agent包到各被監控端,按如下方式在被監控上運作agent。(注:官網上下載下傳的agent包裡沒有運作agentd所必須的配置檔案,可以從zabbix server上拷貝一份zabbix_agentd.conf,這個conf檔案是所有平台都通用的)

1) 源碼安裝

首先建立zabbix使用者來啟動zabbix服務

groupadd zabbix

useradd zabbix -g zabbix

安裝依賴服務

yum install wget make gcc gcc-c++ autoconf ncurses-devel fping -y 

下載下傳zabbix源碼包

<a href="http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.3/zabbix-2.2.3.tar.gz">http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.3/zabbix-2.2.3.tar.gz</a>

tar xzf zabbix-2.2.3.tar.gz

cd zabbix-2.2.3.

./configure  --prefix=/usr/local/zabbix  --enable-agent

make install

複制啟動腳本和配置檔案

cp misc/init.d/redhat/zabbix_agentd_ctl  /etc/init.d/

mkdir /etc/zabbix

cp misc/conf/zabbix_agentd.conf  /etc/zabbix

編輯配置檔案

vi  /etc/zabbix/zabbix_agentd.conf

Server=192.168.X.X  #這裡寫zabbix server的ip位址 如果設定了proxy則這裡寫proxy的ip位址

Hostname=zabbix-agent  #此處與zabbix網頁監控中的host名一緻

開啟zabbix_agentd服務

/etc/init.d/zabbix_agentd_ctl  start

可能需要修改zabbix_agentd_ctl 腳本,有時候裡面zabbix agent的存放路徑不對,根據實際環境修改下就可以。

一般出現什麼問題都會在/tmp/zabbix_agentd.log上有記錄,幫助排錯。

或者在server端上看/tmp/zabbix_server.log也可以。

2) yum安裝

    rpm --import http://repo.zabbixzone.com/centos/RPM-GPG-KEY-zabbixzone

    rpm -Uv http://repo.zabbixzone.com/centos/zabbixzone-release-0.0-1.noarch.rpm

    yum install zabbix-agent -y

    chkconfig zabbix-agent on

    mv /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.default

    sed 's/Server=127.0.0.1/Server=192.168.X.X/' /etc/zabbix/zabbix_agentd.default &gt; /etc/zabbix/zabbix_agentd.conf

service zabbix-agent start

在web頁面添加主機

1)這裡選擇的是手動添加

組态》主機》建立主機

<a href="http://s3.51cto.com/wyfs02/M02/53/97/wKioL1RsCxeARQoBAADmL_HdiiQ516.jpg"></a>

<a href="http://s3.51cto.com/wyfs02/M00/53/97/wKioL1RsCx3hWcdGAAEZAWCc0o8161.jpg"></a>

2)自動添加主機

詳情檢視http://www.centoscn.com/image-text/config/2013/0806/1108.html

常見錯誤排查及解決

zabbix_agentd.log裡面有出現host [] not found錯誤的解決

檢視zabbix_agentd.log時出現下列錯誤

[[email protected] ~]# tail /var/log/zabbix/zabbix_agentd.log

1266:20140523:063554.157 no active checks on server [127.0.0.1:10051]: host [zabbix.clvn.com.cn] not found

出現該錯誤的原因是一般是zabbix_agentd.conf裡面的Hostname和前端zabbix web裡面的配置不一樣所造成的,即在zabbix web頁面Monitoring-&gt;Configuration-&gt;Hosts 頁面的Name和zabbix_agentd.conf裡面的Hostname要一樣。

解決方法:

1.檢視zabbix_agentd.conf檔案中的Hostname

[root@bjsd-zabbix-x86v-app01 ~]# cat /etc/zabbix/zabbix_agentd.conf | grep Hostname

### Option: Hostname

# Value is acquired from HostnameItem if undefined.

# Hostname=

Hostname=zabbix.clvn.com.cn

### Option: HostnameItem

# Item used for generating Hostname if it is undefined. Ignored if Hostname is defined.

# HostnameItem=system.hostname

# Aliases can be used in HostMetadataItem but not in HostnameItem parameters.

2.在zabbix web頁面Monitoring-&gt;Configuration-&gt;Hosts 頁面更改Host name和zabbix_agentd.conf裡面的Hostname一樣。

3.重新啟動zabbix-agent服務

[root@zabbix ~]# service zabbix-agent restart

Shutting down Zabbix agent:                                [  OK  ]

Starting Zabbix agent:                                          [  OK  ]

4.再次檢視日志檔案

[root@bjsd-zabbix-x86v-app01 ~]# tail /var/log/zabbix/zabbix_agentd.log

  1262:20140523:063900.738 Got signal [signal:15(SIGTERM),sender_pid:2615,sender_uid:0,reason:0]. Exiting ...

  1257:20140523:063900.741 Got signal [signal:15(SIGTERM),sender_pid:2615,sender_uid:0,reason:0]. Exiting ...

  1257:20140523:063900.762 Zabbix Agent stopped. Zabbix 2.2.3 (revision 44105).

  2627:20140523:063900.929 Starting Zabbix Agent [zabbix.clvn.com.cn]. Zabbix 2.2.3 (revision 44105).

  2627:20140523:063900.929 using configuration file: /etc/zabbix/zabbix_agentd.conf

  2628:20140523:063900.941 agent #0 started [collector]

  2630:20140523:063900.943 agent #2 started [listener #2]

  2629:20140523:063900.944 agent #1 started [listener #1]

  2631:20140523:063900.947 agent #3 started [listener #3]

  2632:20140523:063900.948 agent #4 started [active checks #1]

本文轉自Devin 51CTO部落格,原文連結:http://blog.51cto.com/devingeng/1579445

繼續閱讀