zabbix主動、被動檢測的詳細過程與區別

weixin_30484739發表於2015-11-13

最近專案再寫採集器採集軟體指標的功能,藉此機會學習學習zabbix監控的一些知識。

http://www.ttlsa.com/zabbix/zabbix-active-and-passive-checks/

zabbix agent檢測分為主動(agent active)和被動(agent)兩種形式,主動與被動的說法均是相對於agent來討論的。簡單說明一下主動與被動的區別如下:

主動:agent請求server獲取主動的監控項列表,並主動將監控項內需要檢測的資料提交給server/proxy

被動:server向agent請求獲取監控項的資料,agent返回資料。

 

zabbix agent通訊過程中的協議均基於json格式,格式如下:


備註:為了避免記憶體耗盡,server限制每個通訊連線最多使用128MB記憶體。

被動檢測

server發起如下請求

Aegent返回如下響應資料

supported items通訊過程

  • Server開啟一個TCP連線
  • Server傳送請求agent.ping\n
  • Agent接收到請求並且響應<HEADER><DATALEN>1
  • Server處理接收到的資料1
  • 關閉TCP連線

not supported items通訊過程

  • Server開啟一個TCP連線
  • Server傳送請求vfs.fs.size[/nono]\n
  • Agent接收請求並且返回響應資料 <HEADER><DATALEN>ZBX_NOTSUPPORTED\0Cannot obtain filesystem information: [2] No such file or directory
  • Server接收並處理資料, 將item的狀態改為“ not supported ”
  • 關閉TCP連線

 

主動檢測

如前面所說,zabbix首先向ServerActive配置的IP請求獲取active items,獲取並提交active tiems資料值server或者proxy。很多同學會提出疑問:zabbix多久獲取一次active items?它會根據配置檔案中的RefreshActiveChecks的頻率進行,如果獲取失敗,那麼將會在60秒之後重試
獲取ACTIVE ITEMS列表

Agent請求


Server響應列表
備註:獲取到的items列表中的所有item屬性key, delay, lastlogsize ,mtime都必須存在,獲取列表的通訊過程如下:
  • Agent開啟TCP連線(主動檢測變成Agent開啟)
  • Agent請求items檢測列表
  • Server返回items列表
  • Agent 處理響應
  • 關閉TCP連線
  • Agent開始收集資料

提交active items資料

Agent傳送請求


Server響應資料


備註:如果有些資料提交失敗,比如host、item被刪除或者禁用,agent不會嘗試從新提交

主動檢測提交資料過程如下:

  • Agent建立TCP連線
  • Agent提交items列表收集的資料
  • Server處理資料,並返回響應狀態
  • 關閉TCP連線
在這裡agent向server傳送的資料是經過agent處理的資料,server拿到資料後就無需再次請求這些資料。只需儲存這些資料即可。

轉載於:https://www.cnblogs.com/yeemi/p/7470169.html

相關文章