-
Change Request
-
Resolution: Unresolved
-
Major
-
None
-
None
-
Debian 9 Stretch amd64
zabbix_proxy (Zabbix) 3.4.12
Due to the new possibilites Microsoft offers the Linux community, I installed Microsoft PowerShell and Vmware PowerCLI on Debian.
I want Zabbix Proxy to query VMware vCenter via External check.
I created a ps1 script which accepts several copmmand line arguments.
Zabbix wraps each argument in quotation marks, but PowerShell can't interpret arguments in quotation marks.
Steps to reproduce:
- Create an Item of Type "External check"
- Create the Key. Can be Any Key with script name and at least 1 Parameter. For example:
- vmware.ps.wrapper.shvmware.vm.snapshot.count.ps1,{HOST.CONN},{$USERNAME},'{$PASSWORD}',{#VM.NAME}
- Set Debug Log to Level 4
Result:
zabbix_proxy.log:
13741:20180809:094425.082 In get_value() key:'vmware.vm.snapshot.count.ps1[-Server {HOST.CONN},-User {$USERNAME},-Password '{$PASSWORD}',-VM {#VM.NAME}]' 13741:20180809:094425.082 In get_value_external() key:'vmware.vm.snapshot.count.ps1[-Server 10.23.0.200,-User [email protected],-Password 'XXX',-VM server.domain.local]' 13741:20180809:094425.083 In zbx_popen() command:'/usr/lib/zabbix/externalscripts/vmware.vm.snapshot.count.ps1 "-Server 10.23.0.200" "-User [email protected]" "-Password 'XXX'" "-VM server.domain.local"'
Zabbix puts quotation marks around any argument:
vmware.vm.snapshot.count.ps1 "-Server 10.23.0.200" "-User [email protected]" "-Password 'XXX'" "-VM server.domain.local"'
These arguments won't get parsed in the script.
Expected:
The String should be created as following:
vmware.vm.snapshot.count.ps1 -Server 10.23.0.200 -User [email protected] -Password 'XXX' -VM server.domain.local
I need Zabbix to let the Admin choose, if the arguments are put in quotation marks or not.
I solved it, by calling a Linux Bash Script first, which accepts five arguments and parses the arguments to the powershell script without quotation marks:
/usr/lib/zabbix/externalscripts/vmware.ps.wrapper.sh:
#!/bin/bash /usr/bin/pwsh -File /usr/lib/zabbix/externalscripts/$1 -Server $2 -User $3 -Password $4 -VM $5