这是原厂英文文档的翻译页面. 欢迎帮助我们 完善文档.

2 Windows Zabbix agent

概述

Windows Zabbix agent 监控项 分为两个列表呈现:

请注意 Windows 版 Zabbix agent 支持的所有 监控项 键值同样适用于新一代 Zabbix agent 2. 参阅仅适用于 agent 2 的 additional item keys.

另请参阅: Minimum permissions for Windows items

共享监控项

下表列出了Windows平台支持并与UNIX Zabbix agent共享的Zabbix agent 监控项:

  • 监控项键是UNIX Zabbix agent 监控项完整详情的链接
  • 包含与Windows相关的监控项注释
监控项键 描述 监控项组
log 监控日志file. 此监控项不支持Windows事件日志.
persistent_dir参数在Windows上不受支持.
Log monitoring
log.count 监控日志file中匹配行的计数. 此监控项不支持Windows事件日志.
persistent_dir参数在Windows上不受支持.
logrt 监控轮转的日志file. 此监控项不支持Windows事件日志.
persistent_dir参数在Windows上不受支持.
logrt.count 监控轮转日志file中匹配行的计数. 此监控项不支持Windows事件日志.
persistent_dir参数在Windows上不受支持.
modbus.get 读取Modbus数据. Modbus
net.dns 检查DNS服务是否运行.
除非使用Zabbix agent 2, 否则ip, timeoutcount参数在Windows上会被忽略.
Network
net.dns.perf 检查DNS服务性能.
除非使用Zabbix agent 2, 否则ip, timeoutcount参数在Windows上会被忽略.
net.dns.record 执行DNS query.
除非使用Zabbix agent 2, 否则ip, timeoutcount参数在Windows上会被忽略.
net.if.discovery 网络接口列表.
某些Windows版本(如Server 2008)可能需要安装最新更新以支持接口名称中的非ASCII字符.
net.if.in 网络接口的入站流量统计.
在Windows上, 如果可用, 监控项会从64位计数器获取值. 64位接口统计计数器在Windows Vista和Windows Server 2008中引入. 如果64位计数器不可用, agent会使用32位计数器.
支持Windows上的多字节接口名称.
可通过net.if.discovery或net.if.list 监控项获取Windows上的网络接口描述.
net.if.out 网络接口的出站流量统计.
在Windows上, 如果可用, 监控项会从64位计数器获取值. 64位接口统计计数器在Windows Vista和Windows Server 2008中引入. 如果64位计数器不可用, agent会使用32位计数器.
支持Windows上的多字节接口名称.
可通过net.if.discovery或net.if.list 监控项获取Windows上的网络接口描述.
net.if.total 网络接口的入站和出站流量统计总和.
在Windows上, 如果可用, 监控项会从64位计数器获取值. 64位接口统计计数器在Windows Vista和Windows Server 2008中引入. 如果64位计数器不可用, agent会使用32位计数器.
可通过net.if.discovery或net.if.list 监控项获取Windows上的网络接口描述.
net.tcp.listen 检查TCP端口是否处于LISTEN状态.
net.tcp.port 检查是否可以在指定端口建立TCP连接.
net.tcp.service 检查服务是否正在运行并接受TCP连接.
在Windows上检查LDAP和HTTPS仅支持Zabbix agent 2.
net.tcp.service.perf 检查TCP服务性能.
在Windows上检查LDAP和HTTPS仅支持Zabbix agent 2.
net.tcp.socket.count 返回匹配参数的TCP套接字数量.
此监控项在Linux上由Zabbix agent支持, 但在Windows上仅由64位Windows上的Zabbix agent 2支持.
net.udp.service 检查服务是否正在运行并响应UDP请求.
net.udp.service.perf 检查UDP服务性能.
net.udp.socket.count 返回匹配参数的UDP套接字数量.
此监控项在Linux上由Zabbix agent支持, 但在Windows上仅由64位Windows上的Zabbix agent 2支持.
proc.get 操作系统进程列表及其参数.
cmdline参数在Windows上不受支持.
Processes
proc.num 进程数量.
在Windows上, 仅支持nameuser参数.
system.cpu.discovery 检测到的CPU/CPU核心列表. System
system.cpu.load CPU负载.
当在Zabbix agent上启动收集器进程时, 会初始化以下性能计数器并随后用于此监控项: \System\Processor Queue Length
system.cpu.num CPU数量.
system.cpu.util CPU利用率百分比.
使用Processor Time性能计数器获取值. 注意从Windows 8开始, 其任务管理器基于Processor Utility性能计数器显示CPU利用率, 而早期版本使用Processor Time计数器(参见more details).
在Windows上仅支持type参数的system值.
system.hostname 系统主机名.
在Windows上通过GetComputerName()(用于netbios), GetComputerNameExA()(用于fqdn)或gethostname()(用于主机)函数获取值.
另见配置-agent.
system.localtime 系统时间.
system.run 在主机上运行指定命令.
system.sw.arch 软件架构信息.
system.swap.size 交换空间大小(字节或占总量的百分比).
pused类型参数在Linux上由Zabbix agent支持, 但在Windows上仅由Zabbix agent 2支持.
注意此键可能在虚拟化(VMware ESXi, VirtualBox)Windows平台上报告不正确的交换空间大小/百分比. 这种情况下可使用perf_counter[\700(_Total)\702]键获取正确的交换空间百分比.
system.uname 系统标识.
在Windows上此监控项的值从Win32_OperatingSystem和Win32_Processor WMI类获取. 操作系统名称(包括版本)可能被翻译为用户显示语言. 在某些Windows版本上包含商标符号和额外空格.
system.uptime 系统运行时间(秒).
vfs.dir.count 目录条目计数.
在Windows上, 目录符号链接会被跳过且硬链接只计数一次.
Virtual file systems
vfs.dir.get 目录条目列表.
在Windows上, 目录符号链接会被跳过且硬链接只计数一次.
vfs.dir.size 目录大小.
在Windows上任何符号链接都会被跳过且硬链接只计算一次.
vfs.file.cksum file校验和, 通过UNIX cksum算法计算.
vfs.file.contents 检索file内容.
vfs.file.exists 检查file是否存在.
在Windows上使用命令行工具调用zabbix_get.exe或agent2时, 双引号必须用反斜杠'\'转义且整个监控项键要用双引号括起来.
注意如果在不存在的目录中搜索目录, 此监控项可能在Windows上变为不受支持, 例如vfs.file.exists[C:\no\dir,dir](其中'no'不存在).
vfs.file.get 返回file信息.
Windows上支持的file类型: 常规file, 目录, 符号链接
vfs.file.md5sum file的MD5校验和.
vfs.file.owner 获取file的所有者.
vfs.file.regexp 在file中检索string.
vfs.file.regmatch 在file中查找string.
vfs.file.size file大小.
vfs.file.time file时间信息.
在Windows XP上vfs.file.time[file,change]可能等于vfs.file.time[file,access].
vfs.fs.discovery 已挂载文件系统列表及其类型和挂载选项.
Windows上支持{#FSLABEL}宏.
vfs.fs.get 已挂载文件系统列表及其类型, 可用磁盘空间, inode统计和挂载选项.
Windows上支持{#FSLABEL}宏.
vfs.fs.size 磁盘空间(字节或占总量的百分比).
vm.memory.size memory大小(字节或占总量的百分比). Virtual memory
web.page.get 获取网页内容. Web monitoring
web.page.perf 完整网页加载时间.
web.page.regexp 在网页上查找string.
agent.hostmetadata agent 主机元数据. Zabbix
agent.hostname agent 主机名.
agent.ping agent可用性检查.
agent.variant Zabbix agent变体(Zabbix agent或Zabbix agent 2).
agent.version Zabbix agent的version.
zabbix.stats 远程返回一组Zabbix server或proxy内部指标.
zabbix.stats 远程返回Zabbix server或proxy上延迟的监控监控项队列数量.

Windows特定的监控项

下表提供了仅由 Windows Zabbix agent 支持的 监控项 键的详细信息。

Windows 特有的 监控项 有时是类似功能的近似对应项 agent 监控项,例如 proc_info,在 Windows 上受支持,大致对应 到 proc.mem 监控项,Windows 上不支持。

“监控项”键是完整“监控项”键详细信息的链接。

监控项 监控项 键值 描述 监控项 监控项 所属主机组
eventlog Windows事件日志监控。 日志监控
eventlog.count Windows事件日志中的行数统计。
net.if.list 网络接口列表(包含接口类型、状态、IPv4地址、描述)。 网络
perf_counter 任何 Windows 性能计数器的值。 性能计数器
perf_counter_en 任何英文的Windows性能计数器的值。
perf_instance.discovery Windows性能计数器的object实例列表。
perf_instance_en.discovery 使用英文的 object 名称发现的 Windows 性能计数器的 object 实例列表。
proc_info 关于特定进程(们)的各种信息。 进程
registry.data 返回 Windows 注册表项中指定值名称的数据。 注册表
registry.get 位于指定键下的 Windows 注册表值或键的列表。
service.discovery Windows服务列表。 服务
service.info 有关服务的信息。
services 服务列表。
vm.vmemory.size 虚拟 memory 大小(以字节或占总量的百分比表示)。 虚拟内存
wmi.get 执行一个 WMI query 并返回第一个选定的 object。 WMI
wmi.getall 执行 WMI query 并返回整个响应。

监控项 键详情

不带尖括号的参数是必选的。 标记有尖括号 < > 的参数是可选的。

eventlog[name,<regexp>,<severity>,<source>,<eventid>,<maxlines>,<mode>]


事件日志监控。
返回值: Log.

参数:

  • name - 事件日志通道名称(事件查看器GUI中的Log Name);
  • regexp - 描述所需模式的正则概述(区分大小写);
  • severity - 描述严重级别的正则表达式(不区分大小写)。 该参数接受基于以下值的正则表达式:"Information"、"Warning"、"Error"、"Critical"、"Verbose"(运行于Windows Vista或更新系统)。
  • source - 描述源标识符的正则表达式(不区分大小写);
  • eventid - 描述事件标识符的正则表达式(区分大小写);
  • maxlines - agent每秒发送至Zabbix server或proxy的最大新行数。 此参数将覆盖zabbix_agentd.conf中的'MaxLinesPerSecond'值。
  • mode - 可选值: all(默认)或skip - 跳过旧数据处理(仅影响新创建的监控项)。

注释:

  • 监控项必须配置为主动检查
  • agent无法从"Forwarded events"日志发送事件;
  • 支持Windows Eventing 6.0;
  • 为此监控项选择非日志配置将导致丢失本地时间戳以及日志严重级别和源信息;
  • 另见log monitoring的附加信息。

示例:

eventlog[Application]
       eventlog[Microsoft-Windows-Application-Experience/Program-Compatibility-Assistant]
       eventlog[Security,,"Failure Audit",,^(529|680)$]
       eventlog[System,,"Warning|Error"]
       eventlog[System,,,,^1$]
       eventlog[Windows PowerShell,,,,,,skip]
       eventlog[System,,,,@TWOSHORT] #here a custom regular expression named `TWOSHORT` is referenced (defined as a *Result is TRUE* type, the expression itself being `^1$|^70$`).
eventlog.count[name,<regexp>,<severity>,<source>,<eventid>,<maxproclines>,<mode>]


Windows事件日志中的行数统计.
返回值: integer.

参数:

  • name - 事件日志通道名称(事件查看器GUI中的Log Name);
  • regexp - 描述所需模式的正则概述(区分大小写);
  • severity - 描述严重级别的正则表达式(不区分大小写). 该参数接受基于以下值的正则表达式: "Information", "Warning", "Error", "Critical", "Verbose"(运行在Windows Vista或更新版本).
  • source - 描述源标识符的正则表达式(不区分大小写);
  • eventid - 描述事件标识符的正则表达式(区分大小写);
  • maxproclines - agent每秒分析的最大新行数(不得超过10000). 默认值为zabbix_agentd.conf中'MaxLinesPerSecond'的10倍.
  • mode - 可能值: all(默认)或skip - 跳过旧数据处理(仅影响新创建的监控项).

注释:

  • 监控项必须配置为主动检查;
  • agent无法从"Forwarded events"日志发送事件;
  • 支持Windows Eventing 6.0;
  • 为此监控项选择非日志配置将导致丢失本地时间戳以及日志严重性和源信息;
  • 另请参阅log monitoring上的附加信息.

示例:

eventlog.count[System,,"Warning|Error"]
       eventlog.count[Windows PowerShell,,,,,,skip]
网络接口列表


网络接口列表(包括接口类型、状态、IPv4地址、描述)。
返回值:文本

备注:

  • 支持多字节接口名称;
  • 不列出已禁用的接口;
  • 启用/禁用某些组件可能会更改其在Windows接口名称中的顺序;
  • 某些Windows版本(例如,Server 2008)可能需要安装最新的更新以支持接口名称中的非ASCII字符。
perf_counter[counter,<interval>]


任何Windows性能计数器的值。
返回值:integerfloatstring文本(根据请求类型而定)。

参数:

  • counter - 计数器路径;
  • interval - 用于计算平均值的最近N秒时长。 interval 必须介于1至900秒之间(含边界值),默认值为1。

注释:

  • interval 适用于需要多个采样值的计数器(如CPU利用率),该检查每次会返回最近"interval"秒内的平均值;
  • 可通过性能监视器获取可用计数器列表。
  • 另请参阅:Windows performance counters
perf_counter_en[counter,<interval>]


任意Windows性能计数器的英文名称值.
返回值: integer, float, string文本 (取决于请求类型).

参数:

  • counter - 计数器的英文路径;
  • interval - 用于计算平均值的最近N秒时长. interval 必须介于1到900秒之间(含边界值),默认值为1.

注释:

  • interval 适用于需要多个采样值的计数器(如CPU利用率),因此每次检查都会返回最近"interval"秒内的平均值;
  • 该监控项仅支持 Windows Server 2008/Vista 及以上版本;
  • 可通过查看以下注册表键值获取英文字符串列表: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009.
perf_instance.discovery[object]


Windows性能计数器的object实例列表. 用于low-level discovery.
返回值: JSON object.

参数:

  • object - object名称(本地化).
perf_instance_en.discovery[object]


Windows性能计数器的object实例列表,使用英文object名称发现。 用于low-level discovery
返回值:JSON object

参数:

  • object - object名称(英文)。
proc_info[process,<attribute>,<type>]


关于特定进程的各类信息。
返回值: float.

参数:

  • process - 进程名称;
  • attribute - 请求的进程属性;
  • type - 表示类型(当存在多个同名进程时有效)

注释:

  • 支持以下attributes:
    vmsize (默认) - 进程虚拟memory大小(单位KB)
    wkset - 进程工作集大小(进程使用的物理memory量,单位KB)
    pf - 页面错误次数
    ktime - 进程内核时间(单位毫秒)
    utime - 进程用户时间(单位毫秒)
    io_read_b - 进程在I/O操作中读取的字节数
    io_read_op - 进程执行的读取操作次数
    io_write_b - 进程在I/O操作中写入的字节数
    io_write_op - 进程执行的写入操作次数
    io_other_b - 进程在非读写操作中传输的字节数
    io_other_op - 进程执行的除读写外的I/O操作次数
    gdiobj - 进程使用的GDI objects数量
    userobj - 进程使用的USER objects数量;
  • 有效的types包括:
    avg (默认) - 所有名为<process>进程的平均值
    min - 所有名为<process>进程的最小值
    max - 所有名为<process>进程的最大值
    sum - 所有名为<process>进程的数值总和;
  • 在64位系统上,此监控项需要64位Zabbix agent才能正常工作。

示例:

proc_info[iexplore.exe,wkset,sum] #retrieve the amount of physical memory taken by all Internet Explorer processes
       proc_info[iexplore.exe,pf,avg] #retrieve the average number of page faults for Internet Explorer processes
registry.data[key,<value name>]


返回Windows注册表键中指定值名称的数据。
返回值:integerstring文本(取决于值类型)

参数:

  • key - 包含根键的注册表键;允许使用根键缩写(如HKLM);
  • value name - 键中的注册表值名称(默认为空 string "")。 如果未提供值名称,则返回默认值。

注释:

  • 支持的根键缩写:
    HKCR - HKEY_CLASSES_ROOT
    HKCC - HKEY_CURRENT_CONFIG
    HKCU - HKEY_CURRENT_USER
    HKCULS - HKEY_CURRENT_USER_LOCAL_SETTINGS
    HKLM - HKEY_LOCAL_MACHINE
    HKPD - HKEY_PERFORMANCE_DATA
    HKPN - HKEY_PERFORMANCE_NLSTEXT
    HKPT - HKEY_PERFORMANCE_TEXT
    HKU - HKEY_USERS
  • 包含空格的键必须用双引号括起来。

示例:

registry.data["HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting"] #return the data of the default value of this key
       registry.data["HKLM\SOFTWARE\Microsoft\Windows\Windows Error Reporting","EnableZip"] #return the data of the value named "Enable Zip" in this key
registry.get[key,<mode>,<name regexp>]


位于给定注册表键下的Windows注册表值或键的列表。
返回值:JSON object.

参数:

  • key - 包含根键的注册表键;允许使用根键缩写(如HKLM)(完整缩写列表请参阅registry.data[]的注释);
  • mode - 可选值:
    values(默认)或 keys
  • name regexp - 仅发现名称匹配正则表达式的值(默认发现所有值)。 仅当modevalues时允许使用。

包含空格的键必须使用双引号包裹。

示例:

registry.get[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall,values,"^DisplayName|DisplayVersion$"] #return the data of the values named "DisplayName" or "DisplayValue" in this key.
       The JSON will include details of the key, last subkey, value name, value type and value data.
       registry.get[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall,values] #return the data of the all values in this key.
       The JSON will include details of the key, last subkey, value name, value type and value data.
       registry.get[HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall,keys] #return all subkeys of this key.
       The JSON will include details of the key and last subkey.
service.discovery


Windows服务列表 用于low-level discovery
返回值: JSON object

service.info[service,<param>]


关于服务的信息。
返回值: integer - 包含 param 作为 state, startup; string - 包含 param 作为 displayname, path, user; Text - 包含 param 作为 description
特别针对 state: 0 - 运行中, 1 - 已暂停, 2 - 启动挂起, 3 - 暂停挂起, 4 - 继续挂起, 5 - 停止挂起, 6 - 已停止, 7 - 未知, 255 - 无此服务
特别针对 startup: 0 - 自动, 1 - 自动延迟, 2 - 手动, 3 - 禁用, 4 - 未知, 5 - 自动触发启动, 6 - 自动延迟触发启动, 7 - 手动触发启动

参数:

  • service - 实际服务名称或在MMC服务管理单元中显示的显示名称;
  • param - state (默认), displayname, path, user, startup, 或 description.

注释:

  • 监控项 如 service.info[service,state]service.info[service] 将返回相同的信息;
  • 仅当 param 作为 state 时,此 监控项 会为不存在的服务返回值(255).

示例:

service.info[SNMPTRAP] - state of the SNMPTRAP service;
       service.info[SNMP Trap] - state of the same service, but with the display name specified;
       service.info[EventLog,startup] - the startup type of the EventLog service
services[<type>,<state>,<exclude>]


服务列表.
返回值: 0 - 如果为空; Text - 以换行符分隔的服务列表.

参数:

  • type - all (默认), automatic, manual, 或 disabled;
  • state - all (默认), stopped, started, start_pending, stop_pending, running, continue_pending, pause_pending, 或 paused;
  • exclude - 要从结果中排除的服务. 排除的服务应列在双引号中,用逗号分隔,不带空格.

示例:

services[,started] #returns the list of started services;
       services[automatic, stopped] #returns the list of stopped services that should be running;
       services[automatic, stopped, "service1,service2,service3"] #returns the list of stopped services that should be running, excluding services named "service1", "service2" and "service3"
vm.vmemory.size[<type>]


虚拟memory的大小,以字节或占总量的百分比表示。
返回值:integer - 表示字节;float - 表示百分比。

参数:

  • type - 可能的值:available(可用虚拟memory)、pavailable(可用虚拟memory,百分比)、pused(已用虚拟memory,百分比)、total(总虚拟memory,默认值)或used(已用虚拟memory)

注释:

  • 虚拟memory统计的监控基于:

    • Total virtual memory on Windows (total physical + page file size);
    • The maximum amount of memory Zabbix agent can commit;
    • The current committed memory limit for the system or Zabbix agent, whichever is smaller.

示例:

vm.vmemory.size[pavailable] #return the available virtual memory, in percentage
wmi.get[<namespace>,<query>]


执行WMI query并返回第一个选中的object.
返回值: integer, float, stringtext (取决于请求类型).

参数:

  • namespace - WMI命名空间;
  • query - 返回单个object的WMI query.

WMI queries通过WQL执行.

示例:

wmi.get[root\cimv2,select status from Win32_DiskDrive where Name like '%PHYSICALDRIVE0%'] #returns the status of the first physical disk
wmi.getall[<namespace>,<query>]


执行WMI query并返回完整响应. 可用于low-level discovery.
返回值: JSON object

参数:

  • namespace - WMI命名空间;
  • query - WMI query.

注释:

示例:

wmi.getall[root\cimv2,select * from Win32_DiskDrive where Name like '%PHYSICALDRIVE%'] #returns status information of physical disks

监控 Windows 服务

本教程提供逐步指导,用于设置Windows服务的监控。 假设Zabbix server和agent已配置并正常运行。

步骤1

获取服务名称.

您可以通过get进入MMC服务管理单元并查看服务属性来获取服务名称. 在常规选项卡中,您会看到一个名为"服务名称"的字段. 该字段后面的值就是您在设置监控项进行监控时需要使用的名称. 例如,如果您想监控"workstation"服务,那么您的服务名称可能是: lanmanworkstation.

步骤 2

Configure an item 用于监控服务

监控项 service.info[service,<param>] 可获取特定服务的信息 根据所需信息类型 需指定param选项 该选项接受以下值: displayname, state, path, user, startupdescription 若未指定param 则默认值为state (service.info[service])

返回值类型取决于所选的param: statestartup返回integer; displayname, pathuser返回字符型string; description返回文本型

示例:

  • 键值: service.info[lanmanworkstation]
  • 信息类型: 数值型(无符号)

监控项 service.info[lanmanworkstation] 将以数值形式获取服务状态信息 要在前端将数值映射为文本表示(如"0"对应"运行中" "1"对应"已暂停"等) 可在配置监控项的主机上配置配置 具体操作方式: 将关联模板中的Windows services by Zabbix agentWindows services by Zabbix agent active关联至主机 或在主机上基于模板中配置的Windows service state值映射配置新的值映射

注意上述模板均配置了自动发现服务的发现规则 若不需要此功能 可在模板关联至主机后 在主机层级disable the discovery rule该规则

Windows 服务发现

Low-level discovery 提供了一种自动create监控项的方法,可为计算机上的不同实体自动创建触发器与图形。 Zabbix能自动开始监控您机器上的Windows服务,无需知晓服务的确切名称或手动为每个服务create监控项。 通过过滤器可generate仅针对关注的服务生成真实的监控项、触发器及图形。