[ZBX-17249] Zabbix Agent 4.4 for Win Created: 2020 Jan 30 Updated: 2025 Apr 26 Resolved: 2020 Apr 08 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Documentation (D) |
Affects Version/s: | 4.4.4, 4.4.5 |
Fix Version/s: | 5.0 (plan) |
Type: | Documentation task | Priority: | Trivial |
Reporter: | Rolf Hebgen | Assignee: | Viktors Tjarve |
Resolution: | Fixed | Votes: | 1 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
Win 2019 Core amd 64; Zabbix Agent 4.4.5, Zabbix Agent 4.4.4 with and without openssl |
Issue Links: |
|
||||
Team: | |||||
Sprint: | Sprint 62 (Mar 2020), Sprint 63 (Apr 2020) | ||||
Story Points: | 1 |
Description |
Steps to reproduce:
Result: zabbix_agentd.exe [10812]: Warning: failed to get system hostname from [system.run[powershell -NonInteractive "[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.toLo wer()"]]) Expected: https://www.zabbix.com/documentation/current/manual/appendix/config/zabbix_agentd_win |
Comments |
Comment by Markku Leiniö [ 2020 Jan 30 ] |
Same observation, with the same HostnameItem configured on both config files (3.4.0 agent finds the correct hostname "windows8", 4.4.4 fails):
C:\zabbix>bin\win64\zabbix_agentd.exe --config conf\zabbix_agentd.win.conf -f Starting Zabbix Agent [windows8]. Zabbix 3.4.0 (revision 71462). Press Ctrl+C to exit. (^C) C:\zabbix>cd "\Program Files\Zabbix Agent" C:\Program Files\Zabbix Agent>zabbix_agentd.exe --config zabbix_agentd.conf -f zabbix_agentd.exe [3116]: Warning: failed to get system hostname from [system.run[powershell -NonInteractive "[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.toLower()"]]) zabbix_agentd.exe [3116]: ERROR: "Hostname" configuration parameter is not defined C:\Program Files\Zabbix Agent>zabbix_agentd.exe --version zabbix_agentd Win64 (service) (Zabbix) 4.4.4
|
Comment by Maximilian Brune [ 2020 Mar 13 ] |
same here. Version 4.0.18 is not working either. |
Comment by dimir [ 2020 Mar 13 ] |
markkul, could you try it with the same config file? |
Comment by Markku Leiniö [ 2020 Mar 13 ] |
C:\zabbix\bin\win64>zabbix_agentd.exe --config "\Program Files\Zabbix Agent\zabbix_agentd.conf" -f Starting Zabbix Agent [windows8]. Zabbix 3.4.0 (revision 71462). Press Ctrl+C to exit. C:\zabbix\bin\win64>cd "\Program Files\Zabbix Agent" C:\Program Files\Zabbix Agent>zabbix_agentd.exe --config zabbix_agentd.conf -f zabbix_agentd.exe [2732]: Warning: failed to get system hostname from [system.run[powershell -NonInteractive "[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.toLower()"]]) zabbix_agentd.exe [2732]: ERROR: "Hostname" configuration parameter is not defined C:\Program Files\Zabbix Agent>zabbix_agentd.exe --version zabbix_agentd Win64 (service) (Zabbix) 4.4.4 C:\Program Files\Zabbix Agent>find /V "#" zabbix_agentd.conf LogFile=C:\Program Files\Zabbix Agent\zabbix_agentd.log Server=172.16.4.161 ServerActive=172.16.4.161 HostnameItem=system.run[powershell -NonInteractive "[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.toLower()"] Include=C:\Program Files\Zabbix Agent\zabbix_agentd.conf.d\ (which is empty) |
Comment by dimir [ 2020 Mar 13 ] |
Thank you! Will try to get some attention to this. |
Comment by Maximilian Brune [ 2020 Mar 17 ] |
Writing it like this fixed it for me: Maybe something for Documentation that commands with '[' and ']' characters need to be quoted. |
Comment by dimir [ 2020 Mar 18 ] |
The feature is kind of documented here https://www.zabbix.com/documentation/current/manual/config/items/item/key#parameter_-_array however I agree it might be not too easy to understand. As to particularly documenting Windows agent configuration, I agree, let's see if that will help others here. |
Comment by Viktors Tjarve [ 2020 Mar 27 ] |
Everything here is working as it should according to documentation. When using HostnameItem with system.run[] item all the item key formatting rules apply to it. The correct format in this case is: HostnameItem=system.run["powershell -NonInteractive \"[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLower()\""] The documentation could be improved by additionally pointing out that if a parameter string contains quotation mark then this parameter has to be quoted and each quotation mark inside of that string has to be escaped with "\" character. |
Comment by Marina Generalova [ 2020 Apr 07 ] |
viktors.tjarve, thanks for the suggestion! Documentation updated: |
Comment by Dimitri Bellini [ 2020 Apr 29 ] |
Hi Viktors, I come on the issue but in my case is more tricky... If put the system.run on Zabbix Agent HostInterfaceItem parameter everything is working . Zabbix Agent 4.4.5 - zabbix_agentd.conf HostInterfaceItem=system.run["powershell -NonInteractive \"[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLower()\""] Log from Zabbix Agent 13112:20200429:115044.640 EXECUTE_STR() command:'powershell -NonInteractive "[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLower()"' len:15 cmd_result:'desktop-kfhjv0d'
The problem comes when i test using Zabbix Get on the same Windows machine CMD shell: zabbix_get.exe -s 127.0.0.1 -k system.run["powershell -NonInteractive \"[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLower()\""] Agent Log details: 11472:20200429:114728.420 Requested [system.run[powershell -NonInteractive "[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLower()"]] 11472:20200429:114728.421 Sending back [ZBX_NOTSUPPORTED: Invalid item key format.]
Do you know why? Thanks |
Comment by Viktors Tjarve [ 2020 Apr 29 ] |
Hi Dimitri, zabbix_get.exe -s 127.0.0.1 -k "system.run[\"powershell -NonInteractive \\\"[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLower()\\\"\"]" |
Comment by Vladislavs Sokurenko [ 2020 Apr 29 ] |
This is windows cmd specific On linux I would simply do:
./bin/zabbix_get -s 127.0.0.1 -k 'system.run["powershell -NonInteractive \"[System.Net.Dns]::GetHostByName(($env:computerName)).Hostname.ToLower()\""]'
|
Comment by Dimitri Bellini [ 2020 Apr 30 ] |
Hi vso & viktors.tjarve, Thanks so much for your suggestion and both solution is working, i would suggest to Zabbix Team to update the Documentation about this case (include some example scenario). Still thanks so much! |