切换到宽版

中国黑防联盟

查看: 185|回复: 9

Linux 常用监控指标总结

[复制链接]
发表于 2020-11-16 08:42:20 | |阅读模式
1、Linux 运维基础采集项
做运维,不怕出问题,怕的是出了问题,抓不到现场,两眼摸黑。所以,依靠强大的监控系统,收集尽可能多的指标,意义重大。但哪些指标才是有意义的呢,本着从实践中来的思想,各位工程师在长期摸爬滚打中总结出来的经验最有价值。
在各位运维工程师长期的工作实践中,我们总结了在系统运维过程中,经常会参考的一些指标,主要包括以下几个类别:
CPU
Load
内存
磁盘
IO
网络相关
内核参数
ss 统计输出
端口采集
核心服务的进程存活信息采集
关键业务进程资源消耗
NTP offset采集
DNS解析采集
+
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 描述,类似 ,其中 是挂载点,比如 , 是文件系统,比如 ext4。
4、megacli 工具输出
使用 megacli 工具读取 RAID 相关信息,每个 metric 都会附件一组 tag 描述,用来标明所属 PD 或者 VD,PD 格式为 PD=Enclosure_ID:SLOT_ID,比如 PD=32:0 表明第一块磁盘 ,VD=0 表明第一个逻辑磁盘。
5、SMART 工具输出
使用 smartctl 工具读取磁盘 SMART 信息,目前所有指标仅作为数据收集,不一定意味磁盘损坏(只是表示概率变大),每个 metric 都会有一组 tag 描述,表明盘符,例如 device=/dev/sda。
6、分区读写监控
测试所有已挂载分区是否可读写,每个 metric 都会有一组 tag 描述,表示挂载点,比如 mount=/home
7、IO相关采集项
计算方法:每秒采集一次 /proc/diskstats,计算差值,都是计数器类型的。每个 metric 都会有一组 tag 描述,形如 ,用来表示具体的设备,比如 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的含义。
10、网络相关采集项
计算方法:读取 /proc/net/dev 的内容,每个 metric 都附加有一组 tag,形如 ,标明具体那个 interface,比如 eth0。metric 中带有 in 的表示流入情况,out 表示流出情况,total 是总量 ,支持的 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就是具体的端口。
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。
14、进程监控
proc.num:判断某个进程的数目,这里需要分两个场景,一种是根据进程的名字来判定,比如name=sshd;另外一种是根据cmdline来判定,比如Java的应用进程名可能都是java,根据第一种情况没法做区分,此时可以配置cmdline,如cmdline=./falcon_agent-c./cfg.ini
15、进程资源监控
16. ss命令输出

永远支持中国黑防联盟论坛:www.vcs6.com
发表于 2021-3-27 17:02:25 |
谢谢分享!一直在找
永远支持中国黑防联盟论坛:www.vcs6.com
发表于 2021-4-11 04:47:52 |
支持黑防论坛支持楼主!
永远支持中国黑防联盟论坛:www.vcs6.com
发表于 2021-4-24 21:15:42 |
感谢分享,先尝试一下
永远支持中国黑防联盟论坛:www.vcs6.com
发表于 2021-5-21 04:27:18 |
我不太喜欢回消息,感觉我上辈子就是个免打扰。
永远支持中国黑防联盟论坛:www.vcs6.com
发表于 2021-5-30 08:34:22 |
感谢分享,收藏下载了
永远支持中国黑防联盟论坛:www.vcs6.com
发表于 2021-6-11 07:07:02 |
感谢热心楼主分享,Mark一下
永远支持中国黑防联盟论坛:www.vcs6.com
发表于 2021-7-9 08:48:31 |
亲测有效,楼主牛
永远支持中国黑防联盟论坛:www.vcs6.com
发表于 2021-8-9 03:41:48 |
感谢分享 试一下看看
永远支持中国黑防联盟论坛:www.vcs6.com
发表于 2021-9-18 18:19:53 |
永远支持中国黑防联盟论坛的发展,支持楼主!
永远支持中国黑防联盟论坛:www.vcs6.com
关闭

站长推荐上一条 /1 下一条

手机版|小黑屋|网站地图|( 蜀ICP备2020029785号 )

快速回复 返回顶部 返回列表