Linux 超好用监控工具(atop)

本文详细介绍了在Ubuntu系统上安装atop工具以及其网络监控模块netatop的过程,包括更新包管理器、下载、编译、配置启动选项和查看网络使用情况的命令。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Ubuntu 系统

# 安装atop
sudo apt update 
sudo apt install atop

# 监测网络的使用率,网络监控模块 netatop (可选)
sudo apt install zlib1g-dev
sudo wget https://www.atoptool.nl/download/netatop-3.1.tar.gz --no-check-certificate
tar -zxvf netatop-3.1.tar.gz
cd netatop-3.1
sudo make && sudo make install
sudo systemctl start netatop

# 配置启动atop(我的是ubuntu22.04,没有/etc/sysconfig目录)
vim /etc/default/atop
LOGOPTS=""
LOGINTERVAL=30          # 监控周期30s(粒度小,数据更详细)
LOGGENERATIONS=7        # 日志保留时间7天
LOGPATH=/var/log/atop

sudo systemctl restart atop

 其他系统

# 安装 atop
sudo yum install atop

# 监测网络的使用率,网络监控模块 netatop (可选)
sudo yum install kernel-devel-$(uname -r)
sudo yum install elfutils-libelf-devel
sudo wget https://www.atoptool.nl/download/netatop-3.1.tar.gz --no-check-certificate
tar -zxvf netatop-3.1.tar.gz
cd netatop-3.1
sudo make && sudo make install
sudo systemctl start netatop

# 配置启动atop
vim /etc/sysconfig/atop
LOGOPTS=""
LOGINTERVAL=30
LOGGENERATIONS=7
LOGPATH=/var/log/atop   #如ubuntu配置

sudo systemctl restart atop

查看方式

atop -r /var/log/atop/atop_2024XXXX

 如果需要某个时间点的数据

按 b —— 输入具体日期 —— 回车 (如下图)

常用命令

都是根据降序进行筛选

c  :cpu使用率

m  :内存使用率

d  : 磁盘使用率

a  : 进程资源综合使用率

n  : 网络使用率

t  :下一个监控点

T  :上一个监控点

atop --help

root@xxxxxxx:~# atop --help
atop: invalid option -- '-'
Usage: atop [-flags] [interval [samples]]
                or
Usage: atop -w  file  [-S] [-a] [interval [samples]]
       atop -r [file] [-b [YYYYMMDD]hhmm] [-e [YYYYMMDD]hhmm] [-flags]

        generic flags:
          -V  show version information    # 版本信息
          -a  show or log all processes (i.s.o. active processes only)    # 显示或记录所有进程(仅限i.s.o.活动进程)
          -R  calculate proportional set size (PSS) per process    # 计算每个过程的比例集大小(PSS)
          -W  determine WCHAN (string) per thread    # 确定每个线程的WCHAN(字符串)
          -P  generate parseable output for specified label(s)    # 为指定的标签生成可解析的输出
          -Z  no spaces in parseable output for command (line)    # 命令(行)的可解析输出中没有空格
          -L  alternate line length (default 80) in case of non-screen output    # 非屏幕输出情况下的交替行长度(默认值80)
          -f  show fixed number of lines with system statistics    # 显示具有系统统计信息的固定行数
          -F  suppress sorting of system resources    # 抑制系统资源的排序
          -G  suppress exited processes in output    # 在输出中抑制退出的进程
          -l  show limited number of lines for certain resources    # 显示某些资源的有限行数
          -y  show threads within process    # 显示进程中的线程
          -Y  sort threads (when combined with 'y')    # 排序线程
          -1  show average-per-second i.s.o. total values    # 显示每秒平均i.s.o.总值

          -x  no colors in case of high occupation    # 在高占用率的情况下没有颜色
          -g  show general process-info (default)    # 显示一般流程信息(默认值)
          -m  show memory-related process-info    # 显示与内存相关的进程信息 
          -d  show disk-related process-info    # 显示与磁盘相关的进程信息 
          -n  show network-related process-info    # 显示与网络相关的进程信息 
          -s  show scheduling-related process-info    # 显示与日程安排相关的流程信息 
          -v  show various process-info (ppid, user/group, date/time)    # 显示各种进程信息(ppid、用户/组、日期/时间) 
          -c  show command line per process    # 显示每个进程的命令行 
          -o  show own defined process-info    # 显示自己定义的流程信息 
          -u  show cumulated process-info per user    # 显示每个用户的累积过程信息 
          -p  show cumulated process-info per program (i.e. same name)    # 显示每个程序(即相同名称)的累积过程信息 
          -j  show cumulated process-info per container    # 显示每个容器的累积过程信息

          -C  sort processes in order of cpu consumption (default)    # 按照cpu消耗的顺序对进程进行排序(默认) 
          -M  sort processes in order of memory consumption    # 按内存消耗顺序排序的进程 
          -D  sort processes in order of disk activity    # 按磁盘活动的顺序对进程进行排序 
          -N  sort processes in order of network activity    # 按网络活动顺序排序的进程 
          -E  sort processes in order of GPU activity    # 按GPU活动的顺序对进程进行E排序 
          -A  sort processes in order of most active resource (auto mode)    # 排序按最活跃资源的顺序进行处理(自动模式)

        specific flags for raw logfiles:
          -w  write raw data to   file (compressed)    # 将原始数据写入文件(压缩)
          -r  read  raw data from file (compressed)    # 从文件读取原始数据(压缩)
              symbolic file: y[y...] for yesterday (repeated)
              file name '-': read raw data from stdin
          -S  finish atop automatically before midnight (i.s.o. #samples)    # 在午夜前自动完成
          -b  begin showing data from specified date/time    # 开始显示指定日期/时间的数据
          -e  finish showing data after specified date/time    # 在指定日期/时间后完成显示数据

        interval: number of seconds   (minimum 0)
        samples:  number of intervals (minimum 1)

If the interval-value is zero, a new sample can be
forced manually by sending signal USR1 (kill -USR1 pid_atop)
or with the keystroke 't' in interactive mode.

Please refer to the man-page of 'atop' for more details.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值