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

Posted 黄海的编程知识世界

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用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-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的监控数据的主要内容,如果未能解决你的问题,请参考以下文章

如何从Zabbix数据库中获取监控数据

如何实施zabbix对mysql全面监控

我要用sql语句查询出MySql的各项监控指标...

如何在Zabbix上安装MySQL监控插件PMP,zabbixpmp

zabbix监控windows mysql脚本报错

玩转 Zabbix: 用 LLD 完全自动化监控 Oracle