PowerShell multiple transfer values

  • server version Ubuntu 20.04.4 LTS
  • Version used (icinga2 r2.13.3-1))
  • Enabled features (core NSClient++ 0.4.4.23 2016-04-05 x64)

I need to monitor a program that can run as an application or as a service. In addition, two texts must be included in the description of the service. I then programmed the functionalities in c-sharp and made a .dll, which I call in a .ps1 script. Until then everything works including the command from icinga. see code below:
The computer being monitored has windows 10 installed with NsClient++

However, I have the problem that I only ever get one transfer value from the Icinga, which I find unpleasant. Then every time I have to take the string apart again in the power shell script.

Comands.conv sniped:

object CheckCommand "check_acron_provider" {
  import "plugin-check-command"

  command = [PluginDir + "/check_nrpe"]

  arguments = {
    "-H" = "$host.address$"
    "-n" = ""
    "-c" = "check_acron_provider"
    "-a" = {
      value = "$service.vars.serviceName$ $service.vars.processName$ $service.vars.processTitle1$ $service.vars.processTitle2$"
      order = 1
    }
  }
}

NsClient++ init file snipet with multiple argument on check_acron_provider.ps1:

[/settings/external scripts/scripts]
check_mse_dat=cscript.exe //T:30 //NoLogo scripts\\check_mse_datdate.vbs $ARG1$ $ARG2$
check_intel_raid=cscript.exe //T:30 //NoLogo scripts\\check_intel_raid.vbs $ARG1$ 
check_acron_provider=cmd /c echo scripts\check_acron_provider.ps1 "$ARG1$" "$ARG2$" "$ARG3$" "$ARG4$"; exit $LastExitCode | powershell.exe -command -

Power Shell Script check_acron_provider.ps1

# <summary>
# Find Acron-Provider Service, and see if service 'ACProvService' or Process 'ACProv' is running. Additional with specific plant name and plant id
# </summary>
# <param name="serviceName">
#    name for the service e.g. ACProvService</param>
# <param name="processName">
#   name for the process e.g. ACProv</param>
# <param name="processTitle1">
#   text1 which must be present in the windows task-manager process description. e.g name of Acron plant</param>
# <param name="processTitle2">
#    text2 which must be present in the windows task-manager process description. e.g acron plant id</param>
# <returns>true if specific service or process exists</returns>

Param(
    [Parameter(Mandatory = $true)][string]$serviceName,
    [Parameter(Mandatory = $true)][string]$processName,
    [Parameter(Mandatory = $false)][string]$processTitle1,
    [Parameter(Mandatory = $false)][string]$processTitle2
	)

## Start Main Script
$OutputString = ""
$ExitCode = 3 # ExitCode auf 3=Unknown

# get root directorie from current file and set dll path
$icingaCsPath = [IO.Path]::Combine($PSScriptRoot , 'lib', 'IcingaScript.dll')
Write-Output $icingaCsPath
# load the dll file into shell
Add-Type -Path $icingaCsPath

# Create an instance and call an instance method
$hostProcess = New-Object IcingaScripts.HostProcess
$isProcessRuninig = $hostProcess.IsAcronProviderRunning($serviceName, $processName, $processTitle1, $processTitle2)

if ($isProcessRuninig) {
    $ExitCode = 0
    $OutputString = "All OK"
}
else {
    $ExitCode = 2
    $OutputString = "No process $($serviceName) or service $($processName) with title $($processTitle1) and $($processTitle2) -> Critical"
}

Write-Output "$OutputString"
Exit $ExitCode 

output from nscp test on client computer

if I adjust the .ini

check_acron_provider=cmd /c echo scripts\check_acron_provider.ps1 "$ARG1$"; exit $LastExitCode | powershell.exe -command -

and the powershell script:

Param(
    [Parameter(Mandatory = $true)][string]$serviceName
	)

## Start Main Script
$OutputString = ""
$ExitCode = 3 # ExitCode auf 3=Unknown

$var = $serviceName.Split(" ", 4)
$serviceName = $var[0]
$processName = $var[1]
$processTitle1 = $var[2]
$processTitle2 = $var[3]

It does work!

Does anyone know how to bring multiple values into a Power Shell script from icinga2? Or is my approach wrong?