Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  1. ZABBIX FEATURE REQUESTS
  2. ZBXNEXT-4761

Zabbix Item Type External Check wraps each argument in quotation marks, which breaks PowerShell Core

    Details

      Description

      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:

      1. Create an Item of Type "External check"
      2. Create the Key. Can be Any Key with script name and at least 1 Parameter. For example:
      3. vmware.ps.wrapper.shvmware.vm.snapshot.count.ps1,{HOST.CONN},{$USERNAME},'{$PASSWORD}',{#VM.NAME}
      4. 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 monitoring@vsphere.local,-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 monitoring@vsphere.local" "-Password 'XXX'" "-VM server.domain.local"'
      

       

       Zabbix puts quotation marks around any argument:

      vmware.vm.snapshot.count.ps1 "-Server 10.23.0.200" "-User monitoring@vsphere.local" "-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 monitoring@vsphere.local -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
      

       

        Attachments

          Activity

            People

            • Assignee:
              zabbix.support Zabbix Support Team
              Reporter:
              starko Marco Hofmann
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: