基于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 ...
随机推荐
- 07 - HTTP
HTTP 强烈推荐学习:HTTP | MDN 一 .基础概念 请求和响应报文 客户端发送一个请求报文给服务器,服务器根据请求报文中的信息进行处理,并将处理结果放入响应报文中返回给客户端. 请求报文结构 ...
- [转帖]Nginx中absolute_redirect、port_in_redirect配置简述
一.背景: 我们在访问nginx代理下的项目前端页面时,经常会有访问链接最末尾带不带'/'的问题,当我们访问http://xxxx/home时,如果匹配不到location,会自动加上端口port以及 ...
- Oracle Rac 的简单学习
Oracle Rac 的简单学习 Oracle RAC的概念 Oracle RAC (Real Application Clusters) 是 Oracle 数据库管理系统的一个功能, 它允许将数据库 ...
- [转帖]win10下使用Rclone将OneDrive映射到本地磁盘教程(开机自动挂载)
win10下使用Rclone将OneDrive映射到本地磁盘教程(开机自动挂载) 下载rclone,winfsp和Git bash Rclone. Winfsp. 和 [Git bash](https ...
- [转帖]centos7离线安装postgresql13
https://www.cnblogs.com/summer-88/p/15341918.html 在一台可以联网的centos上安装postgresql源 yum install -y https: ...
- [转帖]Linux系统:page fault
Linux进程如何访问内存 Linux下,进程并不是直接访问物理内存,而是通过内存管理单元(MMU)来访问内存资源,原因后面会讲到. 为什么需要虚拟内存地址空间 假设某个进程需要4MB的空间,内存假设 ...
- Windows 环境下简单的自动备份以及清理数据库的操作过程
今天能想到要简单的备份一下windows上面的数据库. 然后并且能够定期清理文件. 然后从网上找了一下 找到把饭如下 1. 备份 创建一个目录用来存放数据库备份 c:\dbbak 然后编写一个脚本, ...
- vue 半场动画进入状态
<style> .box{ width: 30px; height: 30px; border-radius: 50%; background: red; } </style> ...
- 大模型应用开发:为产品创建一个AI客服/智能助手
欢迎阅读本系列文章!我将带你一起探索如何使用OpenAI API来开发GPT应用.无论你是编程新手还是资深开发者,都能在这里获得灵感和收获. 本文将继续展示AI助手的开发方式,在OpenAPI中它的名 ...
- NetCore高级系列文章01---创建项目及配置文件
.NET Core是适用于 Windows.Linux 和 macOS 的免费.开源托管的计算机软件框架,作为.NET开发人员,全面拥抱.NetCore将成为趋势. 本系列文章将分为两大部分讲解.Ne ...