码迷,mamicode.com
首页 > 数据库 > 详细

用SQL语句查询zabbix的监控数据

时间:2019-01-26 11:05:55      阅读:410      评论:0      收藏:0      [点我收藏+]

标签:blog   tmp   col   where   blank   and   code   hosts   zab   

 参考地址: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-20and 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;

 

用SQL语句查询zabbix的监控数据

标签:blog   tmp   col   where   blank   and   code   hosts   zab   

原文地址:https://www.cnblogs.com/littlehb/p/10322522.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!