Ad Widget

Collapse

Zabbix Returning Empty Value When Using PowerShell Get-Process

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pdwelliver
    Junior Member
    • Jun 2021
    • 4

    #1

    Zabbix Returning Empty Value When Using PowerShell Get-Process

    I wrote a simple PowerShell script to check and see if specific processes are running in Windows. I am running multiple instances of these processes which run in a command window so all of the processes have the same name, but I need to differentiate between each instance of the running processes. They are actually each connected to a different data stream and must be running all of the time. Fortunately, each of the command windows has a different title (MainWindowTitle property) so I can use that to know which data set each process is running. I am using the Get-Process | Where-Object to retrieve the property MainWindowTitle.

    PowerShell Script
    get-process | where-object { $_.MainWindowTitle -Like "ITWS Solace JMS 1.9.2" } | select-object ProcessName, MainWindowTitle | Write-Output

    Results Running Script In PowerShell
    ProcessName MainWindowTitle
    ----------- ---------------
    cmd ITWS Solace JMS 1.9.2

    The results is correct and what I needed. This is actually a simplified version of the script I will need to run but isolates the problem I am having.

    I then set this up as a UserParameter and tested it using Zabbix_agent2.exe and got the same basic result with the same value in the MainWindowTitle property.

    UserParameter Setup In Configuration File
    UserParameter=IsITWSRunning,PowerShell -NoProfile -ExecutionPolicy Bypass -file D:/Zabbix_Scripts/IsITWSRunning.ps1​

    I then set this up as an item in Zabbix and the returned data set was empty.

    Item Key: IsITWSRunning
    Type: Zabbix Agent
    Type Of Information Text

    I did some further testing where I had the script retrieve all of the properties and it worked fine when I tested it with the Zabbix_agent2.exe. It retrieved all of the properties and they had expected values, but when I tested it as an item in Zabbix the MainWindowTile value was blank. The other properties had the same values as when I tested it with Zabbix_agent2.exe. With script below I got other processes running with the ProcessName 'cmd' and found the process instance I was interested in by looking at the ID property.

    Modified PowerShell Script
    get-process | where-object { $_.ProcessName -Like "cmd" } | Format-List * | Write-Output

    Am I doing something wrong or could there be a bug in Zabbix or some other issue? Is there any way I can get around this?
    I am using Zabbix Sever version 5.0.23 on Centos 7 with the Win64 Zabbix_Agent2 version 5.4.0 on Windows Server 2012 R2 Standard. I have tested this on other versions of Window Server with the same results.​



Working...