日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

深度剖析Zabbix Web scenarios数据表结构

發(fā)布時間:2025/7/14 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 深度剖析Zabbix Web scenarios数据表结构 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

深度剖析Zabbix Web scenarios數(shù)據(jù)表結(jié)構(gòu)

前言

因開發(fā)需求,需要解析Zabbix web監(jiān)控數(shù)據(jù)表結(jié)構(gòu);因為網(wǎng)上關于Zabbix數(shù)據(jù)表結(jié)構(gòu)解析的比較少,所以心血來潮寫了一篇作為記錄。

突破口

對Zabbix數(shù)據(jù)庫表結(jié)構(gòu)做解析的時候,我有個習慣,直接針對某個itemid懟。

這次當然不例外,隨便找了個Zabbix web itemid。

直接查數(shù)據(jù)庫里有哪些表

show tables like "%http%"; +---------------------------+ | Tables_in_zabbix (%http%) | +---------------------------+ | httpstep | | httpstep_field | | httpstepitem | | httptest | | httptest_field | | httptestitem | +---------------------------+

用屁股猜已經(jīng)猜出大概存儲的是什么內(nèi)容:

  • 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 | +----------------+------------+--------+------+

根據(jù)這個itemid我們找到他對應的場景id。

獲取這個場景的幾個監(jiān)控item值

  • Last error message of scenario
  • Download speed for scenario
  • Failed step of scenario
select * from httptestitem where httptestid="398"; +----------------+------------+--------+------+ | httptestitemid | httptestid | itemid | type | +----------------+------------+--------+------+ | 1192 | 398 | 56261 | 2 | | 1193 | 398 | 56262 | 3 | | 1194 | 398 | 56263 | 4 | +----------------+------------+--------+------+

解析一波,具體自己參照Latest data

############# # 各Type剖析 # # type類型為2代表【Download speed for scenario】 # 場景總下載速度,歷史數(shù)據(jù)存儲在history表. # # type類型為3代表【Failed step of scenario】 # 場景返回狀態(tài)碼, 0表示場景正常, 每個步驟異常為1.歷史數(shù)據(jù)存儲在history_uint表. # # type類型為4代表【Last error message of scenario】 # 上一次場景返回錯誤信息,歷史數(shù)據(jù)存儲在history_str表. # #############

接下來根據(jù)場景ID找出步驟

查詢http場景下的步驟

  • Download speed for step
  • Response time for step
  • Response code for step
select * from httpstepitem where httpstepid="398"; +----------------+------------+--------+------+ | httpstepitemid | httpstepid | itemid | type | +----------------+------------+--------+------+ | 1192 | 398 | 56180 | 2 | | 1193 | 398 | 56181 | 1 | | 1194 | 398 | 56182 | 0 | +----------------+------------+--------+------+

解析一波,具體自己參照Latest data

############# # 各Type剖析 # # type類型為2代表【Download speed for step】 # 步驟的下載速度,歷史數(shù)據(jù)存儲在history表. # # type類型為1代表【Response time for step】 # 步驟返回時間,歷史數(shù)據(jù)存儲在history表. # # type類型為0代表【Response code for step】 # 步驟的返回狀態(tài)碼, 其中0為無法連接,無狀態(tài)碼.歷史數(shù)據(jù)存儲在history_uint表. # #############

接下來剖析詳細場景與步驟

根據(jù)ID查詢場景信息

自行對應ZabbixWEB界面

select * from httptest where httptestid="398" \G; *************************** 1. row ***************************httptestid: 398name: 業(yè)務接口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的步驟

select * from httpstep where httptestid="398"\G; *************************** 1. row ***************************httpstepid: 412httptestid: 398name: 業(yè)務接口Ano: 1url: https://baidu.comtimeout: 15sposts: required: status_codes: follow_redirects: 0retrieve_mode: 0post_type: 0# no代表場景的步驟 # required表示步驟正常返回字符串,填寫內(nèi)容為正則表達式.

步驟也有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.

后記

文章一些數(shù)據(jù)表字段不明白都可以參照ZabbixWEB配置頁面。
另外建議大家Zabbix二次開發(fā)的時候可以懟庫就懟庫,遇到邏輯復雜沒有把握才使用API。

轉(zhuǎn)載于:https://blog.51cto.com/maoyao/2321362

總結(jié)

以上是生活随笔為你收集整理的深度剖析Zabbix Web scenarios数据表结构的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。