用夜莺监控 Linux
CPU、内存、磁盘、网络、进程到内核参数,Categraf 装上就有数据,模板覆盖 Categraf、node_exporter 和 Telegraf 三种采集口径。
最后校对于
Linux 主机是绝大多数监控的起点。Categraf 自带的 cpu、mem、disk、diskio、net、netstat、kernel、processes 等插件默认开启,装好就上报,不用额外配置;下面列出的是那些有可调项的插件。
模板里的仪表盘和规则分三套:按 Categraf 指标名写的、按 node_exporter 指标名写的、按 Telegraf 指标名写的。用哪种采集器就导哪一套,混用会看到空面板。规则覆盖了磁盘写满预测、IO 繁忙、conntrack 表、时间漂移、失联等运维上真正会半夜被叫醒的场景。
模板里有什么
- 5 张仪表盘,共 71 个面板
- 60 条告警规则,每条附处置步骤
- 132 条指标说明
- Categraf 采集配置:
input.arp_packet、input.kernel_vmstat、input.logs-agent、input.netstat、input.node_exporter、input.ntp、input.processes、input.sshd、input.supervisor
怎么接入
-
安装 Categraf,按需启用下面的插件。每个配置放到对应的
conf/input.<插件名>/目录,改好地址和凭据后重启 Categraf。conf/input.arp_packet/arp_packet.toml# # collect interval# interval = 15[[instances]]#eth_device="ens192"conf/input.kernel_vmstat/kernel_vmstat.toml# # collect interval# interval = 15# file: /proc/vmstat[white_list]oom_kill = 1nr_free_pages = 0nr_alloc_batch = 0nr_inactive_anon = 0nr_active_anon = 0nr_inactive_file = 0nr_active_file = 0nr_unevictable = 0nr_mlock = 0nr_anon_pages = 0nr_mapped = 0nr_file_pages = 0nr_dirty = 0nr_writeback = 0nr_slab_reclaimable = 0nr_slab_unreclaimable = 0nr_page_table_pages = 0nr_kernel_stack = 0nr_unstable = 0nr_bounce = 0nr_vmscan_write = 0nr_vmscan_immediate_reclaim = 0nr_writeback_temp = 0nr_isolated_anon = 0nr_isolated_file = 0nr_shmem = 0nr_dirtied = 0nr_written = 0numa_hit = 0numa_miss = 0numa_foreign = 0numa_interleave = 0numa_local = 0numa_other = 0workingset_refault = 0workingset_activate = 0workingset_nodereclaim = 0nr_anon_transparent_hugepages = 0nr_free_cma = 0nr_dirty_threshold = 0nr_dirty_background_threshold = 0pgpgin = 0pgpgout = 0pswpin = 0pswpout = 0pgalloc_dma = 0pgalloc_dma32 = 0pgalloc_normal = 0pgalloc_movable = 0pgfree = 0pgactivate = 0pgdeactivate = 0pgfault = 0pgmajfault = 0pglazyfreed = 0pgrefill_dma = 0pgrefill_dma32 = 0pgrefill_normal = 0pgrefill_movable = 0pgsteal_kswapd_dma = 0pgsteal_kswapd_dma32 = 0pgsteal_kswapd_normal = 0pgsteal_kswapd_movable = 0pgsteal_direct_dma = 0pgsteal_direct_dma32 = 0pgsteal_direct_normal = 0pgsteal_direct_movable = 0pgscan_kswapd_dma = 0pgscan_kswapd_dma32 = 0pgscan_kswapd_normal = 0pgscan_kswapd_movable = 0pgscan_direct_dma = 0pgscan_direct_dma32 = 0pgscan_direct_normal = 0pgscan_direct_movable = 0pgscan_direct_throttle = 0zone_reclaim_failed = 0pginodesteal = 0slabs_scanned = 0kswapd_inodesteal = 0kswapd_low_wmark_hit_quickly = 0kswapd_high_wmark_hit_quickly = 0pageoutrun = 0allocstall = 0pgrotated = 0drop_pagecache = 0drop_slab = 0numa_pte_updates = 0numa_huge_pte_updates = 0numa_hint_faults = 0numa_hint_faults_local = 0numa_pages_migrated = 0pgmigrate_success = 0pgmigrate_fail = 0compact_migrate_scanned = 0compact_free_scanned = 0compact_isolated = 0compact_stall = 0compact_fail = 0compact_success = 0htlb_buddy_alloc_success = 0htlb_buddy_alloc_fail = 0unevictable_pgs_culled = 0unevictable_pgs_scanned = 0unevictable_pgs_rescued = 0unevictable_pgs_mlocked = 0unevictable_pgs_munlocked = 0unevictable_pgs_cleared = 0unevictable_pgs_stranded = 0thp_fault_alloc = 0thp_fault_fallback = 0thp_collapse_alloc = 0thp_collapse_alloc_failed = 0thp_split = 0thp_zero_page_alloc = 0thp_zero_page_alloc_failed = 0balloon_inflate = 0balloon_deflate = 0balloon_migrate = 0conf/input.logs-agent/logs-agent.toml[logs]## just a placholderapi_key = ""## enable log collect or notenable = true## the server receive logs, http/tcp/kafka, only kafka brokers can be multiple ip:ports with concatenation character ","send_to = "127.0.0.1:17878"## send logs with protocol: http/tcp/kafkasend_type = "http"topic = "flashcatcloud"## send logs with compression or notuse_compress = false## use ssl or notsend_with_tls = false## send logs in batchsbatch_wait = 5## save offset in this pathrun_path = "/opt/categraf/run"## max files can be openopen_files_limit = 100## scan config file in 10 secondsscan_period = 10## read buffer of udpframe_size = 9000## channal size, default 100## 读取日志缓冲区,行数chan_size = 1000## pipeline num , default 4## 有多少线程处理日志pipeline=4## configuration for kafka## 指定kafka版本kafka_version="3.3.2"# 默认0 表示串行,如果对日志顺序有要求,保持默认配置batch_max_concurrence = 0# 最大并发批次, 默认100batch_max_size=100# 每次最大发送的内容上限 默认1000000batch_max_content_size=1000000# client timeout in secondsproducer_timeout= 10# 是否开启sasl模式sasl_enable = falsesasl_user = "admin"sasl_password = "admin"# PLAINsasl_mechanism= "PLAIN"# v1sasl_version=1# set truesasl_handshake = true# optional# sasl_auth_identity=""#### v0.3.39以上版本新增,是否开启pod日志采集enable_collect_container=false# 是否采集所有pod的stdout stderrcollect_container_all = true## glog processing rules# [[logs.Processing_rules]]## single log configure[[logs.items]]## file/journald/tcp/udptype = "file"## type=file, path is required; type=journald/tcp/udp, port is requiredpath = "/opt/tomcat/logs/*.txt"source = "tomcat"service = "my_service"conf/input.netstat/netstat.toml# # collect interval# interval = 15disable_summary_stats = false## if machine has many network connections, use this plugin may exhaust your cpu resource, disable connection stat to avoid thisdisable_connection_stats = truetcp_ext = falseip_ext = falseconf/input.node_exporter/node_exporter.toml#collectors=[# "--path.procfs=/hostfs/proc",# "--path.sysfs=/hostfs/sys",# "--path.rootfs=/hostfs",# "--collector.arp",# "--collector.bcache",# "--collector.bonding",# "--collector.btrfs",# "--collector.conntrack",# "--collector.cpu",# "--collector.cpufreq",# "--collector.diskstats",# "--collector.dmi",# "--collector.edac",# "--collector.entropy",# "--collector.fibrechannel",# "--collector.filefd",# "--collector.filesystem",# "--collector.hwmon",# "--collector.infiniband",# "--collector.ipvs",# "--collector.loadavg",# "--collector.mdadm",# "--collector.meminfo",# "--collector.netclass",# "--collector.netdev",# "--collector.netstat",# "--collector.nfs",# "--collector.nfsd",# "--collector.nvme",# "--collector.os",# "--collector.powersupplyclass",# "--collector.pressure",# "--collector.rapl",# "--collector.schedstat",# "--collector.selinux",# "--collector.sockstat",# "--collector.softnet",# "--collector.stat",# "--collector.tapestats",# "--collector.textfile",# "--collector.thermal_zone",# "--collector.time",# "--collector.timex",# "--collector.udp_queues",# "--collector.uname",# "--collector.vmstat",# "--collector.xfs",# "--collector.zfs",# "--collector.processes"#]#[[relabel_configs]]#source_labels = ["agent_hostname"]#target_label = "instance"#action = "replace"collectors=[]conf/input.ntp/ntp.toml# # collect interval# interval = 15# # ntp servers# ntp_servers = ["ntp.aliyun.com"]# # response time out seconds# timeout = 5conf/input.processes/processes.toml# # collect interval# interval = 15# # force use ps command to gather# force_ps = false# # force use /proc to gather# force_proc = falseconf/input.sshd/sshd.toml# interval = 15#[[instances]]# # append labels# labels = { region="cloud", product="n9e" }# # whether to enable username label in metrics# # when enabled, metrics will include username labels for detailed tracking# # default: false# enable_username = false# # whether to enable client_ip label in metrics# # when enabled, metrics will include client_ip labels for detailed tracking# # default: false# enable_ip = falseconf/input.supervisor/supervisor.toml# Gathers information about processes that running under supervisor using XML-RPC API[[instances]]## Url of supervisor's XML-RPC endpoint if basic auth enabled in supervisor http server,## than you have to add credentials to url (ex. http://login:pass@localhost:9001/RPC2)# url = "http://login:pass@localhost:9001/RPC2"## With settings below you can manage gathering additional information about processes## If both of them empty, then all additional information will be collected.## Currently supported supported additional metrics are: pid, rc# metrics_include = []# metrics_exclude = ["pid", "rc"] -
在夜莺「集成中心」里找到 Linux,把仪表盘和告警规则导入到业务组。
-
导入的告警规则默认是停用的。先确认指标已经入库,再按自己环境的阈值逐条启用。
内置仪表盘
| 仪表盘 | 面板数 |
|---|---|
| 机器常用指标(如果只想看当前业务组内的机器修改大盘变量 ident 的变量类型为机器标识即可) | 22 |
| 机器台账表格视图(使用 Categraf 作为采集器) | 3 |
| 机器进程数量统计(使用 Categraf 作为采集器) | 4 |
| Host Table NG | 1 |
| 机器常用指标(使用 NodeExporter 作为采集器) | 41 |
内置告警规则
共 60 条。每条给出触发条件(PromQL)和告警后的处置步骤,导入后可以直接改阈值。
规则按采集方式分组,用哪种采集器就导哪一组。
Categraf 采集(35)
Conntrack表的使用率超过80%
S2 警告 · 持续 1 分钟 · 触发条件:
conntrack_ip_conntrack_count / conntrack_ip_conntrack_max > 0.8
处置步骤:
- 用 sysctl net.netfilter.nf_conntrack_count 与 nf_conntrack_max 确认当前水位;
- 用 conntrack -L | awk '{print $4}' | sort | uniq -c | sort -rn 看连接集中在哪类协议或来源;
- 应急调大:sysctl -w net.netfilter.nf_conntrack_max=<更大值>,并同步调大 nf_conntrack_buckets;
- 同时缩短 nf_conntrack_tcp_timeout_time_wait 等超时,或对不需要跟踪的流量用 iptables raw 表 NOTRACK。
CPU利用率较高
S3 提醒 · 持续 1 分钟 · 触发条件:
cpu_usage_active>75
cpu_usage_active>85
cpu_usage_active>95
处置步骤:
- 用 top -H 或 pidstat 1 找出占用最高的进程与线程;
- 用 perf top 或对应语言的 profiler(Java 用 arthas/async-profiler,Go 用 pprof)定位热点函数;
- 区分是业务量自然增长还是代码异常(死循环、正则回溯、频繁 GC);
- 业务量增长则扩容或限流,代码问题则修复后发布。
HTTP地址探测失败
S2 警告 · 持续 1 分钟 · 触发条件:
http_response_result_code != 0
处置步骤:
- 在采集机上手工 curl -sv <目标URL> 复现,看是连接失败、超时还是状态码不符;
- 连接失败则先确认目标端口通、进程活;
- 状态码不符则看目标服务日志定位;
- 确认探测配置里的超时、期望状态码、证书校验设置是否与实际相符,避免配置导致的误报。
IO比较繁忙
S2 警告 · 持续 1 分钟 · 触发条件:
rate(diskio_io_time[1m])/10 > 99
处置步骤:
- 用 iostat -x 1 确认是哪块盘、await 与 %util 的具体数值;
- 用 iotop -oP 或 pidstat -d 1 找出占用 IO 最高的进程;
- 常见元凶是数据库大查询、备份任务、日志刷盘——把可延后的任务错峰执行;
- 若是持续高负载而非突发,考虑换 SSD 或把热数据分散到多块盘。
NTP时间偏移太大
S2 警告 · 持续 1 分钟 · 触发条件:
ntp_offset_ms > 1000 or ntp_offset_ms < -1000
处置步骤:
- 用 chronyc tracking(或 ntpq -p)确认当前偏移量与上游源状态;
- 上游不可达则检查网络与防火墙是否放行 123/UDP;
- 用 chronyc sources -v 确认是否所有源都被标记为不可用,必要时更换 NTP 服务器;
- 偏移过大时 chrony 会拒绝平滑校正,需用 chronyc makestep 强制对时(注意对时间敏感的业务先做好准备)。
PING地址探测失败
S2 警告 · 持续 1 分钟 · 触发条件:
ping_result_code != 0
处置步骤:
- 在采集机上手工 ping -c 5 <目标> 复现,再用 mtr -n <目标> 定位丢包出现在哪一跳;
- 目标机若存活,确认它是否禁 ICMP(很多安全策略会禁),是则该探测本身不适用,应改用端口探测;
- 中间跳丢包的联系网络侧排查;
- 确认目标机自身是否宕机或网卡故障。
TME_WAIT状态的连接超过2万,可能需要关注
S2 警告 · 持续 1 分钟 · 触发条件:
netstat_tcp_time_wait > 20000
处置步骤:
- 用 ss -s 确认各状态连接数分布;
- 用 ss -tan state time-wait | awk '{print $4}' | cut -d: -f1 | sort | uniq -c | sort -rn 看集中在哪个目标;
- 根因通常是短连接过多——在应用侧改用长连接或连接池,这是最有效的手段;
- 应急可开启 net.ipv4.tcp_tw_reuse=1 并调大 net.ipv4.ip_local_port_range(不要开 tcp_tw_recycle,NAT 环境下会丢包)。
内存利用率比较高
S3 提醒 · 持续 1 分钟 · 触发条件:
mem_available_percent < 25
mem_available_percent < 15
mem_available_percent < 5
处置步骤:
- 用 free -h 确认 available 与 swap 使用情况;
- 用 ps aux --sort=-%mem | head 找出占用最高的进程,对比它们的历史内存曲线判断是否泄漏;
- 内核回收不及时可用 sync; echo 1 > /proc/sys/vm/drop_caches 释放 page cache(生产慎用);
- 确认是业务增长还是进程泄漏——泄漏要在应用侧抓堆定位,不能只靠重启。
文件句柄使用率超过90%
S2 警告 · 持续 1 分钟 · 触发条件:
linux_sysctl_fs_file_nr/linux_sysctl_fs_file_max>0.9
处置步骤:
- 用 cat /proc/sys/fs/file-nr 确认已分配与上限;
- 用 lsof | awk '{print $2}' | sort | uniq -c | sort -rn | head 找出占用句柄最多的进程;
- 应急调大:sysctl -w fs.file-max=<更大值>,并检查该进程的 ulimit -n 与 systemd LimitNOFILE;
- 根因通常是连接或文件未关闭,需在应用侧修复泄漏。
机器监控 - agent失联超过60秒
触发条件:
处置步骤:
- 先用 ping 与 ssh 确认机器本身是否存活,机器宕机要按宕机处理;
- 机器存活则用 systemctl status categraf 确认 agent 进程,看日志 journalctl -u categraf -n 100 定位;
- 常见原因是 agent 崩溃、配置错误、或到服务端的网络/认证不通——用 curl 手工打一次服务端的写入接口验证;
- 恢复后确认数据已连续,注意盲区期间的故障不会有历史告警。
机器监控 - 时间偏移超过3秒,请注意
持续 1 分钟 · 触发条件:
处置步骤:
- 用 date 与 chronyc tracking 确认本机时间与偏移量;
- 确认 chronyd/ntpd 服务是否在运行,未运行则启动并设为开机自启;
- 检查到 NTP 服务器的网络是否放行 123/UDP,必要时换用内网 NTP 源;
- 偏移过大时用 chronyc makestep 强制对时,对时间敏感的业务先做好准备。
每个CPU Core的平均负载任务超过3
S2 警告 · 持续 1 分钟 · 触发条件:
system_load_norm_1>3
处置步骤:
- 用 uptime 看 1/5/15 分钟负载趋势,判断是突发还是持续;
- 用 top 看 %wa(IO 等待)——高说明瓶颈在磁盘而非 CPU,按磁盘 IO 处理;
- 用 vmstat 1 看 r(运行队列)与 b(阻塞)列区分 CPU 密集与 IO 阻塞;
- 定位到具体进程后按 CPU 或 IO 的路径继续排查,必要时扩容。
硬盘监控 - inode使用率超过90%
S2 警告 · 持续 1 分钟 · 触发条件:
disk_inodes_used/disk_inodes_total >0.9
处置步骤:
- 用 df -i 确认是哪个挂载点的 inode 吃紧;
- 用 for d in /path/*; do echo "$(find $d | wc -l) $d"; done | sort -rn | head 逐层找出小文件最多的目录;
- 常见来源是 session 文件、邮件队列、缓存碎片、未清理的容器层——按业务确认后批量删除;
- 长期可在格式化时调大 inode 密度,或把小文件业务迁到独立分区。
硬盘监控 - 大于200G的盘,空间不足了
S3 提醒 · 持续 1 分钟 · 触发条件:
disk_free/1024/1024/1024 < 20 and disk_total/1024/1024/1024 >= 200
disk_free/1024/1024/1024 < 10 and disk_total/1024/1024/1024 >= 200
disk_free/1024/1024/1024 < 2 and disk_total/1024/1024/1024 >= 200
处置步骤:
- 用 df -h 定位挂载点,用 du -x --max-depth=1 <挂载点> | sort -h 找出占用最大的目录;
- 清理日志与过期数据,注意用 lsof +L1 检查已删除但未释放的文件;
- 评估是否该把数据目录迁到独立磁盘或加盘扩容;
- 若是数据库或对象存储的数据盘,按业务侧的归档策略下沉冷数据。
硬盘监控 - 小于200G的盘,空间不足了
S3 提醒 · 持续 1 分钟 · 触发条件:
disk_used_percent > 90 and disk_total/1024/1024/1024 < 200
disk_used_percent > 95 and disk_total/1024/1024/1024 < 200
disk_used_percent > 99 and disk_total/1024/1024/1024 < 200
处置步骤:
- 用 df -h 定位挂载点,用 du -x --max-depth=1 <挂载点> | sort -h 找出占用最大的目录;
- 系统盘常见是 /var/log 与容器镜像层(docker system df 看占用,docker system prune 清理);
- 用 lsof +L1 检查已删除但句柄未释放的文件;
- 长期需扩容或把大数据目录迁到独立磁盘。
硬盘监控 - 设备有报错
S2 警告 · 持续 1 分钟 · 触发条件:
disk_device_error>0
处置步骤:
- 用 dmesg -T | grep -iE 'i/o error|ata|scsi' 看内核报的具体错误与设备名;
- 用 smartctl -a /dev/sdX 看 SMART 属性,重点关注 Reallocated_Sector_Ct 与 Current_Pending_Sector;
- 确认该盘上的数据是否有副本或备份,优先保证数据安全再处理硬件;
- 确认为硬件故障的,安排停机换盘,RAID 环境下先确认阵列降级状态再操作。
硬盘监控 - 预测硬盘会在未来4小时内写满
S1 紧急 · 持续 1 分钟 · 触发条件:
predict_linear(disk_free[1h], 4*3600) < 0
处置步骤:
- 用 df -h 确认是哪个挂载点,再用 du -x --max-depth=1 <挂载点> | sort -h 逐层找出增长最快的目录;
- 优先清理日志(journalctl --vacuum-size=500M、清 *.log.N)与临时文件,这是最快见效的;
- 用 lsof +L1 找出已删除但句柄未释放的文件,重启对应进程才能真正释放空间;
- 确认是否有异常写入(应用死循环打日志、备份任务堆积),不解决根因清理只是拖延。
系统有OOM产生
S2 警告 · 触发条件:
increase(kernel_vmstat_oom_kill[2m]) > 0
处置步骤:
- 用 dmesg -T | grep -i 'killed process' 确认被杀的是哪个进程、当时占用多少内存;
- 用 free -h 与该进程的内存曲线判断是内存泄漏还是配置的上限过高;
- 给关键进程调整 oom_score_adj 降低被杀优先级,同时给次要进程设 cgroup 内存上限;
- 根因是泄漏的要在应用侧抓堆定位,只扩内存会反复复发。
网卡监控 - 入方向有丢包
S3 提醒 · 持续 1 分钟 · 触发条件:
increase(net_drop_in[1m]) > 0
处置步骤:
- 用 ip -s link show <网卡> 确认 RX dropped/errors 的增长;
- 用 ethtool -S <网卡> 看具体丢包原因(rx_no_buffer、rx_missed_errors 等);
- 环形缓冲区不足可用 ethtool -G <网卡> rx <更大值> 调大,并检查 net.core.netdev_max_backlog;
- 若伴随 CPU 软中断偏高(top 里 %si),开启 RPS/RSS 把中断分散到多核。
网卡监控 - 入方向有错包
S3 提醒 · 持续 1 分钟 · 触发条件:
increase(net_err_in[1m]) > 0
处置步骤:
- 用 ethtool -S <网卡> 看 rx_crc_errors、rx_frame_errors 等具体计数;
- 用 ethtool <网卡> 确认协商的速率与双工模式是否与对端一致(半双工是经典错包源);
- 检查网线/光模块,必要时换线或换口做交叉验证;
- 联系网络侧确认交换机对应端口的错包计数。
网卡监控 - 出方向有丢包
S3 提醒 · 持续 1 分钟 · 触发条件:
increase(net_drop_out[1m]) > 0
处置步骤:
- 用 ip -s link show <网卡> 确认 TX dropped/errors 的增长;
- 用 ethtool -S <网卡> 看具体计数,并用 tc -s qdisc show dev <网卡> 看队列是否溢出;
- 发送队列不足可调大 txqueuelen 与 ethtool -G <网卡> tx;
- 确认是否已跑满带宽——是则限流或扩带宽,不是则排查网卡驱动与对端设备。
网卡监控 - 出方向有错包
S3 提醒 · 持续 1 分钟 · 触发条件:
increase(net_err_out[1m]) > 0
处置步骤:
- 用 ethtool -S <网卡> 看 tx_errors、tx_carrier_errors 等具体计数;
- 用 ethtool <网卡> 确认速率与双工模式与对端一致;
- 检查网线/光模块并做交叉验证;
- 确认网卡驱动与固件版本,必要时升级。
网络地址探活失败
S2 警告 · 持续 1 分钟 · 触发条件:
net_response_result_code != 0
处置步骤:
- 在采集机上手工 telnet <目标> <端口> 或 nc -vz <目标> <端口> 复现;
- 到目标机用 ss -lntp | grep <端口> 确认进程是否在监听;
- 进程在监听则排查防火墙、安全组、以及是否只绑定了 127.0.0.1;
- 进程不在则按该服务自身的恢复流程拉起。
进程监控-有进程数为0,某进程可能挂了
S1 紧急 · 持续 1 分钟 · 触发条件:
procstat_lookup_count == 0
处置步骤:
- 用 ps -ef | grep <进程关键字> 确认确实不在,排除采集侧的匹配规则写错;
- 查该进程的日志与 dmesg -T | grep -i 'killed process',区分自身崩溃、被 OOM 杀死还是人工停止;
- 按服务自身流程拉起,并确认 systemd 的 Restart 策略是否生效;
- 若反复退出,先定位根因再拉起,避免陷入重启循环。
进程监控-进程句柄限制过小
S3 提醒 · 持续 1 分钟 · 触发条件:
procstat_rlimit_num_fds_soft < 2048
处置步骤:
- 用 cat /proc/<pid>/limits 确认 Max open files 的软硬上限;
- systemd 管理的服务在 unit 文件里加 LimitNOFILE=65535 后 systemctl daemon-reload 并重启;
- 非 systemd 的在启动脚本里加 ulimit -n 65535,或改 /etc/security/limits.conf;
- 注意软上限修改后必须重启进程才生效。
进程监控-进程总量超过600
S2 警告 · 持续 1 分钟 · 触发条件:
processes_total > 600
处置步骤:
- 用 ps -eo ppid | sort | uniq -c | sort -rn | head 找出 fork 子进程最多的父进程;
- 确认是正常的多进程模型(如 php-fpm、nginx worker)还是失控 fork;
- 失控的先停掉该父进程止血,再修复代码里的 fork 逻辑;
- 正常业务增长则调整 worker 数配置并评估是否需要扩容。
Hard disk - expected to be written full in 4 hours - categraf
S1 紧急 · 持续 1 分钟 · 触发条件:
predict_linear(disk_free[1h], 4*3600) < 0
处置步骤:
- 用 df -h 确认是哪个挂载点,再用 du -x --max-depth=1 <挂载点> | sort -h 逐层找出增长最快的目录;
- 优先清理日志(journalctl --vacuum-size=500M、清 *.log.N)与临时文件,这是最快见效的;
- 用 lsof +L1 找出已删除但句柄未释放的文件,重启对应进程才能真正释放空间;
- 确认是否有异常写入(应用死循环打日志、备份任务堆积),不解决根因清理只是拖延。
Hard disk - IO is a bit busy - categraf
S2 警告 · 持续 1 分钟 · 触发条件:
rate(diskio_io_time[1m])/10 > 99
处置步骤:
- 用 iostat -x 1 确认是哪块盘、await 与 %util 的具体数值;
- 用 iotop -oP 或 pidstat -d 1 找出占用 IO 最高的进程;
- 常见元凶是数据库大查询、备份任务、日志刷盘——把可延后的任务错峰执行;
- 若是持续高负载而非突发,考虑换 SSD 或把热数据分散到多块盘。
Lost connection with monitoring target - categraf
触发条件:
处置步骤:
- 先用 ping 与 ssh 确认机器本身是否存活,机器宕机要按宕机处理;
- 机器存活则用 systemctl status categraf 确认 agent 进程,看日志 journalctl -u categraf -n 100 定位;
- 常见原因是 agent 崩溃、配置错误、或到服务端的网络/认证不通——用 curl 手工打一次服务端的写入接口验证;
- 恢复后确认数据已连续,注意盲区期间的故障不会有历史告警。
Machine load - high memory, please pay attention - categraf
S3 提醒 · 持续 1 分钟 · 触发条件:
mem_available_percent < 25
mem_available_percent < 15
mem_available_percent < 5
处置步骤:
- 用 free -h 确认 available 与 swap 使用情况;
- 用 ps aux --sort=-%mem | head 找出占用最高的进程,对比它们的历史内存曲线判断是否泄漏;
- 内核回收不及时可用 sync; echo 1 > /proc/sys/vm/drop_caches 释放 page cache(生产慎用);
- 确认是业务增长还是进程泄漏——泄漏要在应用侧抓堆定位,不能只靠重启。
number of TME_WAIT exceeds 20,000 - categraf
S2 警告 · 持续 1 分钟 · 触发条件:
netstat_tcp_time_wait > 20000
处置步骤:
- 用 ss -s 确认各状态连接数分布;
- 用 ss -tan state time-wait | awk '{print $4}' | cut -d: -f1 | sort | uniq -c | sort -rn 看集中在哪个目标;
- 根因通常是短连接过多——在应用侧改用长连接或连接池,这是最有效的手段;
- 应急可开启 net.ipv4.tcp_tw_reuse=1 并调大 net.ipv4.ip_local_port_range(不要开 tcp_tw_recycle,NAT 环境下会丢包)。
packet loss in the inbound direction - categraf
S3 提醒 · 持续 1 分钟 · 触发条件:
increase(net_drop_in[1m]) > 0
处置步骤:
- 用 ip -s link show <网卡> 确认 RX dropped/errors 的增长;
- 用 ethtool -S <网卡> 看具体丢包原因(rx_no_buffer、rx_missed_errors 等);
- 环形缓冲区不足可用 ethtool -G <网卡> rx <更大值> 调大,并检查 net.core.netdev_max_backlog;
- 若伴随 CPU 软中断偏高(top 里 %si),开启 RPS/RSS 把中断分散到多核。
packet loss in the outbound direction - categraf
S3 提醒 · 持续 1 分钟 · 触发条件:
increase(net_drop_out[1m]) > 0
处置步骤:
- 用 ip -s link show <网卡> 确认 TX dropped/errors 的增长;
- 用 ethtool -S <网卡> 看具体计数,并用 tc -s qdisc show dev <网卡> 看队列是否溢出;
- 发送队列不足可调大 txqueuelen 与 ethtool -G <网卡> tx;
- 确认是否已跑满带宽——是则限流或扩带宽,不是则排查网卡驱动与对端设备。
大于200G的盘,空间不足了
S3 提醒 · 持续 1 分钟 · 触发条件:
disk_free/1024/1024/1024 < 20 and disk_total/1024/1024/1024 >= 200
disk_free/1024/1024/1024 < 10 and disk_total/1024/1024/1024 >= 200
disk_free/1024/1024/1024 < 2 and disk_total/1024/1024/1024 >= 200
处置步骤:
- 用 df -h 定位挂载点,用 du -x --max-depth=1 <挂载点> | sort -h 找出占用最大的目录;
- 清理日志与过期数据,注意用 lsof +L1 检查已删除但未释放的文件;
- 评估是否该把数据目录迁到独立磁盘或加盘扩容;
- 若是数据库或对象存储的数据盘,按业务侧的归档策略下沉冷数据。
小于200G的盘,空间不足了
S3 提醒 · 持续 1 分钟 · 触发条件:
disk_used_percent > 90 and disk_total/1024/1024/1024 < 200
disk_used_percent > 95 and disk_total/1024/1024/1024 < 200
disk_used_percent > 99 and disk_total/1024/1024/1024 < 200
处置步骤:
- 用 df -h 定位挂载点,用 du -x --max-depth=1 <挂载点> | sort -h 找出占用最大的目录;
- 系统盘常见是 /var/log 与容器镜像层(docker system df 看占用,docker system prune 清理);
- 用 lsof +L1 检查已删除但句柄未释放的文件;
- 长期需扩容或把大数据目录迁到独立磁盘。
Exporter 采集(12)
A certain disk is unable to read/write normally
S1 紧急 · 持续 1 分钟 · 触发条件:
(node_filesystem_device_error{mountpoint!~"/var/lib/.*",mountpoint!~"/run.*"}) > 0
处置步骤:
- 用 dmesg -T | grep -iE 'i/o error|ata|scsi' 看内核报的具体错误与设备名;
- 用 smartctl -a /dev/sdX 看 SMART 属性,重点关注 Reallocated_Sector_Ct 与 Current_Pending_Sector;
- 确认该盘上的数据是否有副本或备份,优先保证数据安全再处理硬件;
- 确认为硬件故障的,安排停机换盘,RAID 环境下先确认阵列降级状态再操作。
Disk needs to be cleaned - utilization has reached 92% - node exporter
S1 紧急 · 持续 1 分钟 · 触发条件:
(100 - ((node_filesystem_avail_bytes * 100) / node_filesystem_size_bytes) ) > 92
处置步骤:
- 用 df -h 定位挂载点,用 du -x --max-depth=1 <挂载点> | sort -h 找出占用最大的目录;
- 系统盘常见是 /var/log 与容器镜像层(docker system df 看占用,docker system prune 清理);
- 用 lsof +L1 检查已删除但句柄未释放的文件;
- 长期需扩容或把大数据目录迁到独立磁盘。
Insufficient computational resources - average load per core of the machine is greater than 10 - node exporter
S2 警告 · 持续 1 分钟 · 触发条件:
avg (node_load1) by (instance)/count(count(node_cpu_seconds_total) by (cpu,instance)) by (instance) >10
处置步骤:
- 用 uptime 看 1/5/15 分钟负载趋势,判断是突发还是持续;
- 用 top 看 %wa(IO 等待)——高说明瓶颈在磁盘而非 CPU,按磁盘 IO 处理;
- 用 vmstat 1 看 r(运行队列)与 b(阻塞)列区分 CPU 密集与 IO 阻塞;
- 定位到具体进程后按 CPU 或 IO 的路径继续排查,必要时扩容。
Insufficient file handles - usage exceeds 90% - node exporter
You can increase the file handle limit or expand the capacity
S2 警告 · 持续 1 分钟 · 触发条件:
(node_filefd_allocated/node_filefd_maximum*100) > 90
处置步骤:
- 用 cat /proc/sys/fs/file-nr 确认已分配与上限;
- 用 lsof | awk '{print $2}' | sort | uniq -c | sort -rn | head 找出占用句柄最多的进程;
- 应急调大:sysctl -w fs.file-max=<更大值>,并检查该进程的 ulimit -n 与 systemd LimitNOFILE;
- 根因通常是连接或文件未关闭,需在应用侧修复泄漏。
Insufficient inode resources - usage exceeds 90% - node exporter
S2 警告 · 持续 1 分钟 · 触发条件:
(100 - ((node_filesystem_files_free * 100) / node_filesystem_files))>90
处置步骤:
- 用 df -i 确认是哪个挂载点的 inode 吃紧;
- 用 for d in /path/*; do echo "$(find $d | wc -l) $d"; done | sort -rn | head 逐层找出小文件最多的目录;
- 常见来源是 session 文件、邮件队列、缓存碎片、未清理的容器层——按业务确认后批量删除;
- 长期可在格式化时调大 inode 密度,或把小文件业务迁到独立分区。
Insufficient memory resources - utilization is greater than 75% - node exporter
Expansion or upgrading of configuration is required
S2 警告 · 持续 1 分钟 · 触发条件:
(node_memory_MemTotal_bytes - node_memory_MemFree_bytes - (node_memory_Cached_bytes + node_memory_Buffers_bytes))/node_memory_MemTotal_bytes*100 > 75
处置步骤:
- 用 free -h 确认 available 与 swap 使用情况;
- 用 ps aux --sort=-%mem | head 找出占用最高的进程,对比它们的历史内存曲线判断是否泄漏;
- 内核回收不及时可用 sync; echo 1 > /proc/sys/vm/drop_caches 释放 page cache(生产慎用);
- 确认是业务增长还是进程泄漏——泄漏要在应用侧抓堆定位,不能只靠重启。
Insufficient memory resources - utilization is greater than 95% - node exporter
S1 紧急 · 持续 1 分钟 · 触发条件:
(node_memory_MemTotal_bytes - node_memory_MemFree_bytes - (node_memory_Cached_bytes + node_memory_Buffers_bytes))/node_memory_MemTotal_bytes*100 > 95
处置步骤:
- 用 free -h 确认 available 与 swap 使用情况;
- 用 ps aux --sort=-%mem | head 找出占用最高的进程,对比它们的历史内存曲线判断是否泄漏;
- 内核回收不及时可用 sync; echo 1 > /proc/sys/vm/drop_caches 释放 page cache(生产慎用);
- 确认是业务增长还是进程泄漏——泄漏要在应用侧抓堆定位,不能只靠重启。
Packet loss in the inbound direction of the network card - node exporter
S2 警告 · 持续 1 分钟 · 触发条件:
rate(node_network_receive_drop_total{device=~"e.*"}[1m]) > 3
处置步骤:
- 用 ip -s link show <网卡> 确认 RX dropped/errors 的增长;
- 用 ethtool -S <网卡> 看具体丢包原因(rx_no_buffer、rx_missed_errors 等);
- 环形缓冲区不足可用 ethtool -G <网卡> rx <更大值> 调大,并检查 net.core.netdev_max_backlog;
- 若伴随 CPU 软中断偏高(top 里 %si),开启 RPS/RSS 把中断分散到多核。
Packet loss in the outbound direction of the network card - node exporter
S2 警告 · 持续 1 分钟 · 触发条件:
rate(node_network_transmit_drop_total{device=~"e.*"}[1m]) > 3
处置步骤:
- 用 ip -s link show <网卡> 确认 TX dropped/errors 的增长;
- 用 ethtool -S <网卡> 看具体计数,并用 tc -s qdisc show dev <网卡> 看队列是否溢出;
- 发送队列不足可调大 txqueuelen 与 ethtool -G <网卡> tx;
- 确认是否已跑满带宽——是则限流或扩带宽,不是则排查网卡驱动与对端设备。
System conntrack needs to be adjusted - usage exceeds 80% - node exporter
S2 警告 · 持续 1 分钟 · 触发条件:
node_nf_conntrack_entries / node_nf_conntrack_entries_limit*100 > 80
处置步骤:
- 用 sysctl net.netfilter.nf_conntrack_count 与 nf_conntrack_max 确认当前水位;
- 用 conntrack -L | awk '{print $4}' | sort | uniq -c | sort -rn 看连接集中在哪类协议或来源;
- 应急调大:sysctl -w net.netfilter.nf_conntrack_max=<更大值>,并同步调大 nf_conntrack_buckets;
- 同时缩短 nf_conntrack_tcp_timeout_time_wait 等超时,或对不需要跟踪的流量用 iptables raw 表 NOTRACK。
System experiences OOM - node exporter
S2 警告 · 持续 1 分钟 · 触发条件:
increase(node_vmstat_oom_kill[1m]) > 0
处置步骤:
- 用 dmesg -T | grep -i 'killed process' 确认被杀的是哪个进程、当时占用多少内存;
- 用 free -h 与该进程的内存曲线判断是内存泄漏还是配置的上限过高;
- 给关键进程调整 oom_score_adj 降低被杀优先级,同时给次要进程设 cgroup 内存上限;
- 根因是泄漏的要在应用侧抓堆定位,只扩内存会反复复发。
Too many running processes - exceeding 3000 - node exporter
S2 警告 · 持续 1 分钟 · 触发条件:
node_procs_running > 3000
处置步骤:
- 用 ps -eo ppid | sort | uniq -c | sort -rn | head 找出 fork 子进程最多的父进程;
- 确认是正常的多进程模型(如 php-fpm、nginx worker)还是失控 fork;
- 失控的先停掉该父进程止血,再修复代码里的 fork 逻辑;
- 正常业务增长则调整 worker 数配置并评估是否需要扩容。
Telegraf 采集(13)
Address is unreachable by PING, please pay attention - telegraf
S1 紧急 · 持续 1 分钟 · 触发条件:
ping_result_code != 0
处置步骤:
- 在采集机上手工 ping -c 5 <目标> 复现,再用 mtr -n <目标> 定位丢包出现在哪一跳;
- 目标机若存活,确认它是否禁 ICMP(很多安全策略会禁),是则该探测本身不适用,应改用端口探测;
- 中间跳丢包的联系网络侧排查;
- 确认目标机自身是否宕机或网卡故障。
Hard disk - expected to be written full in 4 hours - telegraf
S1 紧急 · 持续 1 分钟 · 触发条件:
predict_linear(disk_free[1h], 4*3600) < 0
处置步骤:
- 用 df -h 确认是哪个挂载点,再用 du -x --max-depth=1 <挂载点> | sort -h 逐层找出增长最快的目录;
- 优先清理日志(journalctl --vacuum-size=500M、清 *.log.N)与临时文件,这是最快见效的;
- 用 lsof +L1 找出已删除但句柄未释放的文件,重启对应进程才能真正释放空间;
- 确认是否有异常写入(应用死循环打日志、备份任务堆积),不解决根因清理只是拖延。
Hard disk - IO is very busy - telegraf
S2 警告 · 持续 1 分钟 · 触发条件:
rate(diskio_io_time[1m])/10 > 99
处置步骤:
- 用 iostat -x 1 确认是哪块盘、await 与 %util 的具体数值;
- 用 iotop -oP 或 pidstat -d 1 找出占用 IO 最高的进程;
- 常见元凶是数据库大查询、备份任务、日志刷盘——把可延后的任务错峰执行;
- 若是持续高负载而非突发,考虑换 SSD 或把热数据分散到多块盘。
Lost connection with monitoring target - telegraf
触发条件:
处置步骤:
- 先用 ping 与 ssh 确认机器本身是否存活,机器宕机要按宕机处理;
- 机器存活则用 systemctl status categraf 确认 agent 进程,看日志 journalctl -u categraf -n 100 定位;
- 常见原因是 agent 崩溃、配置错误、或到服务端的网络/认证不通——用 curl 手工打一次服务端的写入接口验证;
- 恢复后确认数据已连续,注意盲区期间的故障不会有历史告警。
Machine load - high CPU, please pay attention - telegraf
S3 提醒 · 持续 1 分钟 · 触发条件:
cpu_usage_idle{cpu="cpu-total"} < 25
处置步骤:
- 用 top -H 或 pidstat 1 找出占用最高的进程与线程;
- 用 perf top 或对应语言的 profiler(Java 用 arthas/async-profiler,Go 用 pprof)定位热点函数;
- 区分是业务量自然增长还是代码异常(死循环、正则回溯、频繁 GC);
- 业务量增长则扩容或限流,代码问题则修复后发布。
Machine load - high memory, please pay attention - telegraf
S2 警告 · 持续 1 分钟 · 触发条件:
mem_available_percent < 25
处置步骤:
- 用 free -h 确认 available 与 swap 使用情况;
- 用 ps aux --sort=-%mem | head 找出占用最高的进程,对比它们的历史内存曲线判断是否泄漏;
- 内核回收不及时可用 sync; echo 1 > /proc/sys/vm/drop_caches 释放 page cache(生产慎用);
- 确认是业务增长还是进程泄漏——泄漏要在应用侧抓堆定位,不能只靠重启。
Network connection - number of TME_WAIT exceeds 20,000 - telegraf
S2 警告 · 持续 1 分钟 · 触发条件:
netstat_tcp_time_wait > 20000
处置步骤:
- 用 ss -s 确认各状态连接数分布;
- 用 ss -tan state time-wait | awk '{print $4}' | cut -d: -f1 | sort | uniq -c | sort -rn 看集中在哪个目标;
- 根因通常是短连接过多——在应用侧改用长连接或连接池,这是最有效的手段;
- 应急可开启 net.ipv4.tcp_tw_reuse=1 并调大 net.ipv4.ip_local_port_range(不要开 tcp_tw_recycle,NAT 环境下会丢包)。
packet loss in the inbound direction - telegraf
S3 提醒 · 持续 1 分钟 · 触发条件:
increase(net_drop_in[1m]) > 0
处置步骤:
- 用 ip -s link show <网卡> 确认 RX dropped/errors 的增长;
- 用 ethtool -S <网卡> 看具体丢包原因(rx_no_buffer、rx_missed_errors 等);
- 环形缓冲区不足可用 ethtool -G <网卡> rx <更大值> 调大,并检查 net.core.netdev_max_backlog;
- 若伴随 CPU 软中断偏高(top 里 %si),开启 RPS/RSS 把中断分散到多核。
packet loss in the outbound direction - telegraf
S3 提醒 · 持续 1 分钟 · 触发条件:
increase(net_drop_out[1m]) > 0
处置步骤:
- 用 ip -s link show <网卡> 确认 TX dropped/errors 的增长;
- 用 ethtool -S <网卡> 看具体计数,并用 tc -s qdisc show dev <网卡> 看队列是否溢出;
- 发送队列不足可调大 txqueuelen 与 ethtool -G <网卡> tx;
- 确认是否已跑满带宽——是则限流或扩带宽,不是则排查网卡驱动与对端设备。
Port detection failed, please pay attention - telegraf
S1 紧急 · 持续 1 分钟 · 触发条件:
net_response_result_code != 0
处置步骤:
- 在采集机上手工 telnet <目标> <端口> 或 nc -vz <目标> <端口> 复现;
- 到目标机用 ss -lntp | grep <端口> 确认进程是否在监听;
- 进程在监听则排查防火墙、安全组、以及是否只绑定了 127.0.0.1;
- 进程不在则按该服务自身的恢复流程拉起。
process handle limit is too small - telegraf
S3 提醒 · 持续 1 分钟 · 触发条件:
procstat_rlimit_num_fds_soft < 2048
处置步骤:
- 用 cat /proc/<pid>/limits 确认 Max open files 的软硬上限;
- systemd 管理的服务在 unit 文件里加 LimitNOFILE=65535 后 systemctl daemon-reload 并重启;
- 非 systemd 的在启动脚本里加 ulimit -n 65535,或改 /etc/security/limits.conf;
- 注意软上限修改后必须重启进程才生效。
Process monitoring - lookup failure - telegraf
S1 紧急 · 持续 1 分钟 · 触发条件:
procstat_lookup_result_code != 0
处置步骤:
- 在采集机上按配置的匹配方式手工执行 ps/pgrep 复现;
- 进程确实不在则按服务恢复流程处理;
- 进程在但探测失败,检查 procstat 配置的 pid_file、exe、pattern 是否写错,以及采集账号是否有权限读取 /proc;
- 容器环境下确认 categraf 是否挂载了宿主机的 /proc。
there are processes with 0 count, a certain process may have crashed - telegraf
S1 紧急 · 持续 1 分钟 · 触发条件:
procstat_lookup_running == 0
处置步骤:
- 用 ps -ef | grep <进程关键字> 确认确实不在,排除采集侧的匹配规则写错;
- 查该进程的日志与 dmesg -T | grep -i 'killed process',区分自身崩溃、被 OOM 杀死还是人工停止;
- 按服务自身流程拉起,并确认 systemd 的 Restart 策略是否生效;
- 若反复退出,先定位根因再拉起,避免陷入重启循环。
指标说明
共 132 条,和仪表盘、告警规则里用到的指标一一对应。
| 指标 | 含义 | 单位 |
|---|---|---|
cpu_usage_guest | CPU Guest 时间占比 — CPU 为 Guest OS 运行虚拟 CPU 的时间占比。 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值 | % |
cpu_usage_iowait | CPU iowait 时间占比 — 表示 CPU 花费在等待 I/O 操作(输入/输出)完成的时间比例; 标签 cpu="cpu-total",表示整机的 iowait 占用率; 标签 cpu="0",表示 0 号 CPU 的 iowait 占用率 | % |
cpu_usage_steal | CPU Steal 时间占比 — 表示虚拟机(Guest OS)CPU 时间被虚拟化管理器(Hypervisor)用于运行其他虚拟机的时间比例。物理机中这个指标值是 0,没有用处;虚拟机中这个指标值长时间大于 10 表示争抢严重。参考资料; 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值 | % |
cpu_usage_nice | CPU 低优先级进程的时间占比 — 在Linux系统中,每个进程都有一个“nice”值,这个值的范围通常是从-20到19。默认的 nice 值为0。负的 nice 值表示高优先级(更快的 CPU 访问),而正的 nice 值表示低优先级(更慢的 CPU 访问)。该指标统计 nice 值为 1-19 的进程的时间占比。 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值 | % |
cpu_usage_system | CPU 内核态时间占比 — 表示 CPU 内核态的时间占比; 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值 | % |
cpu_usage_active | CPU 利用率 — - 标签 cpu="cpu-total",表示整机的 CPU 利用率; 标签 cpu="0",表示 0 号 CPU 的单核利用率 | % |
cpu_usage_user | CPU 用户态时间占比 — 表示 CPU 用户态的时间占比; 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值 | % |
cpu_usage_irq | CPU 硬中断时间占比 — 表示 CPU 处理硬中断的时间占比; 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值 | % |
cpu_usage_idle | CPU 空闲率 — - 标签 cpu="cpu-total",表示整机的 CPU 空闲率; 标签 cpu="0",表示 0 号 CPU 的单核空闲率 | % |
cpu_usage_softirq | CPU 软中断时间占比 — 表示 CPU 处理软中断的时间占比; 标签 cpu="cpu-total",表示整机的统计值; 标签 cpu="0",表示 0 号 CPU 的统计值 | % |
netstat_tcp_established | ESTABLISHED 状态的网络链接数 | |
netstat_tcp_fin_wait1 | FIN_WAIT1 状态的网络链接数 | |
netstat_tcp_fin_wait2 | FIN_WAIT2 状态的网络链接数 | |
100 * conntrack_ip_conntrack_count / conntrack_ip_conntrack_max | IP conntrack 使用率 — 如果用满了,通常会在系统日志中看到:conntrack table full 这样的报错,可以调整系统最大值解决 | % |
netstat_tcp_last_ack | LAST_ACK 状态的网络链接数 | |
netstat_tcp_listen | LISTEN 状态的网络链接数 | |
100 * conntrack_nf_conntrack_count / conntrack_nf_conntrack_max | NF conntrack 使用率 | % |
increase(kernel_vmstat_oom_kill[1m]) | 1分钟内 OOM 次数统计 — 取自 /proc/vmstat,需要较高版本的内核,没记错的话应该是 4.13 以上版本 | |
netstat_tcp_syn_recv | SYN_RECV 状态的网络链接数 | |
netstat_tcp_syn_sent | SYN_SENT 状态的网络链接数 | |
netstat_tcp_time_wait | TIME_WAIT 状态的网络链接数 — categraf 配置文件 conf/input.netstat/netstat.toml 中 disable_connection_stats 默认配置为 true,是因为在网络连接比较多的机器上,获取各个状态的连接数会耗费较多 CPU,所以默认 disable 掉了。 | |
netstat_tcp_tw | TIME_WAIT 状态的网络链接数(推荐) — 读取自 /proc/net/sockstat。 | |
(mem_swap_total - mem_swap_free)/mem_swap_total * 100 and mem_swap_total > 0 | 交换空间使用率 — 交换空间使用率。计算原子取自 /proc/meminfo。 | % |
mem_swap_total - mem_swap_free | 交换空间使用量 — 交换空间使用量。计算原子取自 /proc/meminfo。 | bytes |
mem_swap_total | 交换空间总量 — 交换空间总量。取自 /proc/meminfo。 | bytes |
mem_swap_free | 交换空间空闲量 — 交换空间空闲量。取自 /proc/meminfo。 | bytes |
mem_buffered | 内存 Buffered 量 — 用作缓冲区的内存量。取自 /proc/meminfo。 | bytes |
mem_cached | 内存 Cached 量 — 用作文件缓存的内存量。取自 /proc/meminfo。 | bytes |
mem_used_percent | 内存使用率 — 内存使用率 | % |
100 - mem_available_percent | 内存使用率(基于MemAvailable) — 内存使用率。基于 MemAvailable 计算更准确,但是老版本的 Linux 不支持。 | % |
mem_used | 内存使用量 — 内存使用量 = Total - Free - Buffered - Cached | bytes |
mem_available_percent | 内存可用率 — 可以立即分配给进程的可用内存量除以内存总量。分子分母的值均取自 /proc/meminfo。 | % |
mem_available | 内存可用量 — 可以立即分配给进程的可用内存量。取自 /proc/meminfo。 | bytes |
mem_total | 内存总量 — 内存总量。取自 /proc/meminfo。 | bytes |
mem_active | 内存活跃量 — 这个字段表示当前活跃使用的内存总量,即系统最近访问过并且预计很快会再次使用的内存页面。取自 /proc/meminfo。 | bytes |
mem_free | 内存空闲量 — 未使用的内存量。取自 /proc/meminfo。 | bytes |
mem_inactive | 内存非活跃量 — 在上一采样周期未以某种方式使用的内存量。取自 /proc/meminfo。 | bytes |
netstat_udp_socket | 当前 UDP 连接数 | |
disk_inodes_used / disk_inodes_total * 100 | 硬盘 inode 使用率 — 如果存储了很多小文件,需要注意 inode 使用情况。 | % |
disk_inodes_used | 硬盘 inode 使用量 — 如果存储了很多小文件,需要注意 inode 使用情况。 | |
disk_inodes_free | 硬盘 inode 剩余量 — 如果存储了很多小文件,需要注意 inode 使用情况。 | |
disk_inodes_total | 硬盘 inode 总量 — 如果存储了很多小文件,需要注意 inode 使用情况。 | |
irate(diskio_write_time[2m])/irate(diskio_writes[2m]) | 硬盘 IO - 写请求平均耗时 | ms |
diskio_write_time | 硬盘 IO - 写请求等待处理的时间 — 写入请求在磁盘上等待的时间。同时等待的多个写入请求会增加该数字。例如,如果 8 个请求均平均等待 1000 毫秒,则报告 8000。 | ms |
diskio_weighted_io_time | 硬盘 IO - 加权 IO 处理时间 — 只要设备在处理 IO,不管同时处理了几个,diskio_io_time 就会递增;同时处理的 IO 数量乘以时间就得到加权的值:diskio_weighted_io_time。 | ms |
irate(diskio_io_time[2m])/1000*100 | 硬盘 IO - 时间维度 Utilization — 在时间维度统计硬盘 IO 时间占比,比如该值是 50%,表示有 50% 的时间是在处理 IO,该值 100%,表示一直在处理 IO,但是注意,现代磁盘设备具备并行处理多个 I/O 请求的能力,所以即便该值是 100%,可能硬盘还是可以接收新的处理请求。 比如某人有两只手,最近 1 分钟一直在用单手劳动,从时间维度来看,利用率是 100%,但即便是 100%,再给他更多的活,他也能干,因为他还有一只手可用。 | % |
irate(diskio_write_bytes[2m]) | 硬盘 IO - 每秒写入字节数量 | bytes/s |
irate(diskio_writes{}[2m]) | 硬盘 IO - 每秒写次数 | |
irate(diskio_merged_writes[2m]) | 硬盘 IO - 每秒合并写请求次数 — 相邻的读取和写入可能会为了效率而被合并。因此,在最终交给磁盘之前,两个4K的读取可能会变成一个8K的读取,因此它将被计数(和排队)为仅有一个I/O。这些字段让你知道这种情况发生的频率。 | |
irate(diskio_merged_reads[2m]) | 硬盘 IO - 每秒合并读请求次数 — 相邻的读取和写入可能会为了效率而被合并。因此,在最终交给磁盘之前,两个4K的读取可能会变成一个8K的读取,因此它将被计数(和排队)为仅有一个I/O。这些字段让你知道这种情况发生的频率。 | |
irate(diskio_read_bytes[2m]) | 硬盘 IO - 每秒读取字节数量 | bytes/s |
irate(diskio_reads{}[2m]) | 硬盘 IO - 每秒读次数 | |
diskio_io_time | 硬盘 IO - 硬盘在处理 IO 的时间 — 硬盘在处理 IO 的时间,单位是毫秒。假设最近 1 秒内有 500 毫秒是在处理 IO,这个值就要加 500,这是一个单调递增的 Counter 值,从操作系统启动之后就会一直涨。实际使用的时候,一般使用该指标计算硬盘 IO UTIL(时间维度的百分比)。 | ms |
diskio_iops_in_progress | 硬盘 IO - 设备驱动程序正在处理的 IO 数量 — 当前已经分配给设备驱动程序并且尚未完成的请求数量,Gauge 类型。如果 I/O 请求已经进入队列,但是尚未分配给设备驱动程序,则不统计在内。 | |
irate(diskio_read_time[2m])/irate(diskio_reads[2m]) | 硬盘 IO - 读请求平均耗时 | ms |
diskio_read_time | 硬盘 IO - 读请求等待处理的时间 — 读取请求在磁盘上等待的时间。同时等待的多个读取请求会增加该数字。例如,如果 5 个请求均平均等待 100 毫秒,则报告 500。 | ms |
irate(diskio_weighted_io_time[1m])/1000 | 硬盘 IO - 队列深度 — 假设过去 1000 毫秒内有 5000 毫秒的加权等待时间,相当于平均有 5 个 IO 请求在等待,即队列深度为 5。 | |
disk_used_percent | 硬盘使用率 — 硬盘空间使用率。 | % |
disk_used | 硬盘使用量 — 使用 SI 标准渲染数据,和 df 命令保持一致。 | bytes |
disk_device_error | 硬盘信息读取是否出错 — 0 表示正常,没有出错;非 0 表示获取硬盘信息出错了。 | |
disk_free | 硬盘剩余量 — 使用 SI 标准渲染数据,和 df 命令保持一致。 | bytes |
disk_total | 硬盘总量 — 使用 SI 标准渲染数据,和 df 命令保持一致。 | bytes |
system_n_cpus | 系统 CPU 核数 — CPU 逻辑核的数量。 | |
system_uptime | 系统启动时长 — 操作系统启动了多久,单位:秒。 | s |
system_load1 | 系统平均负载 - 最近 1 分钟 — 取自 /proc/loadavg。 | |
system_load15 | 系统平均负载 - 最近 15 分钟 — 取自 /proc/loadavg。 | |
system_load5 | 系统平均负载 - 最近 5 分钟 — 取自 /proc/loadavg。 | |
system_load_norm_1 | 系统平均负载(单核) - 最近 1 分钟 — 相当于 system_load1 / system_n_cpus | |
system_load_norm_15 | 系统平均负载(单核) - 最近 15 分钟 — 相当于 system_load15 / system_n_cpus | |
system_load_norm_5 | 系统平均负载(单核) - 最近 5 分钟 — 相当于 system_load5 / system_n_cpus | |
irate(net_drop_in[2m]) | 网卡入方向(接收)每秒丢弃的数据包个数 — 原始指标 net_drop_in 表示操作系统启动之后各个网卡入方向(接收)丢弃的数据包总数。 | |
irate(net_packets_recv[2m]) | 网卡入方向(接收)每秒数据包数 — 原始指标 net_packets_recv 表示操作系统启动之后各个网卡入方向(接收)数据包总数。 | |
irate(net_err_in[2m]) | 网卡入方向(接收)每秒错包数 — 原始指标 net_err_in 表示操作系统启动之后各个网卡入方向(接收)错包总数。 | |
irate(net_drop_out[2m]) | 网卡出方向(发送)每秒丢弃的数据包个数 — 原始指标 net_drop_out 表示操作系统启动之后各个网卡出方向(发送)丢弃的数据包总数。 | |
irate(net_packets_sent[2m]) | 网卡出方向(发送)每秒数据包数 — 原始指标 net_packets_sent 表示操作系统启动之后各个网卡出方向(发送)数据包总数。 | |
irate(net_err_out[2m]) | 网卡出方向(发送)每秒错包数 — 原始指标 net_err_out 表示操作系统启动之后各个网卡出方向(发送)错包总数。 | |
irate(net_bytes_sent[2m]) * 8 | 网卡每秒发送的 bit 量 — 原始指标 net_bytes_sent 表示操作系统启动之后发送的 byte 总量,因为网卡流量习惯使用 bit 作为单位,所以在表达式中做了换算。 | bit/s |
irate(net_bytes_recv[2m]) * 8 | 网卡每秒接收的 bit 量 — 原始指标 net_bytes_recv 表示操作系统启动之后接收的 byte 总量,因为网卡流量习惯使用 bit 作为单位,所以在表达式中做了换算。 | bit/s |
processes_dead | 进程数 - “僵死”状态的进程数 — 处于“僵死”状态的进程数,它是由 Linux 上的 X 状态代码表示的。 | |
processes_paging | 进程数 - “分页”状态的进程数 — 处于“分页”状态的进程数,它是由 Linux 上的 W 状态代码表示的。 | |
processes_stopped | 进程数 - 停止的进程数 — 停止的进程数,由 T 状态代码表示。 | |
processes_zombies | 进程数 - 僵尸进程数 — 僵尸进程数,由 Z 状态代码表示。 | |
processes_total | 进程数 - 总数 — 实例上的总进程数。 | |
processes_unknown | 进程数 - 未知状态的进程数 — 未知状态的进程数。 | |
processes_sleeping | 进程数 - 正在睡眠的进程数 — 睡眠的进程数,由 S 状态代码表示。 | |
processes_running | 进程数 - 正在运行的进程数 — 正在运行的进程数,由 R 状态代码表示。 | |
processes_idle | 进程数 - 空闲的数量 — 处于空闲状态 (睡眠超过 20 秒) 的进程数。 | |
processes_total_threads | 进程数 - 线程总数 — 组成进程的总线程数。该指标仅适用于 Linux 实例。 | |
processes_blocked | 进程数 - 被阻止的进程数 — 被阻止的进程数量。 | |
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="steal"}[2m]) ) * 100 | CPU Steal 时间占比(整机平均) | % |
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="system"}[2m]) ) * 100 | CPU 内核态时间占比(整机平均) | % |
avg without (mode,cpu) ( 1 - irate(node_cpu_seconds_total{mode="idle"}[2m]) ) * 100 | CPU 利用率(整机平均) | % |
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="user"}[2m]) ) * 100 | CPU 用户态时间占比(整机平均) | % |
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="irq"}[2m]) ) * 100 | CPU 硬中断时间占比(整机平均) | % |
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="idle"}[2m]) ) * 100 | CPU 空闲率(整机平均) | % |
avg without (mode,cpu) ( irate(node_cpu_seconds_total{mode="softirq"}[2m]) ) * 100 | CPU 软中断时间占比(整机平均) | % |
(node_memory_SwapTotal_bytes - node_memory_SwapFree_bytes)/node_memory_SwapTotal_bytes * 100 and node_memory_SwapTotal_bytes > 0 | 交换空间使用率 — 交换空间使用率。计算原子取自 /proc/meminfo。 | % |
node_memory_SwapTotal_bytes | 交换空间总量 — 交换空间总量。取自 /proc/meminfo。 | bytes |
node_memory_SwapFree_bytes | 交换空间空闲量 — 交换空间空闲量。取自 /proc/meminfo。 | bytes |
node_memory_Buffers_bytes | 内存 Buffered 量 — 用作缓冲区的内存量。取自 /proc/meminfo。 | bytes |
node_memory_Cached_bytes | 内存 Cached 量 — 用作文件缓存的内存量。取自 /proc/meminfo。 | bytes |
(1 - (node_memory_MemAvailable_bytes{} / node_memory_MemTotal_bytes{})) * 100 | 内存使用率(基于MemAvailable) — 内存使用率。基于 MemAvailable 计算更准确,但是老版本的 Linux 不支持。 | % |
node_memory_MemAvailable_bytes | 内存可用量 — 可以立即分配给进程的可用内存量。取自 /proc/meminfo。 | bytes |
node_memory_MemTotal_bytes | 内存总量 — 内存总量。取自 /proc/meminfo。 | bytes |
node_memory_MemFree_bytes | 内存空闲量 — 未使用的内存量。取自 /proc/meminfo。 | bytes |
node_filefd_allocated / node_filefd_maximum * 100 | 文件句柄 - 已分配占比 | % |
node_filefd_allocated | 文件句柄 - 已分配量 | 个 |
node_filefd_maximum | 文件句柄 - 总可分配量 | 个 |
irate(node_disk_io_time_seconds_total[2m]) * 100 | 硬盘 IO - 时间维度 Utilization — 在时间维度统计硬盘 IO 时间占比,比如该值是 50%,表示有 50% 的时间是在处理 IO,该值 100%,表示一直在处理 IO,但是注意,现代磁盘设备具备并行处理多个 I/O 请求的能力,所以即便该值是 100%,可能硬盘还是可以接收新的处理请求。 比如某人有两只手,最近 1 分钟一直在用单手劳动,从时间维度来看,利用率是 100%,但即便是 100%,再给他更多的活,他也能干,因为他还有一只手可用。 | % |
irate(node_disk_written_bytes_total[2m]) | 硬盘 IO - 每秒写入字节数量 | bytes/s |
irate(node_disk_writes_completed_total{}[2m]) | 硬盘 IO - 每秒写次数 — 每秒写次数 | |
irate(node_disk_read_bytes_total[2m]) | 硬盘 IO - 每秒读取字节数量 | bytes/s |
irate(node_disk_reads_completed_total{}[2m]) | 硬盘 IO - 每秒读次数 — 每秒读次数 | |
100 - ((node_filesystem_avail_bytes{} * 100) / node_filesystem_size_bytes{}) | 硬盘使用率 — 硬盘空间使用率。 | % |
node_filesystem_free_bytes | 硬盘剩余量 — 使用 SI 标准渲染数据,和 df 命令保持一致。 | bytes |
node_filesystem_avail_bytes | 硬盘可用量 — 使用 SI 标准渲染数据,和 df 命令保持一致。 | bytes |
node_filesystem_size_bytes | 硬盘总量 — 使用 SI 标准渲染数据,和 df 命令保持一致。 | bytes |
count(node_cpu_seconds_total{mode="idle"}) without (cpu, mode) | 系统 CPU 核数 — CPU 逻辑核的数量。 | |
node_load1 | 系统平均负载 - 最近 1 分钟 — 取自 /proc/loadavg。 | |
node_load15 | 系统平均负载 - 最近 15 分钟 — 取自 /proc/loadavg。 | |
node_load5 | 系统平均负载 - 最近 5 分钟 — 取自 /proc/loadavg。 | |
node_load1 / count(node_cpu_seconds_total{mode="idle"}) without (cpu, mode) | 系统平均负载(单核) - 最近 1 分钟 | |
node_load15 / count(node_cpu_seconds_total{mode="idle"}) without (cpu, mode) | 系统平均负载(单核) - 最近 15 分钟 | |
node_load5 / count(node_cpu_seconds_total{mode="idle"}) without (cpu, mode) | 系统平均负载(单核) - 最近 5 分钟 | |
irate(node_network_receive_drop_total[2m]) | 网卡入方向(接收)每秒丢弃的数据包个数 — 原始指标 node_network_receive_drop_total 表示操作系统启动之后各个网卡入方向(接收)丢弃的数据包总数。 | |
irate(node_network_receive_packets_total[2m]) | 网卡入方向(接收)每秒数据包数 — 原始指标 node_network_receive_packets_total 表示操作系统启动之后各个网卡入方向(接收)数据包总数。 | |
irate(node_network_receive_errs_total[2m]) | 网卡入方向(接收)每秒错包数 — 原始指标 node_network_receive_errs_total 表示操作系统启动之后各个网卡入方向(接收)错包总数。 | |
irate(node_network_transmit_drop_total[2m]) | 网卡出方向(发送)每秒丢弃的数据包个数 — 原始指标 node_network_transmit_drop_total 表示操作系统启动之后各个网卡出方向(发送)丢弃的数据包总数。 | |
irate(node_network_transmit_packets_total[2m]) | 网卡出方向(发送)每秒数据包数 — 原始指标 node_network_transmit_packets_total 表示操作系统启动之后各个网卡出方向(发送)数据包总数。 | |
irate(node_network_transmit_errs_total[2m]) | 网卡出方向(发送)每秒错包数 — 原始指标 node_network_transmit_errs_total 表示操作系统启动之后各个网卡出方向(发送)错包总数。 | |
irate(node_network_transmit_bytes_total[2m]) * 8 | 网卡每秒发送的 bit 量 — 原始指标 node_network_transmit_bytes_total 表示操作系统启动之后发送的 byte 总量,因为网卡流量习惯使用 bit 作为单位,所以在表达式中做了换算。 | bit/s |
irate(node_network_receive_bytes_total[2m]) * 8 | 网卡每秒接收的 bit 量 — 原始指标 node_network_receive_bytes_total 表示操作系统启动之后接收的 byte 总量,因为网卡流量习惯使用 bit 作为单位,所以在表达式中做了换算。 | bit/s |
相关链接
- [Linux 模板源文件](https://github.com/ccfos/nightingale/tree/main/integrations/Linux):仪表盘、规则和采集配置的 JSON 原文,欢迎提 PR。
- Categraf
arp_packet插件文档:完整配置项和指标列表。 - Categraf
kernel_vmstat插件文档:完整配置项和指标列表。 - Categraf
netstat插件文档:完整配置项和指标列表。 - Categraf
node_exporter插件文档:完整配置项和指标列表。 - Categraf
ntp插件文档:完整配置项和指标列表。 - Categraf
processes插件文档:完整配置项和指标列表。 - Categraf
supervisor插件文档:完整配置项和指标列表。 - 实践:监控 Linux 主机
- 导入仪表盘和告警规则
- 核对指标是否入库
- 全部集成目录