首页 > 系统相关 >Linux 常用监控指标总结

Linux 常用监控指标总结

时间:2024-03-08 09:13:17浏览次数:21  
标签:总结 io mem sys 监控 Linux net disk cpu

1. Linux运维基础采集项


做运维,不怕出问题,怕的是出了问题,抓不到现场,两眼摸黑。所以,依靠强大的监控系统,收集尽可能多的指标,意义重大。但哪些指标才是有意义的呢,本着从实践中来的思想,各位工程师在长期摸爬滚打中总结出来的经验最有价值。在各位运维工程师长期的工作实践中,我们总结了在系统运维过程中,经常会参考的一些指标,主要包括以下几个类别:

  • CPU
  • Load
  • 内存
  • 磁盘
  • IO
  • 网络相关
  • 内核参数
  • ss 统计输出
  • 端口采集
  • 核心服务的进程存活信息采集
  • 关键业务进程资源消耗
  • NTP offset采集
  • DNS解析采集

每个类别,具体的详细指标如下,这些指标,都是open-falcon的agent组件直接支持的。falcon-agent每隔一定时间间隔(目前是60秒)会采集一次相关的指标,并汇报给server端。

2. CPU相关采集项

计算方法:通过采集/proc/stat来得到,大家可以参考sar命令的统计输出来理解。

  • cpu.idle:Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.
  • cpu.busy:与cpu.idle相对,他的值等于100减去cpu.idle。
  • cpu.guest:Percentage of time spent by the CPU or CPUs to run a virtual processor.
  • cpu.iowait:Percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
  • cpu.irq:Percentage of time spent by the CPU or CPUs to service hardware interrupts.
  • cpu.softirq:Percentage of time spent by the CPU or CPUs to service software interrupts.
  • cpu.nice:Percentage of CPU utilization that occurred while executing at the user level with nice priority.
  • cpu.steal:Percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor.
  • cpu.system:Percentage of CPU utilization that occurred while executing at the system level (kernel).
  • cpu.user:Percentage of CPU utilization that occurred while executing at the user level (application).
  • cpu.cnt:cpu核数。
  • cpu.switches:cpu上下文切换次数,计数器类型。

3. 磁盘相关采集项

计算方法:先读取/proc/mounts拿到所有挂载点,然后通过syscall.Statfs_t拿到blocks和inode的使用情况。每个metric都会附加一组tag描述,类似mount=$mount,fstype=$fstype,其中$mount是挂载点,比如/home,$fstype是文件系统,比如ext4。

  • df.bytes.free:磁盘可用量,int64
  • df.bytes.free.percent:磁盘可用量占总量的百分比,float64,比如32.1
  • df.bytes.total:磁盘总大小,int64
  • df.bytes.used:磁盘已用大小,int64
  • df.bytes.used.percent:磁盘已用大小占总量的百分比,float64
  • df.inodes.total:inode总数,int64
  • df.inodes.free:可用inode数目,int64
  • df.inodes.free.percent:可用inode占比,float64
  • df.inodes.used:已用的inode数据,int64
  • df.inodes.used.percent:已用inode占比,float64

4. megacli工具输出

使用 megacli 工具读取 RAID 相关信息,每个metric都会附件一组tag描述,用来标明所属PD或者 VD,PD格式为PD=Enclosure_ID:SLOT_ID,比如PD=32:0表明第一块磁盘 ,VD=0 表明第一个逻辑磁盘。

  • sys.disk.lsiraid.pd.Media_Error_Count:这个及以下三个指标目前仅作为数据收集,不一定意味磁盘损坏(只是表示损坏概率变大)
  • sys.disk.lsiraid.pd.Other_Error_Count
  • sys.disk.lsiraid.pd.Predictive_Failure_Count
  • sys.disk.lsiraid.pd.Drive_Temperature
  • sys.disk.lsiraid.pd.Firmware_state:如果值不为0,则此物理磁盘出现问题
  • sys.disk.lsiraid.vd.cache_policy:如果值不为0,表示此逻辑磁盘缓存策略和设置不符
  • sys.disk.lsiraid.vd.state:如果值不为0,表示此逻辑磁盘出现问题

5. SMART工具输出

使用 smartctl 工具读取磁盘 SMART 信息,目前所有指标仅作为数据收集,不一定意味磁盘损坏(只是表示概率变大),每个metric都会有一组tag描述,表明盘符,例如device=/dev/sda。

  • sys.disk.smart.Reallocated_Sector_Ct
  • sys.disk.smart.Spin_Retry_Count
  • sys.disk.smart.Reallocated_Event_Count
  • sys.disk.smart.Current_Pending_Sector
  • sys.disk.smart.Offline_Uncorrectable
  • sys.disk.smart.Temperature_Celsius

6. 分区读写监控

测试所有已挂载分区是否可读写,每个metric都会有一组tag描述,表示挂载点,比如mount=/home

  • sys.disk.rw:如果值不为0,表明此分区读写出现问题

7. IO相关采集项

计算方法:每秒采集一次/proc/diskstats,计算差值,都是计数器类型的。每个metric都会有一组tag描述,形如device=$device,用来表示具体的设备,比如sda1、sdb。用户可以参考iostat的帮助文档来理解具体的metric含义。

  • disk.io.ios_in_progress:Number of actual I/O requests currently in flight.
  • disk.io.msec_read:Total number of ms spent by all reads.
  • disk.io.msec_total:Amount of time during which ios_in_progress >= 1.
  • disk.io.msec_weighted_total:Measure of recent I/O completion time and backlog.
  • disk.io.msec_write:Total number of ms spent by all writes.
  • disk.io.read_merged:Adjacent read requests merged in a single req.
  • disk.io.read_requests:Total number of reads completed successfully.
  • disk.io.read_sectors:Total number of sectors read successfully.
  • disk.io.write_merged:Adjacent write requests merged in a single req.
  • disk.io.write_requests:total number of writes completed successfully.
  • disk.io.write_sectors:total number of sectors written successfully.
  • disk.io.read_bytes:单位是byte的数字
  • disk.io.write_bytes:单位是byte的数字
  • disk.io.avgrq_sz:下面几个值就是iostat -x 1看到的值
  • disk.io.avgqu-sz
  • disk.io.await
  • disk.io.svctm
  • disk.io.util:是个百分数,比如56.43,表示56.43%

8. 机器负载相关采集项

计算方法:读取/proc/loadavg,都是原始值类型的:

  • load.1min
  • load.5min
  • load.15min

9. 内存相关采集项

计算方法:读取/proc/meminfo 中的内容,其中的mem.memfree是free+buffers+cached,mem.memused=mem.memtotal-mem.memfree。用户具体可以参考free命令的输出和帮助文档来理解每个metric的含义。

  • mem.memtotal:内存总大小
  • mem.memused:使用了多少内存
  • mem.memused.percent:使用的内存占比
  • mem.memfree
  • mem.memfree.percent
  • mem.swaptotal:swap总大小
  • mem.swapused:使用了多少swap
  • mem.swapused.percent:使用的swap的占比
  • mem.swapfree
  • mem.swapfree.percent

10. 网络相关采集项

计算方法:读取/proc/net/dev的内容,每个metric都附加有一组tag,形如iface=$iface,标明具体那个interface,比如eth0。metric中带有in的表示流入情况,out表示流出情况,total是总量in+out,支持的metric如下:

  • net.if.in.bytes
  • net.if.in.compressed
  • net.if.in.dropped
  • net.if.in.errors
  • net.if.in.fifo.errs
  • net.if.in.frame.errs
  • net.if.in.multicast
  • net.if.in.packets
  • net.if.out.bytes
  • net.if.out.carrier.errs
  • net.if.out.collisions
  • net.if.out.compressed
  • net.if.out.dropped
  • net.if.out.errors
  • net.if.out.fifo.errs
  • net.if.out.packets
  • net.if.total.bytes
  • net.if.total.dropped
  • net.if.total.errors
  • net.if.total.packets

11. 端口采集项

计算方法,通过ss -ln,来判断指定的端口是否处于listen状态。原始值类型,值要么是1:代表在监听,要么是0,代表没有在监听。每个metric都附件一组tag,形如port=$port,$port就是具体的端口。

  • net.port.listen

12. 机器内核配置

  • kernel.maxfiles:读取的/proc/sys/fs/file-max
  • kernel.files.allocated:读取的/proc/sys/fs/file-nr第一个Field
  • kernel.files.left:值=kernel.maxfiles-kernel.files.allocated
  • kernel.maxproc:读取的/proc/sys/kernel/pid_max

13. ntp采集项

使用 ntpq -pn 获取本机时间相对于 ntp 服务器的 offset。

  • sys.ntp.offset:本机偏移时间,单位为ms,值过大或者为0则表明有异常,需要报警

14. 进程监控

  • proc.num:判断某个进程的数目,这里需要分两个场景,一种是根据进程的名字来判定,比如name=sshd;另外一种是根据cmdline来判定,比如Java的应用进程名可能都是java,根据第一种情况没法做区分,此时可以配置cmdline,如cmdline=./falcon_agent-c./cfg.ini

15. 进程资源监控

  • process.cpu.all:进程和它的子进程使用的sys+user的cpu,单位是jiffies
  • process.cpu.sys:进程和它的子进程使用的sys cpu,单位是jiffies
  • process.cpu.user:进程和它的子进程使用的user cpu,单位是jiffies
  • process.swap:进程和它的子进程使用的swap,单位是page
  • process.fd:进程使用的文件描述符个数
  • process.mem:进程占用内存,单位byte

16. ss命令输出

  • ss.orphaned
  • ss.closed
  • ss.timewait
  • ss.slabinfo.timewait
  • ss.synrecv
  • ss.estab

标签:总结,io,mem,sys,监控,Linux,net,disk,cpu
From: https://www.cnblogs.com/shujuyr/p/18060259

相关文章

  • 【数学】概率&期望小总结
    开篇碎碎念好久没有更博客了(咸鱼瘫瘫),到现在还欠了最近的几场cf没补题(呜呜呜欠债upup),由于一道很显然的期望没有开出来所以最近补了几道期望,来总结一下友情指路:sshwy的期望洛谷题单相关基础概念首先是概率:常用P(X)表示X发生的概率,等价于X发生的可能性在全部事件的占比。......
  • 将java项目打包部署在linux系统上(配置成systemd)
    我这里以ruoyi前后端分离的springboot项目为例打包部署1.前置条件1.0一些一些小问题#如果是阿里云或者腾讯云上面去开通安全组#默认防火墙是关闭的可以将防火墙打开sudosystemctlenablefirewalldsudosystemctlstartfirewalld#开放端口sudofirewall-cmd--zo......
  • htmi总结+css
    HTML表单学习<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>登录注册</title></head><body><h1>注册</h1><!--表单formaction:表单提交的位置可以是网站,也可以是一个请求的位置m......
  • MySQL-01.Linux下MySQL安装和使用
    C-01.Linux下MySQL的安装和使用前置说明,MySQL高级部分,需要前置知识,为Linux操作系统。如果没有该部分知识,这里推荐韩顺平老师的Linux操作系统的教程。韩老师Linux教程1.安装前准备1.1Linux系统及工具的准备安装并启动好两台虚拟机:CentOS7版本掌握克隆虚拟机的操作mac地......
  • CSP_J2023总结
    维护中include<bits/stdc++.h>usingnamespacestd;intn,ans,k;intmain(){ cin>>n; while(n){ ans++; if(k==0&&n%3==1)k=ans; if(n%3==0)n-=n/3; elsen-=n/3+1; } cout<<ans<<""<<k; return0;}......
  • Windows虚拟机安装Linux的基础配置
    Linux实用本次练习实用的是Ubuntu20.04基础配置root用户进入root用户模式sudosu解决网络参考文章一篇搞定Ubuntu22.04下联网问题、ifconfig、net-tools不能用的问题(亲测可行_仅供参考)_无法定位软件包net-tools-CSDN博客编辑->虚拟网络编辑器:删除原先是VMnet*,重新“添......
  • 2024.3.7习题总结
    CF1288C题目可以把\(a\)数组和\(b\)数组的倒序合并,这样,题目就成了求出长度为\(2m\)的序列递增的方案数,\(dp\)求解可以把长度为\(2m\)的差分数组。对于任意一个\(c_i\),\(c_i\ge0,\sumc_i\len\),所以方案数为\(C_{n+2*m-1}^{2*m}\)CF1569C......
  • Redis之Redis7安装&卸载(Linux版)
    卸载##查看当前服务器是否安装redis及其版本redis-server-v##停止服务###停止单机上的单实例redis-cli-a9527shutdown###停止单机上的多实例的某一个实例redis-cli-a9527-p6379shutdown###查看是否停止完全ps-ef|grepredis##删除/usr/local/bin目......
  • Linux文件管理
    Linux文件管理学习目标了解文件名规则和工作中的建议命名规则会创建和删除目录mkdir/rmdir会创建和删除文件touch/rm了解复制cp和移动mv的区别会使用tar命令进行压缩和解压缩掌握vm的保存和退出和不保存强制退出q!掌握vim的快捷方式yy,dd,gg,G,u会使用tail命令来查看文件......
  • flink总结
    基本概念介绍flink的基本处理流程读取数据(source)->各种算子计算处理数据(rdd)-->输出数据(sink)有界流和无界流如果是从文件有限数据的地方读取数据就是有界流,如果是接到kafka或者socket这种地方就是无界流。有状态和无状态算子计算的过程中,是否要保存中间结算结果......