当前位置: 首页 > news >正文

sar:如何定时收集Linux监控信息

sar: sar:如何定时收集Linux监控信息

很多博客都有提到,安装了sysstat之后,默认会配置crond定时任务收集信息。

尽信书,不如无书,实地求证一下!

在AnolisOS 8.9上,安装并启动服务,发现在/etc/crontab中并不存在sar相关的定时任务。最终发现是通过两个服务sysstat-collect.timersysstat-summary.timer完成每10分钟统计!

  • 安装并启动
yum install sysstat
systemctl enable sysstat
systemctl start sysstat
  • 查看sysstat rpm包中的scripts,确认没有配置crond定时任务的操作
[root@localhost test]# rpm -qp --scripts sysstat-11.7.3-13.0.1.an8.x86_64.rpm
postinstall scriptlet (using /bin/sh):

if [ $1 -eq 1 ] ; then
        # Initial installation
        systemctl --no-reload preset sysstat.service sysstat-collect.timer sysstat-summary.timer &>/dev/null || :
fi
preuninstall scriptlet (using /bin/sh):

if [ $1 -eq 0 ] ; then
        # Package removal, not upgrade
        systemctl --no-reload disable --now sysstat.service sysstat-collect.timer sysstat-summary.timer &>/dev/null || :
fi

if [[ $1 -eq 0 ]]; then
    # Remove sa logs if removing sysstat completely
    rm -rf /var/log/sa/*
fi
postuninstall program: /bin/sh

  • 发现依然每10分钟会自动收集一次,怎么做到的?

根据 systemctl status sysstat的输出,找到/usr/lib/systemd/system/sysstat.service文件,发现其中还有两个关联服务:
sysstat-collect.timersysstat-summary.timer .

在这里插入图片描述

  • sysstat-collect.timer服务

    • Started Run system activity accounting tool every 10 minutes.
    • 即每隔10分钟收集一次,存在/var/log/sa/目录
      在这里插入图片描述
  • sysstat-summary.timer服务

    • Started Generate summary of yesterday’s process accounting.
    • 即每天生成昨天进程统计的摘要

在这里插入图片描述

相关文章:

  • 数字电子电路基础第三章——门电路(三)
  • 如何通过DeepBI提升亚马逊广告效果:全方位优化广告投放的智能工具
  • 随身wifi wps是什么?(Wi-Fi Protected Setup)一种简化无线网络连接的技术,允许用户无需手动输入密码即可快速连接设备
  • Ubuntu 下 nginx-1.24.0 源码分析 - ngx_conf_t
  • 58区间和+44开发商购买土地(前缀和)
  • Linux的软件安装
  • 【navigator.geolocation的手机脚本定位】
  • Spring Cloud — 消息驱动 Stream
  • npx degit 问题:could not fetch remote...
  • 调用com接口调整windows系统音量
  • Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(11)
  • Let‘s Encrypt免费证书的应用示例
  • 2025年2月28日(RAG)
  • 为AI聊天工具添加一个知识系统 之127 详细设计之68 应用行规:符号学芭比 之2
  • 西门子S7-1200 PLC计数器详解
  • docker-compose部署开源堡垒机Orion-Visor——筑梦之路
  • 随笔 | 写在二月的最后一天
  • 常用的 pip 命令
  • springboot rocketmq配置生产者和消息者
  • 优化器Reaction1:从动力学角度看优化算法(1.1):从GD 到 SGD
  • 怎么做阿里巴巴网站/嘉兴优化公司
  • 陕西城乡建设厅网站/临沂网站seo
  • 郑州做网站_郑州免费建站/手机百度极速版app下载安装
  • 潍坊专业网站制作公司营销/成都网站seo费用
  • 重庆宣传网站怎么做/外包网络推广营销
  • 直播视频网站源码/google下载手机版