Hi, I'm kind of new to Zabbix, but I do believe I might have found some kind of bug. It would be nice to get some input from others.
The following is tested on a clean Windows 7 and Windows 10 VM with both v3.0.4 and v3.2.0. I got the same results.
The issue:
After adding a UserParameter that run a PowerShell script I get the wrong output when getting the key with zabbix_get.
It's simple to reproduce:
1.
Unzip pre-compiled agent to C:\zabbix\
2.
Add the following to C:\zabbix\conf\zabbix_agentd.win.conf:
3.
Add a file C:\zabbix\get-test.ps1 with the following content:
4.
Start zabbix_agentd:
5.
Observe wrong output with zabbix_get:
Expected output is gotten in different ways.
cmd and zabbix_agentd:
cmd and powershell:
powershell:
cmd and powershell with wrapping cmd:
The only way I've been able to reproduce the output I get with zabbix_get is like this in powershell:
(This is expected. Short story, if you aren't familiar with powershell: An empty array piped into the script/function means that there is nothing to process and the process block won't be run)
So what's going on here? Is Zabbix somehow piping some kind of empty input to the script when getting the key via zabbix_get?
I haven't been able to test this in a full server/client environment. So I'm not sure whether or not the data sent to the server contains the "process" part.
The following is tested on a clean Windows 7 and Windows 10 VM with both v3.0.4 and v3.2.0. I got the same results.
The issue:
After adding a UserParameter that run a PowerShell script I get the wrong output when getting the key with zabbix_get.
It's simple to reproduce:
1.
Unzip pre-compiled agent to C:\zabbix\
2.
Add the following to C:\zabbix\conf\zabbix_agentd.win.conf:
Code:
UserParameter=test,C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy "Bypass" -NoProfile -NonInteractive -File "C:\zabbix\get-test.ps1"
Add a file C:\zabbix\get-test.ps1 with the following content:
Code:
<#
.SYNOPSIS
ASDF
.DESCRIPTION
ASDF
#>
[CmdletBinding()] Param()
Begin {
$x = 1
Write-Host ("begin {0}" -f ($x++))
}
Process {
Write-Host ("process {0}" -f ($x++))
}
End {
Write-Host ("end {0}" -f ($x++))
}
Start zabbix_agentd:
Code:
C:\zabbix>bin\win64\zabbix_agentd.exe -c conf\zabbix_agentd.win.conf -f
Observe wrong output with zabbix_get:
Code:
C:\zabbix>bin\win64\zabbix_get.exe -s 127.0.0.1 -k test begin 1 end 2
cmd and zabbix_agentd:
Code:
C:\zabbix>bin\win64\zabbix_agentd.exe -c conf\zabbix_agentd.win.conf -t test test [t|begin 1 process 2 end 3]
Code:
C:\>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy "Bypass" -NoProfile -NonInteractive -File "C:\zabbix\get-test.ps1" begin 1 process 2 end 3
Code:
PS C:\zabbix> Set-ExecutionPolicy "Bypass" PS C:\zabbix> .\get-test.ps1 begin 1 process 2 end 3
Code:
C:\>cmd.exe /C C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy "Bypass" -NoProfile -NonInteractive -File "C:\zabbix\get-test.ps1" begin 1 process 2 end 3
(This is expected. Short story, if you aren't familiar with powershell: An empty array piped into the script/function means that there is nothing to process and the process block won't be run)
Code:
PS C:\zabbix> @() | .\get-test.ps1 begin 1 end 2
I haven't been able to test this in a full server/client environment. So I'm not sure whether or not the data sent to the server contains the "process" part.
Comment