2 Windows 下的Zabbix agent

2 Zabbix agent on Microsoft Windows

agent配置

Configuring agent

Zabbix agent 作为Windows服务运行。 Zabbix agent runs as a Windows service.

在一台Windows主机上可以运行一个或多个Zabbix agent实例。 如果安装一个实例可以使用默认的配置文件C:\zabbix_agentd.conf 或者在命令中指定配置文件路径。 如果安装多个实例,每一个agent必须有自己的配置文件 (其中一个实例可以使用默认的配置文件)。

You can run a single instance of Zabbix agent or multiple instances of the agent on a Microsoft Windows host. A single instance can use the default configuration file C:\zabbix_agentd.conf or a configuration file specified in the command line. In case of multiple instances each agent instance must have its own configuration file (one of the instances can use the default configuration file).

在Zabbix源文件目录有一个配置文件样例conf/zabbix_agentd.win.conf

An example configuration file is available in Zabbix source archive as conf/zabbix_agentd.win.conf.

关于Zabbix Windows agent 更多详细信息,参考 配置文件

See the configuration file options for details on configuring Zabbix Windows agent.

主机名参数
Hostname parameter

主机执行 active checks 时,Zabbix agent 需要定义主机名。而且,agent端的主机名必须和前端配置的主机名 “Host name“完全一致 。

To perform active checks on a host Zabbix agent needs to have the hostname defined. Moreover, the hostname value set on the agent side should exactly match the ”Host name” configured for the host in the frontend.

agent端的主机名可以通过配置文件configuration file中的HostnameHostnameItem参数定义 - 如果不指定参数值将使用默认的主机名字。

The hostname value on the agent side can be defined by either the Hostname or HostnameItem parameter in the agent configuration file - or the default values are used if any of these parameters are not specified.

参数HostnameItem 的默认值即agent端key值为 “system.hostname”的监控项返回值,对于Windows平台返回的是NetBIOS的主机名。

The default value for HostnameItem parameter is the value returned by the “system.hostname” agent key and for Windows platform it returns the NetBIOS host name.

参数Hostname默认值为HostnameItem 参数的返回值。所以,实际上,如果这两个参数都是未指定的,实际的主机名将是主机NetBIOS名称; Zabbix agent将使用NetBIOS主机名从Zabbix server获取active checks列表,并将检查结果发送给它。

The default value for Hostname is the value returned by the HostnameItem parameter. So, in effect, if both these parameters are unspecified the actual hostname will be the host NetBIOS name; Zabbix agent will use NetBIOS host name to retrieve the list of active checks from Zabbix server and send results to it.

system.hostnamekey始终返回限制为15个字符的NetBIOS主机名,并且全为大写字符 - 而不管实际主机名中的长度和字符大小写。

The system.hostname key always returns the NetBIOS host name which is limited to 15 symbols and in UPPERCASE only - regardless of the length and lowercase/uppercase characters in the real host name.

从Windows Zabbix agent 1.8.6版本开始, “system.hostname” key支持可选参数 -名称的类型。此参数的默认值为“netbios” (用于向后兼容) 另一个可能的值是 “host”.

Starting from Zabbix agent 1.8.6 version for Windows the “system.hostname” key supports an optional parameter - type of the name. The default value of this parameter is “netbios” (for backward compatibility) and the other possible value is “host”.

system.hostname[host]键总是返回完整的,实际的(区分大小写的)Windows主机名。

The system.hostname[host] key always returns the full, real (case sensitive) Windows host name.

因此,为了简化zabbix_agentd.conf文件的配置并使其统一起来,可以使用两种不同的方法。

  1. 不定义 Hostname或者HostnameItem 参数,Zabbix agent将使用NetBIOS主机名作为主机名;

  2. 不定义 Hostname 参数,定义HostnameItem 如:
    HostnameItem=system.hostname[host]
    Zabbix agent将使用完整的,实际的(区分大小写的)Windows主机名作为主机名。

So, to simplify the configuration of zabbix_agentd.conf file and make it unified, two different approaches could be used.

  1. leave Hostname or HostnameItem parameters undefined and Zabbix agent will use NetBIOS host name as the hostname;

  2. leave Hostname parameter undefined and define HostnameItem like this:
    HostnameItem=system.hostname[host]
    and Zabbix agent will use the full, real (case sensitive) Windows host name as the hostname.

主机名也用作Windows服务名称的一部分,用于安装,启动,停止和卸载Windows服务。 例如,如果Zabbix agent配置文件指定Hostname=Windows_db_server, 那么agent将作为Windows服务“Zabbix Agent [Windows_db_server]“安装。因此,如果要每个Zabbix agent实例拥有不同的Windows服务名称,则每个实例都必须使用不同的主机名。

Host name is also used as part of Windows service name which is used for installing, starting, stopping and uninstalling the Windows service. For example, if Zabbix agent configuration file specifies Hostname=Windows_db_server, then the agent will be installed as a Windows service ”Zabbix Agent [Windows_db_server]”. Therefore, to have a different Windows service name for each Zabbix agent instance, each instance must use a different host name.

将代理安装为Windows服务

Installing agent as Windows service

使用默认配置文件c:\zabbix_agentd.conf安装Zabbix agent的单个实例:

To install a single instance of Zabbix agent with the default configuration file c:\zabbix_agentd.conf:

  1. zabbix_agentd.exe --install

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

On a 64-bit system, a 64-bit Zabbix agent version is required for all checks related to running 64-bit processes to work correctly.

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

If you wish to use a configuration file other than c:\zabbix_agentd.conf, you should use the following command for service installation:

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

应指定配置文件的全路径。 A full path to the configuration file should be specified.

Zabbix agent多实例作为服务安装的命令如下: Multiple instances of Zabbix agent can be installed as services like this:

  1. zabbix_agentd.exe --config <configuration_file_for_instance_1> --install --multiple-agents
  2. zabbix_agentd.exe --config <configuration_file_for_instance_2> --install --multiple-agents
  3. ...
  4. zabbix_agentd.exe --config <configuration_file_for_instance_N> --install --multiple-agents

现在在控制面板中可以看到安装的服务。 The installed service should now be visible in Control Panel.

启动 agent

Starting agent

启动agent服务,可以使用控制面板或通过命令行方式。 To start the agent service, you can use Control Panel or do it from command line.

启动使用默认配置文件的单实例Zabbix agent命令如下: To start a single instance of Zabbix agent with the default configuration file:

  1. zabbix_agentd.exe --start

启动使用自定义配置文件的单实例Zabbix agent命令如下: To start a single instance of Zabbix agent with another configuration file:

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

启动多实例Zabbix agent中的一个实例命令如下: To start one of multiple instances of Zabbix agent:

  1. zabbix_agentd.exe --config <configuration_file_for_this_instance> --start --multiple-agents

停止 agent

Stopping agent

停止agent服务,可以使用控制面板或通过命令行方式。 To stop the agent service, you can use Control Panel or do it from command line.

停止使用默认配置文件的单实例Zabbix agent命令如下: To stop a single instance of Zabbix agent started with the default configuration file:

  1. zabbix_agentd.exe --stop

停止使用自定义配置文件的单实例Zabbix agent命令如下: To stop a single instance of Zabbix agent started with another configuration file:

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

停止多实例Zabbix agent中的一个实例命令如下: To stop one of multiple instances of Zabbix agent:

  1. zabbix_agentd.exe --config <configuration_file_for_this_instance> --stop --multiple-agents

卸载 agent Windows 服务

Uninstalling agent Windows service

卸载使用默认配置文件的单实例Zabbix agent服务命令如下: To uninstall a single instance of Zabbix agent using the default configuration file:

  1. zabbix_agentd.exe --uninstall

卸载使用自定义配置文件的单实例Zabbix agent服务命令如下: To uninstall a single instance of Zabbix agent using a non-default configuration file:

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

卸载多实例Zabbix agent服务命令如下: To uninstall multiple instances of Zabbix agent from Windows services:

  1. zabbix_agentd.exe --config <configuration_file_for_instance_1> --uninstall --multiple-agents
  2. zabbix_agentd.exe --config <configuration_file_for_instance_2> --uninstall --multiple-agents
  3. ...
  4. zabbix_agentd.exe --config <configuration_file_for_instance_N> --uninstall --multiple-agents