Communitygithub.com

网络接口健康检查

诊断路由器、交换机及 Linux 主机上的接口错误、丢包、CRC、双工不匹配、抖动、速率协商问题及计数器趋势。当接口显示错误、丢包、CRC、抖动或双工/速率不匹配时使用。

网络接口健康检查 是什么?

此技能专门用于诊断网络物理层问题,涵盖路由器、交换机和 Linux 主机。它帮助运维人员快速定位由物理链路、线缆、光模块、双工设置或拥塞引发的接口错误、丢包、CRC 校验错误、抖动及速率协商异常。该技能支持通过命令行或 API 捕获接口计数器基线,并在指定间隔后对比增量,从而判断问题趋势。它提供详细的计数器参考表(如 CRC、runts、giants、输入/输出丢包等)和分步骤的诊断流程,包括 CRC/输入错误、丢包、双工/速率问题。此外,还包含一个安全的 Python 解析器示例,用于从 `show interfaces` 输出中提取每个接口的数据块,避免因窗口切割导致的计数遗漏或错位。该技能适用于 Cursor、Codex 等智能体平台,可集成到自动化排查工具链中。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/network-interface-health

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

网络接口健康检查 是做什么的?

当网络症状可能由物理链路、交换机端口、线缆、光模块、双工设置或接口拥塞引起时,使用此技能。

使用时机

  • 主机或 VLAN 出现丢包、延迟尖峰或间歇性可达性问题。
  • 交换机或路由器接口显示 CRC、runts、giants、丢包、重置或 flap。
  • 在更换硬件前需要对比链路两端计数器。
  • 变更窗口需要接口计数器变更前后的证据。
  • 监控报告 ifInErrors、ifOutErrors 或 ifOutDiscards 持续上升。

工作原理

接口计数器是证据,但趋势比绝对数值更重要。先捕获基线,等待一个测量间隔,再次捕获,然后比较增量。

show interfaces <interface>
show interfaces <interface> status
show logging | include <interface>|changed state|line protocol

在 Linux 主机上:

ip -s link show <interface>
ethtool <interface>
ethtool -S <interface>

计数器参考

计数器含义常见原因
CRC接收帧校验和失败线缆损坏、光纤污染、光模块故障、双工不匹配
input errors汇总的接收侧错误在得出结论前检查子计数器
runts尺寸小于最小以太网帧的帧双工不匹配、冲突域、NIC 故障
giants尺寸超过预期 MTU 的帧MTU 不匹配或巨型帧边界问题
input drops设备无法接收入站数据包突发流量、超额认购、CPU 路径、队列压力
output drops出口队列丢弃的数据包拥塞、QoS 策略、上行链路容量不足
resets接口硬件复位接口 flap、keepalive、驱动程序、光模块、电源
collisions以太网冲突计数器半双工或协商不匹配

诊断流程

CRC 或输入错误

  1. 确认计数器在持续增长,而不仅仅是历史数据。
  2. 检查链路两端。接收侧错误通常指向到达该侧的信号问题,而不一定是报告错误的端口本身。
  3. 更换跳线或清洁/更换光纤和光模块。
  4. 确认两端的速率/双工设置匹配。
  5. 检查日志中相同时间戳附近的 flap 事件。

丢包

  1. 区分输入丢包和输出丢包。
  2. 将接口速率与容量进行比较。
  3. 检查 QoS 策略、队列计数器以及该链路是否是一个超额认购的上行链路。
  4. 队列调优是次要的。首先证明链路是否拥塞。

双工和速率

在现代以太网链路上,如果两端都支持,优先使用自动协商。如果一端必须固定配置,则两端都要显式配置并记录原因。绝不要在一端混合固定速率/双工而在另一端使用自动协商。

show interfaces <interface> | include duplex|speed

安全解析示例

将每个接口块从头一个标识符到下一个标识符切片。不要使用任意字符窗口;大的接口块可能导致计数器被遗漏或错误分配给其他端口。

import re
from typing import Any

HEADER_RE = re.compile(
    r"^(?P<name>\S+) is (?P<status>(?:administratively )?down|up), "
    r"line protocol is (?P<protocol>up|down)",
    re.I | re.M,
)
ERROR_RE = re.compile(r"(?P<input>\d+) input errors, (?P<crc>\d+) CRC", re.I)
DROP_RE = re.compile(r"(?P<output>\d+) output errors", re.I)
DUPLEX_RE = re.compile(r"(?P<duplex>Full|Half|Auto)-duplex,\s+(?P<speed>[^,]+)", re.I)

def parse_show_interfaces(raw: str) -> list[dict[str, Any]]:
    headers = list(HEADER_RE.finditer(raw))
    interfaces = []
    for index, header in enumerate(headers):
        end = headers[index + 1].start() if index + 1 < len(headers) else len(raw)
        block = raw[header.start():end]
        errors = ERROR_RE.search(block)
        drops = DROP_RE.search(block)
        duplex = DUPLEX_RE.search(block)
        interfaces.append({
            "name": header.group("name"),
            "status": header.group("status"),
            "protocol": header.group("protocol"),
            "duplex": duplex.group("duplex") if duplex else "unknown",
            "speed": duplex.group("speed").strip() if duplex else "unknown",
            "input_errors": int(errors.group("input")) if errors else 0,
            "crc_errors": int(errors.group("crc")) if errors else 0,
            "output_errors": int(drops.group("output")) if drops else 0,
        })
    return interfaces

示例

一个交换机端口上的 CRC

  1. 捕获本地端口的计数器。
  2. 捕获连接的对端端口的计数器。
  3. 在更改路由或防火墙规则之前更换线缆或光模块。
  4. 仅在记录基线后清除计数器。
  5. 在固定时间间隔后重新检查。

互联网慢但局域网正常

  1. 检查 WAN 接口的丢包/错误。
  2. 检查 LAN 上行链路的利用率和输出丢包。
  3. 如果 WAN 链路干净但吞吐量仍然低,检查网关 CPU。
  4. 在责怪上游服务之前,先比较有线和无线测试结果。

反模式

  • 在保存基线前清除计数器。
  • 只查看链路的一端。
  • 没有时间窗口就假设所有历史 CRC 都是活跃问题。
  • 在一端混合自动协商而在另一端使用固定速率/双工。
  • 在检查拥塞之前就将输出丢包视为线缆问题。

参见

  • 智能体: network-troubleshooter
  • 技能: network-config-validation
  • 技能: homelab-network-setup

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

相关技能