[ZBXNEXT-8848] Zabbix Agent support for multiple HostMetadataItem entries + JSON formatting Created: 2023 Nov 23  Updated: 2023 Nov 27

Status: Open
Project: ZABBIX FEATURE REQUESTS
Component/s: Agent (G)
Affects Version/s: None
Fix Version/s: None

Type: New Feature Request Priority: Trivial
Reporter: James Cook Assignee: Vladislavs Sokurenko
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All Zabbix Agent versions



 Description   

At this point you are only able to specify one configuration setting for HostMetadataItem.

It would be handy if you were able to specify multiple items such as:

  • HostMetadataItem=Hostname, system.hostname
  • HostMetadataItem=Chassis, system.hw.chassis
  • HostMetadataItem=OS, system.sw.os[name]
  • HostMetadataItem=Architecture, system.sw.arch

Perhaps the format could be 'HostMetadataItem=<Label>,<Item>'  (i.e. HostMetadataItem=Hostname, system.hostname) so the data returned may look something like 'Hostname=HostX, Chassis=VMware Virtual Platform....'.

This way you would be able to tell what is what in the metadata returned and use this accordingly in the Auto-Registration actions when comparing values.

I would also suggest In addition if the agent could have a configuration setting to send metadata formatted as a JSON dict to contain these for example:

{     "Hostname": "HostX",     "Chassis": "VMware Virtual Platform",     "OS": "Red Hat Enterprise Linux Server 7.9 (Maipo)",     "Architecture": "x64" }

In the Auto-Registration actions it would be handy to have a compare/match/exists against a JSONPath so you can extract out specific values etc...

The use case is we currently have a script that produces metadata in the format of the following:

'0:<provider>,1:<client>,2:<group>,3:<agentType>,4:<agentVersion>,5:<agentListenIp>,6:<agentPort>,7:<host>,8:<hostFQDN>,9:<osFamily>,10:<osName>,11:<osBuild>,12:<architecture>'

This makes it easier to apply specific 'base' templates at the time of Agent Auto-Registration.



 Comments   
Comment by atpk [ 2023 Nov 24 ]

Hi James Cook,

You can achieve this with help of user parameters. Bind your script to a user parameter and give that parameter in host metadata item. Verify metadata by calling parameter with zabbix_get.

On agent conf:

HostMetadataItem=my.script

UserParameter=my.script,/path/to/myscript

and restart agent.

On server:

zabbix_get -s <agent> -k my.script

and you can write autoregistration actions as usual.

 

You can simplify your current script output. Try to change it to space or newline delimited keywords.

<provider> <client> <group>

or

<provider>

<client>

<group>

Comment by James Cook [ 2023 Nov 27 ]

Hi atpk,

This is how we have approached it, however it required us to write a script to encapsulate the data into one string.

I guess the script could use zabbix_gets via localhost(127.0.0.1) to get that information.

It would be nice to be able to do this out of the box for others that want to use native items from the agent that supports JSON formatting along with JSON functions in the Zabbix Action for auto-registration.

Note: I did not use json formatting as the metadata character limit was small in older versions of the agent - will be changing to json

Cheers

James

Generated at Wed Apr 02 23:54:47 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.