You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何基于Apache SkyWalking实现Windows系统监控?代码修改及vm.yaml需求

Apache SkyWalking Windows系统监控适配方案

一、代码修改核心要点

  • 系统指标采集模块适配
    • 扩展OSInfo类的系统识别逻辑,新增Windows分支,通过WMI或Windows API(如GetVersionExW)获取系统版本、主机名、CPU架构等基础信息,替代原有的Linux /proc 文件读取逻辑。
    • CPU使用率采集:替换Linux的/proc/stat读取方式,改用Windows性能计数器(Processor\% User Time)或WMI的Win32_PerfFormattedData_PerfOS_Processor类获取实时CPU占用数据。
    • 内存监控:放弃/proc/meminfo读取,通过WMI的Win32_OperatingSystem类或GlobalMemoryStatusExAPI获取总内存、可用内存、已用内存等指标。
    • 磁盘IO监控:替换/proc/diskstats,改用WMI的Win32_PerfFormattedData_PerfDisk_LogicalDisk类读取磁盘读写速率、空间使用率,适配Windows的盘符路径(如C:\)。
  • Agent端适配
    • 针对Windows平台编译Agent的Native组件,调整JNI调用逻辑,适配Windows系统调用接口,确保进程信息采集正常。
    • 进程监控逻辑修改:替换Linux的/proc/[pid]读取方式,通过WMI的Win32_Process类获取进程的CPU占用、内存使用、启动时间、命令行参数等信息。
  • UI展示层调整
    • 在系统监控面板中新增Windows系统的指标渲染逻辑,比如将磁盘挂载点改为盘符展示,确保图表能正确匹配Windows的指标维度。

二、Windows系统适配版vm.yaml配置

agent:
  service_name: Windows_Business_Service
  instance_name: Windows-Server-001
  collector_backend_service: 192.168.1.100:11800 # 替换为你的Collector地址
  authentication: ""
  ignore_suffix: .js,.css,.html,.png,.svg

metrics:
  jvm:
    enabled: true
  system:
    enabled: true
    cpu:
      enabled: true
      metrics:
        - usage
    memory:
      enabled: true
      metrics:
        - total
        - used
        - free
    disk:
      enabled: true
      metrics:
        - read_bytes
        - write_bytes
        - usage
      paths: # 配置需要监控的Windows盘符
        - C:\
        - D:\
    network:
      enabled: true
      metrics:
        - bytes_sent
        - bytes_received

logging:
  level: info
  file: skywalking-agent.log

内容的提问来源于stack exchange,提问作者Dona Dominic

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 21:50:36