Ad Widget

Collapse

FQDN in HostnameItem prevents starting of agent.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CodingVoid
    Junior Member
    • Mar 2020
    • 6

    #1

    FQDN in HostnameItem prevents starting of agent.

    Hi,
    I tried to use the following in my zabbix-agent config to send the fqdn hostname (found here: https://zabbix.org/wiki/Docs/howto/fqdn-windows)
    HostnameItem=system.run[powershell -NonInteractive "[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLo wer()"] But everytime I try to start the Agent, I get the following error:
    Click image for larger version  Name:	Capture.PNG Views:	0 Size:	25.4 KB ID:	397520
    I use zabbix-version 4.4
    /Edit
    I tested the same config with multiple versions of zabbix agent and it seems that in zabbix-agent version 3.0 it's still working. But since version 4 this way of getting the fqdn in lowercase isn't working anymore, but I can't find anything in the documentation that gives me a hint, why it's not working since version 4.
    Attached Files
    Last edited by CodingVoid; 13-03-2020, 02:55.
  • dimir
    Zabbix developer
    • Apr 2011
    • 1080

    #2
    Could you show the agent config file?

    Comment

    • CodingVoid
      Junior Member
      • Mar 2020
      • 6

      #3
      I found the same Issue here:
      Attached Files

      Comment

      • dimir
        Zabbix developer
        • Apr 2011
        • 1080

        #4
        Yep, looks like it.

        Comment

        • CodingVoid
          Junior Member
          • Mar 2020
          • 6

          #5
          dimir
          I don't even know if this is the right place to share this, but I did some digging and found out that the problem resides in the following:
          file: src/libs/zbxcommon/str.c
          function: int num_param(const char *p)
          the function interprets '[' and ']' as arrays/parameter-list for zabbix. But as one can see these characters are needed in some powershell commands. Luckily some Developer seemed to already think about that and ignored these characters if they are in quotes. Only drawback is that you can't use them in a command if you quote the command itself. Luckily the command I use does not need the quotes. (Maybe something for documentation (or it already is int the documentation and I just didn't find it) in the sorts of: If you use System.run[cmd] and your cmd does have '[' and ']' characters in them, quote out the cmd like this: System.run["cmd"])

          Long story short:
          This fixed it for me:
          HostnameItem=system.run["powershell -NonInteractive [System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLo wer()"]
          Last edited by CodingVoid; 14-03-2020, 22:21.

          Comment

          • dimir
            Zabbix developer
            • Apr 2011
            • 1080

            #6
            Nice. Could you please suggest trying that in a ticket?

            Comment

          • dimir
            Zabbix developer
            • Apr 2011
            • 1080

            #7
            Danke! :-)

            Comment

            Working...