Zabbix使用總結


1. CentOS 7上啟動zabbix-server失敗,/var/log/messages中的報錯信息如下:

Feb 22 12:56:43 mysql-server1 systemd: Starting Zabbix Server with MySQL DB...
Feb 22 12:56:43 mysql-server1 kernel: zabbix_server[1599]: segfault at 18 ip 00007fce09ca6bd0 sp 00007fffa39b7808 error 4 in libpthread-2.17.so[7fce09c9d000+16000]
Feb 22 12:56:43 mysql-server1 systemd: zabbix-server-mysql.service: control process exited, code=killed status=11
Feb 22 12:56:43 mysql-server1 systemd: Failed to start Zabbix Server with MySQL DB.
Feb 22 12:56:43 mysql-server1 systemd: Unit zabbix-server-mysql.service entered failed state.

解決方法:

# rpm -Uvh --force ftp://bo.mirror.garr.it/1/slc/centos/7.0.1406/updates/x86_64/Packages/gnutls-3.1.18-10.el7_0.x86_64.rpm

Retrieving ftp://bo.mirror.garr.it/1/slc/centos/7.0.1406/updates/x86_64/Packages/gnutls-3.1.18-10.el7_0.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:gnutls-3.1.18-10.el7_0           ################################# [ 50%]
Cleaning up / removing...
   2:gnutls-3.3.8-12.el7              ################################# [100%]

該RPM包的下載地址為:

http://rpm.pbone.net/index.php3/stat/4/idpl/27966545/dir/centos_7/com/gnutls-3.1.18-10.el7_0.x86_64.rpm.html

 

2. CentOS 7的Zabbix官方源和epel源

    # rpm -ivh http://repo.zabbix.com/zabbix/2.2/rhel/7/x86_64/zabbix-2.2.11-1.el7.x86_64.rpm

    # rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm

    前者是Zabbix的官方源,后者是epel,前者只是安裝zabbix這個軟件,后者是安裝epel的yum源,該epel源包含了zabbix的相關軟件包,兩者只用其一即可,如果兩個都裝了,在后續安裝的過程中會報沖突。

Transaction check error:
  file /var/log/zabbix from install of zabbix22-agent-2.2.11-1.el7.x86_64 conflicts with file from package zabbix-2.2.11-1.el7.x86_64

 epel中包含的zabbix的軟件包如下所示:

zabbix20.x86_64                                             2.0.16-1.el7                               epel              
zabbix20-agent.x86_64                                       2.0.16-1.el7                               epel              
zabbix20-proxy.noarch                                       2.0.16-1.el7                               epel              
zabbix20-proxy-mysql.x86_64                                 2.0.16-1.el7                               epel              
zabbix20-proxy-pgsql.x86_64                                 2.0.16-1.el7                               epel              
zabbix20-proxy-sqlite3.x86_64                               2.0.16-1.el7                               epel              
zabbix20-server.noarch                                      2.0.16-1.el7                               epel              
zabbix20-server-mysql.x86_64                                2.0.16-1.el7                               epel              
zabbix20-server-pgsql.x86_64                                2.0.16-1.el7                               epel              
zabbix20-web.noarch                                         2.0.16-1.el7                               epel              
zabbix20-web-mysql.noarch                                   2.0.16-1.el7                               epel              
zabbix20-web-pgsql.noarch                                   2.0.16-1.el7                               epel              
zabbix22.x86_64                                             2.2.11-1.el7                               epel              
zabbix22-agent.x86_64                                       2.2.11-1.el7                               epel              
zabbix22-dbfiles-mysql.noarch                               2.2.11-1.el7                               epel              
zabbix22-dbfiles-pgsql.noarch                               2.2.11-1.el7                               epel              
zabbix22-dbfiles-sqlite3.noarch                             2.2.11-1.el7                               epel              
zabbix22-proxy.noarch                                       2.2.11-1.el7                               epel              
zabbix22-proxy-mysql.x86_64                                 2.2.11-1.el7                               epel              
zabbix22-proxy-pgsql.x86_64                                 2.2.11-1.el7                               epel              
zabbix22-proxy-sqlite3.x86_64                               2.2.11-1.el7                               epel              
zabbix22-server.noarch                                      2.2.11-1.el7                               epel              
zabbix22-server-mysql.x86_64                                2.2.11-1.el7                               epel              
zabbix22-server-pgsql.x86_64                                2.2.11-1.el7                               epel              
zabbix22-web.noarch                                         2.2.11-1.el7                               epel              
zabbix22-web-mysql.noarch                                   2.2.11-1.el7                               epel              
zabbix22-web-pgsql.noarch                                   2.2.11-1.el7                               epel    

 

3. 利用zabbix_get驗證Agent的配置是否正確

# zabbix_get -s 192.168.244.144 -p 10050 -k system.uanme
ZBX_NOTSUPPORTED

   ZBX_NOTSUPPORTED代表監控項有問題

# zabbix_get -s 192.168.244.144 -p 10050 -k agent.ping
1

 

4.  59635:20160223:161315.258 no active checks on server [192.168.244.146:10051]: host [192.168.244.146] not found

     原因:/etc/zabbix_agentd.conf中的Hostname與zabbix web頁面Monitoring->Configuration->Hosts 頁面的Name不匹配

 

5. 在執行system.run時報“ZBX_NOTSUPPORTED”錯誤

[root@localhost ~]# zabbix_get -s 192.168.244.10 -k system.run['df -h']
ZBX_NOTSUPPORTED

   原因:客戶端中配置文件中EnableRemoteCommands默認為0,沒有開啟。

   開啟后,

[root@localhost ~]# zabbix_get -s 192.168.244.10 -k system.run['df -h']
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        18G  8.7G  8.0G  53% /
tmpfs           238M     0  238M   0% /dev/shm
/dev/sda1       190M   27M  154M  15% /boot

 

6. 被動模式和主動模式的區別

    被動模式:

    1> Server打開一個TCP連接

    2> Server發送一個key為agent.ping\n

    3> Agent接受到這個請求,然后響應數據<HEADER><DATALEN>1

    4> Server對接收到的數據進行處理

    5> TCP連接關閉

    主動模式:

    1> Agent向Server建立一個TCP的連接

    2> Agent請求需要檢測的數據列表

    3> Server響應Agent,發送一個Items列表(item key,delay)

    4> Agent響應請求

    5> TCP連接關閉

    6> Agent開始周期性地收集數據。

    7> Agent向Server建議一個TCP連接

    8> Agent發送在采集周期內,需要采集的數據給Server。

    9> Server處理Agent發送的數據。

   10> TCP連接關閉

 

7. 如何禁用Zabbix的重新安裝

   禁用前:

  

   如何禁用:

   # vim /usr/share/zabbix/include/menu.inc.php

/**,
                        array(
                                'url' => 'setup.php',
                                'label' => _('Installation')
                        )**/

  禁用后:

 

  如果數據庫不變的話,重裝數據庫基本上沒影響,還是展示之前的數據。

 

8. 如何設置zabbix前端頁面的刷新時間

    右上角Profile->User->Refresh (in seconds)

 

9. Zabbix Agent的配置參數

Server:被動模式,允許哪台服務器連接Agent

ServerActive:主動模式,向哪台服務器傳送數據。

 

10. zabbix_sender

Zabbix的Trapping模式,將采集到的數據通過定時任務等主動發送給zabbix_server。

 

11. Administration->General->Housekeeper

采用表分區后,需要關閉Housekeeper的功能,因為Housekeeper對數據的清理主要是通過DELECT語句來進行的,在數據量比較大的情況下,DELETE操作執行效率比較低。 

12. Zabbix登錄用戶的賬號和密碼保存在zabbix.users表中

      其中passwd字段是用的md5算法加密

mysql> select * from zabbix.users where alias='Admin'\G
*************************** 1. row ***************************
        userid: 1
         alias: Admin
          name: Zabbix
       surname: Administrator
        passwd: 5fce1b3e34b520afeffb37ce08c7cd66
           url: 
     autologin: 1
    autologout: 0
          lang: en_GB
       refresh: 30
          type: 3
         theme: default
attempt_failed: 0
    attempt_ip: 192.168.244.1
 attempt_clock: 1488507893
 rows_per_page: 50
1 row in set (0.00 sec)

mysql> select md5('123456');
+----------------------------------+
| md5('123456')                    |
+----------------------------------+
| e10adc3949ba59abbe56e057f20f883e |
+----------------------------------+
1 row in set (0.01 sec)

 

13. Zabbix完整的監控配置流程

Host groups(主機組)-> Hosts(主機)-> Applications(監控項組)-> Items(監控項)-> Triggers(觸發器)->Event(事件)->Actions(處理動作)-> User Groups(用戶組)-> Users(用戶)-> Medias(告警方式)-> Audit(日志審計)

 

14. Graphs

個人感覺Graphs其實完全不用配置,直接查看Monitoring->Latest data->具體item的Graph

 

15. Screen

Screen將多種信息放到一起展示,便於集中展示某個Host的多個信息,或是將多個Hosts的同一種信息放到一起顯示。

這些信息可以為Graphs,Maps,Server info等,幾乎涵蓋Zabbix所有的監控信息。
 
16. Slide shows在多個Screen之間以幻燈片的方式來展示。
 
17. 日志的工作方式必須為主動模式,用zabbig_get提示不支持。
 
18. Zabbix告警的配置步驟
1. 設置Trigger
2. 配置用戶
3. 配置告警介質
4. 設置Action
其中,action包含兩部分:第一是發送信息,即將告警信息發送給用戶;第二部分是執行命令,即將事件用命令進行處理,達到對事件故障自動嘗試恢復的效果。
 
19. 如何查看已經觸發的Action
Administration-> Audit -> Actions(Action_log)
 
20. 解決zabbix Item Not supported的問題
Administration -> General -> Other -> Refresh unsupported items (in sec)
 
21.
/*
 * The cache (zbx_vc_cache_t) is organized as a hashset of item records (zbx_vc_item_t).
 *
 * Each record holds item data (itemid, value_type), statistics (hits, last access time,...)
 * and the historical data (timestamp,value pairs in ascending order).
 *
 * The historical data are stored from largest request (+timeshift) range to the
 * current time. The data is automatically fetched from DB whenever a request
 * exceeds cached value range.
 *
 * If an item is already being cached the new values are automatically added to the cache
 * after being written into database.
 *
 * When cache runs out of memory to store new items it enters in low memory mode.
 * In low memory mode cache continues to function as before with few restrictions:
 *   1) items that weren't accessed during the last day are removed from cache.
 *   2) items with worst hits/values ratio might be removed from cache to free the space.
 *   3) no new items are added to the cache.
 *
 * The low memory mode can't be turned off - it will persist until server is rebooted.
 * In low memory mode a warning message is written into log every 5 minutes.
 */

 

 

   

 

   

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM