在 CentOS 上,“dropped” 通常指网络丢包(packet dropped),也可能是系统丢包/服务丢弃请求。下面按最常见场景给你一套可落地的监控 + 告警方案。
常见 dropped 位置:
ip -s link
ifconfig
关注:
RX droppedTX droppednetstat -s | egrep 'drop|retrans|overflow'
nstat -az | grep -i drop
dmesg | grep conntrack
cat /proc/sys/net/netfilter/nf_conntrack_count
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
tar zxvf node_exporter-*.tar.gz
cd node_exporter-*
./node_exporter &
scrape_configs:
- job_name: node
static_configs:
- targets: ['centos-ip:9100']
groups:
- name: network-drop
rules:
- alert: NetworkPacketDropped
expr: rate(node_network_receive_errs_total[5m]) > 0
for: 5m
labels:
severity: warning
annotations:
summary: "网卡丢包告警"
description: "{{ $labels.instance }} 存在丢包"
监控项:
net.if.in[eth0,errors]net.if.out[eth0,errors]net.tcp.listen.drop触发器:
{host:net.if.in[eth0,errors].last()}>0
#!/bin/bash
DROP=$(ip -s link show eth0 | awk '/RX:/ {getline; print $3}')
if [ "$DROP" -gt 100 ]; then
echo "eth0 dropped: $DROP" | mail -s "CentOS drop alert" admin@xx.com
fi
加 crontab:
* * * * * /root/check_drop.sh
| 原因 | 处理 |
|---|---|
| 网卡 buffer 小 | ethtool -G eth0 rx 4096 |
| conntrack 满 | 调大 nf_conntrack_max |
| 带宽打满 | 限速 / 扩容 |
| 防火墙 DROP | 检查 iptables |
| 半连接攻击 | 开启 SYN Cookie |
你可以告诉我:
我可以直接帮你写 完整告警规则 + 脚本。