用SQL語句查詢zabbix的監控數據


 參考地址:http://blog.51cto.com/sfzhang88/1558254
-- 獲取主機id -- 10084 select hostid from hosts where host="Zabbix server"; -- 查詢剩余磁盤itemid --28537 select itemid,key_ from items where hostid=10084 and key_="vfs.fs.size[/,free]"; -- 最后N次探查的結果 select from_unixtime(clock) as DateTime,value,ns from history_uint where itemid=28537 order by clock desc limit 10; select round(sum(1.0/i.delay),2) as qps from items i,hosts h where i.status='0' and i.hostid=h.hostid and h.status='0' and i.delay<>0; -- 主機流入量 select itemid,name,key_ from items where hostid=10084 and key_="net.if.in[eth0]"; select from_unixtime(clock) as DateTime,round(value/1024/1024,2) as Traffic_in from history_uint where itemid="28533" and from_unixtime(clock)>='2014-09-20' and from_unixtime(clock)<'2019-09-21' limit 20; -- 主機流出量 select itemid,name,key_ from items where hostid=10084 and key_="net.if.out[eth0]"; select from_unixtime(clock) as DateTime,round(value/1024/1024,2) as Traffic_out from history_uint where itemid="28534" and from_unixtime(clock)>='2014-09-20' and from_unixtime(clock)<'2014-09-21' limit 20; -- 下面SQL語句是匯總上面主機網卡的進出流量的 select from_unixtime(clock,"%Y-%m-%d %H:%i") as DateTime,sum(round(value/1024/1024,2)) as Traffic_total from history_uint where itemid in (28533,28534) and from_unixtime(clock)>='2014-09-20'and from_unixtime(clock)<'2019-09-21' group by from_unixtime(clock,"%Y-%m-%d %H:%i") limit 20; -- 查詢一天中主機流量的最大值,最小值和平均值。 select date as DateTime,round(min(traffic)/2014/1024,2) as TotalMinIN,round(avg(traffic)/1024/1024,2) as TotalAvgIN,round(max(traffic)/1024/1024,2) as TotalMaxIN from (select from_unixtime(clock,"%Y-%m-%d") as date,sum(value) as traffic from history_uint where itemid in (28533,28534) and from_unixtime(clock)>='2014-09-20' and from_unixtime(clock)<'2019-09-21' group by from_unixtime(clock,"%Y-%m-%d %H:%i") ) tmp;

 


免責聲明!

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



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