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. [转帖]TiDB 内存控制文档

    https://docs.pingcap.com/zh/tidb/stable/configure-memory-usage 目前 TiDB 已经能够做到追踪单条 SQL 查询过程中的内存使用情况,当 ...

  2. [转帖]tidb4.0.4使用tiup扩容TiKV 节点

    https://blog.csdn.net/mchdba/article/details/108896766 环境:centos7.tidb4.0.4.tiup-v1.0.8 添加两个tikv节点   ...

  3. [转帖]PostgreSQL 压测工具pgbench

    1.命令 pgbench --help pgbench is a benchmarking tool for PostgreSQL. Usage:   pgbench [OPTION]... [DBN ...

  4. [转帖]cx_Oracle.DatabaseError: ORA-28040

    背景: python第三方库cx-Oracle连接Oracle数据库报错 ORA-28040 cx_Oracle.DatabaseError: ORA-28040: No matching authe ...

  5. [转帖]简单理解Linux的Memory Overcommit

    https://zhuanlan.zhihu.com/p/551677956 Memory Overcommit的意思是操作系统承诺给进程的内存大小超过了实际可用的内存.一个保守的操作系统不会允许me ...

  6. [转帖][译]ARM大小核架构白皮书

    https://zhuanlan.zhihu.com/p/33411449 ARM big.LITTLE Processing with ARM Cortex-A15 & Cortex-A7 ...

  7. 银河麒麟系统信息获取V1.0版本

    银河麒麟系统信息获取 摘要 最近项目有一些兼容性测试需求. 可能需要获取一些系统配置信息便于相关的工作. 想着自己总结一下. 便于后续的不太熟悉的同事进行简要处理 银河麒麟获取版本 nkvers # ...

  8. Nginx反向代理总结

    反向代理的种类 1. LVS的方案 2. DNS轮询的方案 3. Nginx的4层代理 4. Nginx的7层代理 5. 网络NAT的处理 Nginx的反向代理-四层` 编译时增加 --with-st ...

  9. TienChin 引入 MyBatisPlus

    在父工程当中添加版本号,统一管理: <mybatis-plus.version>3.5.1</mybatis-plus.version> 在父工程当中添加 MyBatisPlu ...

  10. 从零开始搭建医药领域知识图谱实现智能问答与分析服务(含码源):含Neo4j基于垂直网站数据的医药知识图谱构建、医药知识图谱的自动问答等

    从零开始搭建医药领域知识图谱实现智能问答与分析服务(含码源):含Neo4j基于垂直网站数据的医药知识图谱构建.医药知识图谱的自动问答等 项目介绍 关于知识图谱概念性的介绍就不在此赘述.目前知识图谱在各 ...