当前位置:网站首页>Zabbix历史数据清理(保留以往每个项目每天一条数据)
Zabbix历史数据清理(保留以往每个项目每天一条数据)
2022-08-03 05:27:00 【谷凯Jump】
部门同事说zabbix数据太大,清理一下历史数据,结果以往数据一条都不见了。-_-!
看了网上的教程也都是说直接truncate两张表history和history_uint
我的想法是,以前的历史数据,每个项目每天保留一条,这样的话可以留一些数据供后期参考
先看一下这两张表

根据itemid日期取每天最小的clock
select itemid,date_format(from_unixtime(clock),'%Y-%m-%d'),count(*),min(clock) from history group by itemid,date_format(from_unixtime(clock), '%Y-%m-%d');执行删除
delete from history where (itemid,clock) not in
(select itemid,min(clock) from history group by itemid,date_format(from_unixtime(clock), '%Y-%m-%d'));
delete from history_uint where (itemid,clock) not in
(select itemid,min(clock) from history_uint group by itemid,date_format(from_unixtime(clock), '%Y-%m-%d'));
delete from trends_uint where (itemid,clock) not in
(select itemid,min(clock) from trends_uint group by itemid,date_format(from_unixtime(clock), '%Y-%m-%d'));边栏推荐
- MySql数据格式转成Redis键值对格式
- contos安装php-ffmpeg和tp5.1使用插件
- find命令、sort命令、uniq命令
- 二、Exception和Error有什么区别?
- How the world's leading medical technology company maximizes design productivity | SOLIDWORKS Product Exploration
- MySQL的主从复制
- MySql【后面附有练习题】
- What is parametric design, let's understand it through practical operation?| SOLIDWORKS How-To Videos
- JSP的基本使用
- 数组与字符串9-翻转字符串里的单词
猜你喜欢
随机推荐
【3D建模制作技巧分享】ZBrush快捷键如何设置
数组与字符串12-数组拆分
域名注册流程:如何选择购买合适的域名?
What is parametric design, let's understand it through practical operation?| SOLIDWORKS How-To Videos
All-round interpretation of POE switches (middle)
Typora
BOA服务器的移植
守望先锋英雄角色模型分享,obj文件+材质贴图,3dmax游戏建模
Podman一篇就学会
二分查找3 - 猜数字大小
802.1AS的SystemIdentity理解
详解SSL证书的分类以及如何选择合适的证书?
Delightful Nuxt3 Tutorial (2): Build a Blog Quickly and Easily
学习C的第一天,尝试一下写博客
树——二叉排序树(BST)
Eight, the difference between the interface of the abstract class
大学毕业后,零基础想转行成为一名3D建模师,现在该做什么?
使用ZBrush制作恶魔模型
JS--正则表达式
How the world's leading medical technology company maximizes design productivity | SOLIDWORKS Product Exploration









