Jamyy's Weblog

Zabbix 安裝暨操作備忘

by Jamyy on 七月.13, 2012, under Linux

在 CentOS 6 安裝 Zabbix Server, 監視裝有 Zabbix Agent 之伺服器或個人電腦的系統狀態, 可及早發現系統問題, 或作為電腦是否需要升級的參考依據。

環境:

  • Zabbix Server: CentOS 6.2, zabbix 2.0.1
  • Zabbix Clients: Linux hosts with zabbix agent 2.0.1, Windows hosts with zabbix agent 2.0.0

Zabbix Server 需求套件

# yum install mysql-server mysql-devel libcurl-devel net-snmp-devel \
   php php-gd php-xml php-mysql php-mbstring php-bcmath httpd

安裝 Zabbix Server

取得 Zabbix 原始碼: http://www.zabbix.com/download.php

# tar zxf zabbix-2.0.1.tar.gz -C /usr/local/src
# cd /usr/local/src/zabbix-2.0.1
# ./configure --prefix=/opt/zabbix-2.0.1 --enable-server --enable-agent \
   --with-mysql --with-libcurl --with-net-snmp --enable-ipv6

# make install

# mysql -u root -p -A mysql

mysql> create database zabbix;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql> quit

# cd /usr/local/src/zabbix-2.0.1/database/mysql
# mysql -u root -p -A zabbix < schema.sql
# mysql -u root -p -A zabbix < images.sql
# mysql -u root -p -A zabbix < data.sql

# cd /opt
# ln -s zabbix-2.0.1 zabbix
# vi /opt/zabbix/etc/zabbix_server.conf

DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

# groupadd zabbix
# useradd -g zabbix -s /sbin/nologin -M zabbix

啟動 Zabbix Server 與 Zabbix Agent Daemon

# /opt/zabbix/sbin/zabbix_server
# /opt/zabbix/sbin/zabbix_agentd

開機自動啟動

# echo "/opt/zabbix/sbin/zabbix_server" >> /etc/rc.d/rc.local
# echo "/opt/zabbix/sbin/zabbix_agentd" >> /etc/rc.d/rc.local

在 Zabbix Server 安裝 Web 介面

# cp -r /usr/local/src/zabbix-2.0.1/frontends/php/. /var/www/zabbix/
# chown apache:apache /var/www/zabbix/conf

# vi /etc/php.ini

date.timezone = "Asia/Taipei"
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
memory_limit = 128M

# vi /etc/httpd/conf.d/zabbix.conf

Alias /zabbix /var/www/zabbix
<Directory /var/www/zabbix>
    AllowOverride Limit
    Order allow,deny
    Allow from 192.168.
</Directory>

# service httpd restart

Web 介面安裝步驟

瀏覽器連入: http://my.linux.host/zabbix/, 登入帳號: admin, 預設密碼: zabbix

# chown -R root:root /var/www/zabbix/conf

Zabbix Agent @ Linux 安裝步驟

# ./configure --prefix=/opt/zabbix-2.0.1 --enable-agent
# make install
# cd /opt
# ln -s zabbix-2.0.1 zabbix
# vi /opt/zabbix/etc/zabbix_agentd.conf

Server=zabbix.server.name.or.ip
Hostname=my.host.name

# groupadd zabbix
# useradd -g zabbix -s /sbin/nologin -M zabbix
# /opt/zabbix/sbin/zabbix_agentd
# echo "/opt/zabbix/sbin/zabbix_agentd" >> /etc/rc.d/rc.local

Zabbix Agent @ Windows 安裝步驟

1. 取得 Zabbix Agent for Windows: http://www.zabbix.com/download.php

2. 將 win32 (32位元) 或 win64 (64位元) 裡的檔案解壓縮到 C:\zabbix

3. 以 Administrator 身份執行 cmd

4. 產生 zabbix_agentd.conf 設定檔
> echo Server=zabbix.server.name.or.ip > c:\zabbix\zabbix_agentd.conf

5. 註冊 Zabbix Agent 服務
> c:\zabbix\zabbix_agentd.exe --config c:\zabbix\zabbix_agentd.conf --install

6. 啟動 Zabbix Agent 服務
> net start "Zabbix Agent"

7. 開機自動啟動 Zabbix Agent 服務 (注意空格)
> sc config "Zabbix Agent" start= auto

註: 如果沒有出現防火牆開放提示, 必須到控制台手動操作防火牆設定, 允許 C:\zabbix\zabbix_agentd.exe 通過防火牆, 或開放 TCP 10050 port

Zabbix Server Web 介面基本操作

變更 admin 密碼

Administration → Users → Members: Admin → Change password → Save

設定上班時間 圖表會以灰/白色區別工作時間

Administration → General → 最右邊的下拉選單: Working time

監視本機 (Zabbix Server)

Configuration → Status: Not monitored (點擊) → Enable host? (OK)

監視裝有 Zabbix Agent 的 Linux 主機

Configuration → Hosts → Create host

Host:

Host name: myhost.mydomain.com
Visible name: myhost
Groups - In groups: Linux servers
Agent interfaces: myhosts.ip.address

Templates:

Add → (勾選) Template OS Linux → Select → Save

監視裝有 Zabbix Agent 的 Windows 主機

Configuration → Hosts → Create host

Host:

Host name: my.computer.name
Visible name: my computer
New host group: Windows servers
Agent interfaces: my.computers.ip.address

Templates:

Add → (勾選) Template OS Windows → Select → Save

監視支援 SNMP 的網路設備

Configuration → Hosts → Create host

Host:

Host name: my.firewall
Visible name: my firewall
New host group: Firewalls
Agent interfaces: Remove
SNMP interfaces: Add → my.firewalls.ip.address

Templates:

Add →
    (勾選) Template SNMP Generic
    (勾選) Template SNMP Interfaces
    (勾選) Template SNMP Processors
→ Select → Save

Ref: Zabbix Manual



:, , , ,