select FROM_UNIXTIME(clock) as DateTime, value, round(value/1024,2) as Traffic_in
from history_uint
where itemid="28770"
; # 10270
select * from hosts where host='192.168.58.129'; select * from items where hostid='10270'; # 创建监控项与历史值得视图
create or replace view v_item_history_uint
(host_id, item_name, item_id, item_key, status, data_time, value)
AS
select t1.hostid as host_id, t1.itemid as item_id , t1.name as item_name, t1.key_ as item_key, t1.`status`, FROM_UNIXTIME(clock) as data_time, t2.`value`
from items t1, history_uint t2
where t1.itemid = t2.itemid
; create or replace view v_item_history
(host_id, item_name, item_id, item_key, status, data_time, value)
AS
select t1.hostid as host_id, t1.itemid as item_id , t1.name as item_name, t1.key_ as item_key, t1.`status`, FROM_UNIXTIME(clock) as data_time, t2.`value`
from items t1, history t2
where t1.itemid = t2.itemid
; select * from v_item_history_uint where item_key='net.if.in[ens32]' order by data_time desc;
select * from v_item_history_uint where item_key='vm.memory.size[total]' order by data_time desc; # 收集主机状态列表
create or replace view v_host_info_tmp
(host_id, host_name, host_ip, status,cpu_used_pct, ava_mem, total_mem, net_in, net_out)
as
select t1.hostid as host_id, t1.`host` as host_name, t2.ip as host_ip, t1.`status`,
(select round(value*100,2) from v_item_history v1 where v1.host_id = t1.hostid and v1.item_key='system.cpu.load[percpu,avg1]' order by data_time desc limit 0,1) as cpu_used_pct,
(select value from v_item_history_uint v1 where v1.host_id = t1.hostid and v1.item_key='vm.memory.size[available]' order by data_time desc limit 0,1) as ava_mem,
(select value from v_item_history_uint v1 where v1.host_id = t1.hostid and v1.item_key='vm.memory.size[total]' order by data_time desc limit 0,1) as total_mem,
(select round(value/1024,2) from v_item_history_uint v1 where v1.host_id = t1.hostid and v1.item_key='net.if.in[ens32]' order by data_time desc limit 0,1) as net_in,
(select round(value/1024,2) from v_item_history_uint v1 where v1.host_id = t1.hostid and v1.item_key='net.if.out[ens32]' order by data_time desc limit 0,1) as net_out
from hosts t1, interface t2
where t1.hostid = t2.hostid
; create or replace view v_host_info
(host_id, host_name, host_ip, status, cpu_used_pct, memory_used_pct, net_in, net_out)
as
select host_id, host_name, host_ip, status, cpu_used_pct, round(1-ava_mem/total_mem,2) as memory_used_pct, net_in, net_out
from v_host_info_tmp; select * from items; SELECT
a.ip,
b.ip
FROM
`interface` a
LEFT JOIN (
SELECT DISTINCT
ip
FROM
`hosts_templates` AS h
JOIN `interface` AS i ON i.hostid = h.hostid
WHERE
h.templateid = 10465
) AS b ON a.ip = b.ip
ORDER BY
b.ip DESC;

基于zabbix的数据库查询各种监控数据的更多相关文章

  1. [ python3 ] 基于zabbix 自动抓取每天监控数据

    通过python登录到zabbix直接抓取每天的数据的图片趋势图,并制作成静态index.html给与展示并发送提示邮件. 操作系统:Centos6.7 python版本:python3.5 #!/u ...

  2. laravel数据库查询返回的数据形式

    版本:laravel5.4+ 问题描述:laravel数据库查询返回的数据不是单纯的数组形式,而是数组与类似stdClass Object这种对象的结合体,即使在查询构造器中调用了toArray(), ...

  3. 基于zabbix 的memached 多实例监控

    基于zabbix 的memached 多实例监控 zabbix agentd 配置文件新增配置: UserParameter=memcached.server.discovery[*],ps uax ...

  4. SQL数据库查询一列数据返回一行

    SQL:数据库合并列数据:遇到一个更新的问题 想要把查询到的数据某一列拼接成字符串形式返回用的是SQL数据库中的STUFF函数比如 查询到的表(u_College)如下Id Name Age Clas ...

  5. 在vue中的form表单中下拉框中的数据来自数据库查询到的数据

    文章目录 1.实现的效果: 2.前端html代码 3.js中的代码 4.后端的方法 1.实现的效果: 增加一个新的类型到数据库 2.前端html代码 需要注意的部分:prop后边是表单中的字段 v-m ...

  6. Java基于POI实现excel任意多级联动下拉列表——支持从数据库查询出多级数据后直接生成【附源码】

     Excel相关知识点 (1)名称管理器--Name Manager [CoderBaby]首先需要创建多个名称(包含key及value),作为下拉列表的数据源,后续通过名称引用.可通过菜单:&quo ...

  7. 从后台数据库查询的List数据怎么在前台combobox显示

    后台直接从数据库,通过jdbcTemplate查询数据,得到List数据集,里面是Map List<Map<String, Object>> list =  jdbcTempl ...

  8. MySql数据库-查询、插入数据时转义函数的使用

    最近在看一部php的基础视频教程,在做案例的时,当通过用户名查询用户信息的时候,先使用了转义函数对客户提交的内容进行过滤之后再交给sql语句进行后续的操作.虽然能看到转义函数本身的作用,但是仍然有一些 ...

  9. sql server数据库查询取出重复数据记录

    问题:博主在2011年6月,广东技术师范大学大四的时候,从学校计算机科学学院网站看到招聘信息并到广东中原地产IT部面试,很清楚记得当时的面试题目:怎么从数据库里面查询重复记录. 解决方案:在sql s ...

  10. 转 zabbix 优化方法 以及 后台数据库查询方法 两则

    ############sample 1 https://blog.51cto.com/sfzhang88/1558254 如何从Zabbix数据库中获取监控数据 sfzhang关注6人评论40627 ...

随机推荐

  1. linux-介绍

  2. [转帖]SQL Server 2008~2022版本序列号/密钥/激活码 汇总

    https://www.cnblogs.com/cqpanda/p/16148822.html SQL Server 2022# Enterprise: J4V48-P8MM4-9N3J9-HD97X ...

  3. [转帖]使用 Grafana 监控 TiDB 的最佳实践

    https://docs.pingcap.com/zh/tidb/stable/grafana-monitor-best-practices 使用 TiUP 部署 TiDB 集群时,如果在拓扑配置中添 ...

  4. [转帖]云数据库是杀猪盘么,去掉中间商赚差价,aws数据库性能提升 10 倍!价格便宜十倍。

    https://tidb.net/blog/021059f1 于是乎dba中的冯大嘴喊出了云数据库就是杀猪盘.让每个公司自建数据库. 那么有没有一种数据库又便宜又好用呢.有 哪就是tidb数据库. 之 ...

  5. [转帖]TiDB系统调参实战经验

    https://tidb.net/blog/c9466c40#TiDB%E7%B3%BB%E7%BB%9F%E8%B0%83%E5%8F%82%E5%AE%9E%E6%88%98%E7%BB%8F%E ...

  6. [转帖]Jmeter脚本录制:Jmeter5.0脚本录制

    第一部分进行jmeter设置 第一步:在JMeter中添加线程组 第二步:在线程组下添加HTTP请求默认值 添加->配置元件->HTTP请求默认值,设置服务器IP和端口号 第三步:在线程组 ...

  7. [转帖]jmap执行失败了,怎么获取heapdump?

    https://www.jianshu.com/p/f4bfd169b4ca   在之前的OOM问题复盘中,我们添加了jmap脚本来自动dump内存现场,方便排查OOM问题. 但当我反复模拟OOM场景 ...

  8. Springboot tomcat.threads线程数学习

    Springboot tomcat.threads线程数学习 摘要 压测完nginx 突然想搞一下springboot内嵌的tomcat的 threads的参数 一不做二不休, 直接就着脚本进行学习和 ...

  9. SPECJVM2008 再学习

    SPECJVM2008 再学习 摘要 昨天的太水了 感觉今天有必要再水一点.. 存在的问题 默认进行启动 sunflow 必定过不去. 一般的解决办法要求进行重新编译 但是我不知道怎么下载源码... ...

  10. buildkit ctr 与 k3s的简单学习

    摘要 前面一部分学习了 buildkit的简单搭建 也学习会了如果build images的简单处理 但是搭建镜像只是万里长征第一步. 如何进行微服务部署,才是关键的第二步. 公司最近使用基于K3S的 ...