用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

时间: 2024-10-28 11:09:19

用SQL语句查询zabbix的监控数据的相关文章

sql语句查询后几行数据并倒着排列

$conn = mysql_connect("数据库地址","用户名","密码"); if(!$conn) { die("mysql conn failed"); } else{ mysql_query("SET NAMES 'utf8'"); mysql_select_db("数据表",$conn); if(!$conn) { die("database selected f

SQL语句查询某字段不同数据的个数(DISTINCT 的使用)

今天做了一个题,学到了一个知识点: 有一个高速收费表VF,如下: 统计收费涉及的车辆有多少: SQL语句: SELECT  COUNT(DISTINCT  VchReg)  from  VF ; 其中DISTINCT翻译为明显的.清楚的,在这里用作消除重复行,在此为消除VF表中VchReg字段的重复行,得到的即为涉及的车辆.

sql语句查询某一天数据

--如果还有今天以后的数据 --一周内呢SELECT * FROM TB WHERE datediff(dd,DATE_TIME,getdate()) between 0 and 7 --从现在起往前算24小时内的呢?SELECT * FROM TB WHERE datediff(hh,DATE_TIME,getdate()) between 0 and 23

sql语句查询重复的数据

查找所有重复标题的记录:SELECT *FROM t_info aWHERE ((SELECT COUNT(*)FROM t_infoWHERE Title = a.Title) > 1)ORDER BY Title DESC一.查找重复记录1.查找全部重复记录Select * From 表 Where 重复字段 In (Select 重复字段 From 表 Group By 重复字段 Having Count(*)>1)2.过滤重复记录(只显示一条)Select * From HZT Whe

使用sql语句查询日期在一定时间内的数据

使用sql语句查询日期在一周内的数据 select * from ShopOrder where datediff(week,ordTime,getdate()-1)=0   //查询当天日期在一周年的数据 select * from ShopOrder where datediff(day,ordTime,getdate()-1)=0   //查询当天的所有数据 SELECT * FROM A where datediff(d,datetime,getdate()) <=30 //前30天 S

如何用SQL语句查询Excel数据?

如何用SQL语句查询Excel数据?Q:如何用SQL语句查询Excel数据? A:下列语句可在SQL SERVER中查询Excel工作表中的数据. 2007和2010版本: SELECT*FROMOpenDataSource( 'Microsoft.ACE.OLEDB.12.0', 'Data Source="c:\book1.xlsx";User ID=Admin;Password=;Extended properties=Excel 12.0')...[Sheet1$] 复制代码

转 mysql 中sql 语句查询今天、昨天、7天、近30天、本月、上一月 数据

转自 http://blog.csdn.net/ve_love/article/details/19685399 转 mysql 中sql 语句查询今天.昨天.7天.近30天.本月.上一月 数据

sql语句查询是有关时间的运算

SELECT WmsStock.sku_id,WmsStock.stock_num,WmsStock.product_date,WmsStock.expire_date,WmsStock.cost_price,GoodsSku.sku_name,GoodsSku.barcode, CONVERT(((UNIX_TIMESTAMP(WmsStock.expire_date)-UNIX_TIMESTAMP(WmsStock.product_date))/(60*60*24)),SIGNED) AS

sql语句查询同一表内多字段同时重复的记录 sql数据库重复记录删除

分享下用sql语句删除数据库中重复记录的方法.比如现在有一人员表 (表名:peosons) 若想将姓名.身份证号.住址这三个字段完全相同的记录查询出来select p1.* from persons p1,persons p2 where p1.id<>p2.id and p1.cardid = p2.cardid and p1.pname = p2.pname and p1.address = p2.address可以实现上述效果.几个删除重复记录的SQL语句 1.用rowid方法2.用gr