Ad Widget

Collapse

Using system hostname in templates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mtudor
    Junior Member
    • Jul 2023
    • 2

    #1

    Using system hostname in templates

    Hi, I have an issue making the "RabbitMQ node by Zabbix agent" template work (Zabbix 6.2.6), more specifically on lines like this:

    Code:
    master_item:
        key: 'web.page.get["{$RABBITMQ.API.SCHEME}://{$RABBITMQ.API.USER}:{$RABBITMQ.API.PASSWORD}@{$RABBITMQ.API.HOST}:{$RABBITMQ.API.PORT}/api/nodes/{$RABBITMQ.CLUSTER.NAME}@{HOST.NAME}?memory=true"]'
    ​
    because in my case the {HOST.NAME} (so basically the displayed name set in the agent configuration) and the rabbitmq node name (which is the system hostname) are different.

    I've tried using {HOST.DNS} but this expands to an emptry string, {HOST.DNS1} which remains a string, or ip-{{HOST.IP}.regsub(\.,-}} which again just stays as it is, like a string. I've tried also with agent.hostname, no luck.

    Is there any way in which I can use the system hostname on that expression, in stead of {HOST.NAME}? Or any way in which i can apply regsub to {HOST.IP} at least (all I need is to replace . with -)?​
  • mtudor
    Junior Member
    • Jul 2023
    • 2

    #2
    Turns out that if the agent connects via IP then {HOST.DNS} is not available, but if you switch it to connect to DNS (by setting HostInterface in zabbix_agent2.conf), then {HOST.DNS} expands properly, this could've been documented a little better. So that solves my problem here, I'm posting it so maybe it will help somebody else in the future.

    Comment

    Working...