用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;

 

转载于:https://www.cnblogs.com/littlehb/p/10322522.html

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值