10 Zabbix agent 在 Microsoft Windows 上

配置 agent

两代Zabbix agents run均可作为Windows服务运行。适用于Zabbix agent 2,将以下说明中的agentd替换为agent2

你可以run单个Zabbix agent实例或多个实例 在Microsoft Windows 主机上的agent。单个实例可以使用 默认配置 file C:\zabbix_agentd.conf 或配置 file 在命令行中指定。若存在多个实例,每个 agent实例必须拥有自己的配置file(其中之一为 实例可以使用默认配置file。

Zabbix源码归档中提供了一个示例配置file conf/zabbix_agentd.win.conf.

参见configuration file 有关配置Zabbix Windows agent的详细选项

主机名参数

对 一个主机 执行 主动检查 Zabbix agent 需要定义主机名。此外,主机名 在agent端设置的值必须与Host name中为主机配置的值完全匹配 前端

主机名值在agent端可以通过以下任一方式定义 HostnameHostnameItem 参数在 agent configuration file 中 - 或默认值 如果未指定任何这些参数,则使用默认值。

HostnameItem 参数的默认值为返回的值 通过"system.hostname"agent键值获取。对于Windows系统,该键返回gethostname()函数的结果,该函数通过queries命名空间提供程序来确定本地主机名。如果没有命名空间提供程序响应,则返回NetBIOS名称。

Hostname的默认值为返回的 HostnameItem 参数。因此,实际上,如果这两个参数都 未指定时,实际主机名将为主机 NetBIOS名称;Zabbix agent 将使用 NetBIOS 主机名 来检索活动检查列表 从Zabbix server并发送结果至该处

"system.hostname"键支持两个可选参数 - type转换

Type 参数决定了 监控项 应返回的名称类型。 支持的值:

  • netbios (默认) - 返回受限制的NetBIOS 主机名 至15个字符且仅使用大写字母;

  • 主机 - 区分大小写,返回完整的真实Windows 主机名(不包含域);

  • shorthost (自Zabbix 5.4.7起支持) - 返回部分

    hostname before the first dot. It will return a full string if the name does not contain a dot.

Transform 参数自 Zabbix 5.4.7 版本起支持,可用于 指定主机名的额外转换规则。支持 值:

  • (默认) - 使用原始字母大小写;
  • lower - 将文本转换为小写。

因此,为了简化zabbix_agentd.conf file的配置并使其 可采用两种不同的方法来实现统一。

  1. 保留 HostnameHostnameItem 参数未定义 Zabbix agent 将使用 NetBIOS 主机名 作为主机名

  2. 保留Hostname参数未定义状态并定义HostnameItem

    like this:
    HostnameItem=system.hostname[host] - for Zabbix agent to use the full, real (case sensitive) Windows host name as the hostname
    HostnameItem=system.hostname[shorthost,lower] - for Zabbix agent to use only part of the hostname before the first dot, converted into lowercase.

主机名 也被用作Windows服务名称的一部分 安装、启动、停止和卸载Windows服务。 例如,如果 Zabbix agent 配置 file 指定 Hostname=Windows_db_server, 然后 agent 将被安装为 Windows服务"Zabbix Agent [Windows_db_server]"。因此,要 为每个Zabbix agent实例使用不同的Windows服务名称 实例必须使用不同的主机名。

将 agent 安装为 Windows 服务

要安装具有默认配置file c:\zabbix_agentd.conf的Zabbix agent单实例:

zabbix_agentd.exe --install

在64位系统上,所有与运行64位进程相关的检查都需要64位Zabbix agent version才能正常工作。

如果希望使用c:\zabbix_agentd.conf以外的配置file,应使用以下命令进行服务安装:

zabbix_agentd.exe --config <your_configuration_file> --install

必须指定配置file的完整路径。

可以像这样安装多个Zabbix agent实例作为服务:

  zabbix_agentd.exe --config <configuration_file_for_instance_1> --install --multiple-agents
         zabbix_agentd.exe --config <configuration_file_for_instance_2> --install --multiple-agents
         ...
         zabbix_agentd.exe --config <configuration_file_for_instance_N> --install --multiple-agents

安装的服务现在应该可以在控制面板中看到。

Starting agent

要启动agent服务,您可以使用控制面板或从命令行执行。

使用默认配置file启动单个Zabbix agent实例:

 zabbix_agentd.exe --start

使用其他配置file启动单个Zabbix agent实例:

 zabbix_agentd.exe --config <your_configuration_file> --start

启动多个Zabbix agent实例中的一个:

zabbix_agentd.exe --config <此实例的配置文件> --start --multiple-agents

停止 agent

要停止agent服务,可通过控制面板或命令行操作

停止使用默认配置file启动的单个Zabbix agent实例:

 zabbix_agentd.exe --stop

停止使用其他配置file启动的单个Zabbix agent实例:

 zabbix_agentd.exe --config <your_configuration_file> --stop

停止多个Zabbix agent实例中的某一个:

zabbix_agentd.exe --config <该实例的配置文件> --stop --multiple-agents

卸载 agent Windows 服务

使用默认配置file卸载单个Zabbix agent实例:

   zabbix_agentd.exe --uninstall

使用非默认配置file卸载单个Zabbix agent实例:

   zabbix_agentd.exe --config <your_configuration_file> --uninstall

从Windows服务中卸载多个Zabbix agent实例:

zabbix_agentd.exe --config <configuration_file_for_instance_1> --uninstall --multiple-agents zabbix_agentd.exe --config <configuration_file_for_instance_2> --uninstall --multiple-agents ... zabbix_agentd.exe --config <configuration_file_for_instance_N> --uninstall --multiple-agents

限制条件

Zabbix agent for Windows不支持 在非标准Windows配置下CPU非均匀分布 跨NUMA节点的场景。若逻辑CPU呈现 非均匀分布,则部分CPU的性能指标 可能无法获取。例如,当系统存在72个逻辑CPU 且划分为2个NUMA节点时,每个节点 必须均包含36个CPU。