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

匿名 (未验证) 提交于 2019-12-02 23:05:13
 参考地址: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;

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!