当前位置:网站首页>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'));边栏推荐
猜你喜欢
随机推荐
各种cms getshell技巧
ZEMAX | 在 OpticStudio 中使用自由曲面进行设计
【七夕特效】 -- 满屏爱心
【面试准备】游戏开发中的几个岗位分别做什么&考察侧重点
3D游戏建模师在国内的真实现状,想转行,先来看看!
权限管理 UGO 、 ACL 、特殊权限
SQLMAP介绍及使用
影响PoE供电传输距离的除了网线还有啥?
gotests自动生成测试用例
借助ginput函数在figure窗口实时读取、展示多条曲线的坐标值
3D建模:做什么副业在家就能月入1W?
数组与字符串11-反转字符串
使用Blender和ZBrush制作武器模型
How the world's leading medical technology company maximizes design productivity | SOLIDWORKS Product Exploration
关于C语言中getchar()函数的用法
classpath:与classpath*的比较
Prometheus监控容器、pod、邮件告警
什么是国密SSL协议?国密证书与传统SSL证书有什么区别?
数组与字符串8-最长回文子串
802.1AS的SystemIdentity理解









