基于zabbix的数据库查询各种监控数据
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的数据库查询各种监控数据的更多相关文章
- [ python3 ] 基于zabbix 自动抓取每天监控数据
通过python登录到zabbix直接抓取每天的数据的图片趋势图,并制作成静态index.html给与展示并发送提示邮件. 操作系统:Centos6.7 python版本:python3.5 #!/u ...
- laravel数据库查询返回的数据形式
版本:laravel5.4+ 问题描述:laravel数据库查询返回的数据不是单纯的数组形式,而是数组与类似stdClass Object这种对象的结合体,即使在查询构造器中调用了toArray(), ...
- 基于zabbix 的memached 多实例监控
基于zabbix 的memached 多实例监控 zabbix agentd 配置文件新增配置: UserParameter=memcached.server.discovery[*],ps uax ...
- SQL数据库查询一列数据返回一行
SQL:数据库合并列数据:遇到一个更新的问题 想要把查询到的数据某一列拼接成字符串形式返回用的是SQL数据库中的STUFF函数比如 查询到的表(u_College)如下Id Name Age Clas ...
- 在vue中的form表单中下拉框中的数据来自数据库查询到的数据
文章目录 1.实现的效果: 2.前端html代码 3.js中的代码 4.后端的方法 1.实现的效果: 增加一个新的类型到数据库 2.前端html代码 需要注意的部分:prop后边是表单中的字段 v-m ...
- Java基于POI实现excel任意多级联动下拉列表——支持从数据库查询出多级数据后直接生成【附源码】
Excel相关知识点 (1)名称管理器--Name Manager [CoderBaby]首先需要创建多个名称(包含key及value),作为下拉列表的数据源,后续通过名称引用.可通过菜单:&quo ...
- 从后台数据库查询的List数据怎么在前台combobox显示
后台直接从数据库,通过jdbcTemplate查询数据,得到List数据集,里面是Map List<Map<String, Object>> list = jdbcTempl ...
- MySql数据库-查询、插入数据时转义函数的使用
最近在看一部php的基础视频教程,在做案例的时,当通过用户名查询用户信息的时候,先使用了转义函数对客户提交的内容进行过滤之后再交给sql语句进行后续的操作.虽然能看到转义函数本身的作用,但是仍然有一些 ...
- sql server数据库查询取出重复数据记录
问题:博主在2011年6月,广东技术师范大学大四的时候,从学校计算机科学学院网站看到招聘信息并到广东中原地产IT部面试,很清楚记得当时的面试题目:怎么从数据库里面查询重复记录. 解决方案:在sql s ...
- 转 zabbix 优化方法 以及 后台数据库查询方法 两则
############sample 1 https://blog.51cto.com/sfzhang88/1558254 如何从Zabbix数据库中获取监控数据 sfzhang关注6人评论40627 ...
随机推荐
- [转帖]深入理解mysql-第五章 InnoDB记录存储结构-页结构
前言: 页是InnoDB管理存储空间的基本单位,上一章我们主要分析了页中的主要的构成行的存储结构-行格式,其中简单提了一下页的概念.这章我们详细讲解一下页的存储结构. 一.数据页结构 前边我们简单提了 ...
- [转帖]sqlserver on linux vs windows
简单对比下sqlserver on windows与linux的特点,发现新的继续添加 对比项 sqlserver on windows sqlserver on Linux 备注 费用 需要wind ...
- [转帖]一行Python代码实现同一局域网内的文件共享
在不同的设备之间传输文件除了数据线,网盘传输外是否还有其他优雅的方法?我们可以使用一行Python代码使局域网内的所有设备都可以访问并下载文件夹内的文件. 要求: 电脑中安装配置好python 访问的 ...
- [转帖]浅谈redis采用不同内存分配器tcmalloc和jemalloc
http://www.kaotop.com/it/173669.html 我们知道Redis并没有自己实现内存池,没有在标准的系统内存分配器上再加上自己的东西.所以系统内存分配器的性能及碎片率会对Re ...
- [转帖]Linux 防火墙开放特定端口 (iptables)
查看状态: iptables -L -n 下面添加对特定端口开放的方法: 使用iptables开放如下端口 /sbin/iptables -I INPUT -p tcp --dport 8000 -j ...
- 机器学习从入门到放弃:卷积神经网络CNN(一)
一.前言 在上一篇中我们使用全连接网络,来构建我们的手写数字图片识别应用,取得了很好的效果.但是值得注意的是,在实验的最后,最后我们无论把 LOSS 优化到如何低,似乎都无法在测试数据集 test d ...
- windows共享文件创建----局域网办公
一.共享文件设置 1.选择要共享的文件夹-----右键点击属性--------在上方选项栏选择共享----然后点击"高级共享" 2.勾选"共享此文件夹"---- ...
- 4.9 x64dbg 内存处理与差异对比
LyScript 插件中针对内存读写函数的封装功能并不多,只提供了最基本的内存读取和内存写入系列函数的封装,本章将继续对API接口进行封装,实现一些在软件逆向分析中非常实用的功能,例如ShellCod ...
- [Go] string、int、int64相互转换
import "strconv" //先导入strconv包 // string到int int, err := strconv.Atoi(string) // string到in ...
- 影驰RTX 4070 SUPER星曜OC显卡评测:250W超频潜力十足 散热更惊喜
一.前言:影驰推出主打高颜值的RTX 4070 SUPER星曜OC显卡 影驰作为DIY大厂,要说它家颜值最高的产品,那必然就是星曜系列,无论显卡.内存还是SSD,不光好看,品质和性能上也都有着不俗的表 ...