深度剖析Zabbix Web scenarios数据表结构
生活随笔
收集整理的這篇文章主要介紹了
深度剖析Zabbix Web scenarios数据表结构
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
深度剖析Zabbix Web scenarios數據表結構
前言
因開發需求,需要解析Zabbix web監控數據表結構;因為網上關于Zabbix數據表結構解析的比較少,所以心血來潮寫了一篇作為記錄。
突破口
對Zabbix數據庫表結構做解析的時候,我有個習慣,直接針對某個itemid懟。
這次當然不例外,隨便找了個Zabbix web itemid。
直接查數據庫里有哪些表
show tables like "%http%"; +---------------------------+ | Tables_in_zabbix (%http%) | +---------------------------+ | httpstep | | httpstep_field | | httpstepitem | | httptest | | httptest_field | | httptestitem | +---------------------------+用屁股猜已經猜出大概存儲的是什么內容:
- httpstep 存儲的為場景信息
- httpstepitem 存儲的為場景ID
- httptest 存儲的為步驟信息
- httptestitem 存儲的為步驟ID
剖析
以itemid為突破口
獲取到這個場景的itemID
查詢這個item所在的testID與testitemID
select * from httptestitem where itemid="56263" ; +----------------+------------+--------+------+ | httptestitemid | httptestid | itemid | type | +----------------+------------+--------+------+ | 1194 | 398 | 56263 | 4 | +----------------+------------+--------+------+根據這個itemid我們找到他對應的場景id。
獲取這個場景的幾個監控item值
- Last error message of scenario
- Download speed for scenario
- Failed step of scenario
解析一波,具體自己參照Latest data
############# # 各Type剖析 # # type類型為2代表【Download speed for scenario】 # 場景總下載速度,歷史數據存儲在history表. # # type類型為3代表【Failed step of scenario】 # 場景返回狀態碼, 0表示場景正常, 每個步驟異常為1.歷史數據存儲在history_uint表. # # type類型為4代表【Last error message of scenario】 # 上一次場景返回錯誤信息,歷史數據存儲在history_str表. # #############接下來根據場景ID找出步驟
查詢http場景下的步驟
- Download speed for step
- Response time for step
- Response code for step
解析一波,具體自己參照Latest data
############# # 各Type剖析 # # type類型為2代表【Download speed for step】 # 步驟的下載速度,歷史數據存儲在history表. # # type類型為1代表【Response time for step】 # 步驟返回時間,歷史數據存儲在history表. # # type類型為0代表【Response code for step】 # 步驟的返回狀態碼, 其中0為無法連接,無狀態碼.歷史數據存儲在history_uint表. # #############接下來剖析詳細場景與步驟
根據ID查詢場景信息
自行對應ZabbixWEB界面
select * from httptest where httptestid="398" \G; *************************** 1. row ***************************httptestid: 398name: 業務接口Aapplicationid: 800nextcheck: 1542984224delay: 1mstatus: 0agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36authentication: 0http_user: http_password: hostid: 10084templateid: 397http_proxy: retries: 1ssl_cert_file: ssl_key_file: ssl_key_password: verify_peer: 0verify_host: 0順便簡單介紹下場景下的字段表,也就是一些自定宏
select * from httptest_field limit 1; +------------------+------------+------+----------+-------------------+ | httptest_fieldid | httptestid | type | name | value | +------------------+------------+------+----------+-------------------+ | 1 | 535 | 1 | {IP} | 10.1.1.1 | +------------------+------------+------+----------+-------------------+ # type為1表示 Variables. # type為0表示 Headers.接下來查看場景里面的步驟 自行參照Steps頁面
查詢指定ID的步驟
步驟也有map字段表
select * from httpstep_field limit 1; +------------------+------------+------+----------+---------------------+ | httpstep_fieldid | httpstepid | type | name | value | +------------------+------------+------+----------+---------------------+ | 1 | 129 | 1 | {rentid} | regex:([0-9]{4,10}) | +------------------+------------+------+----------+---------------------+# type為0表示 Headers. # type為1表示 Variables. # type為2表示 Post fields.后記
文章一些數據表字段不明白都可以參照ZabbixWEB配置頁面。
另外建議大家Zabbix二次開發的時候可以懟庫就懟庫,遇到邏輯復雜沒有把握才使用API。
轉載于:https://blog.51cto.com/maoyao/2321362
總結
以上是生活随笔為你收集整理的深度剖析Zabbix Web scenarios数据表结构的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Error Kernel Pattern
- 下一篇: 【spring boot2】第2篇:配置