Skip to content

Invoke-IcingaCheckService has problems with spaces in servicename #209

@stevie-sy

Description

@stevie-sy

Unfortunately, there are software companies which deliver setup routines that create a service with spaces.
e.g.
image

The check "Invoke-IcingaCheckService" can't deal with this, because this is the plugin output:
image

The director is rendering this call:

'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' '-C' 'try { Use-Icinga; } catch { Write-Output '\''The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details'\''; exit 3; }; Exit-IcingaPluginNotInstalled '\''Invoke-IcingaCheckService'\''; exit Invoke-IcingaCheckService' '-Service' 'EJM Agent' '-Exclude' '$null' '-Status' 'Running' '-Verbosity' '3'

I looked into the command definition and tested a little bit. I saw the quotes are missing. I'm not an Icinga-DSL pro, but this change works (for us). But I think there is a nicer and more elegant solution :

var arr = macro("$IcingaCheckService_Array_Service$");
if (len(arr) == 0) {
return "$null";
}
return "'" + arr.join("', '") + "'";

Tested with one service to check
image

'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' '-C' 'try { Use-Icinga; } catch { Write-Output '\''The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details'\''; exit 3; }; Exit-IcingaPluginNotInstalled '\''Invoke-IcingaCheckService'\''; exit Invoke-IcingaCheckService' '-Service' ''\''"EJM Agent"'\''' '-Exclude' '$null' '-Status' 'Running' '-Verbosity' '3'

And also tested with more services to check:
image

'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' '-C' 'try { Use-Icinga; } catch { Write-Output '\''The Icinga PowerShell Framework is either not installed on the system or not configured properly. Please check https://icinga.com/docs/windows for further details'\''; exit 3; }; Exit-IcingaPluginNotInstalled '\''Invoke-IcingaCheckService'\''; exit Invoke-IcingaCheckService' '-Service' ''\''EJM Agent'\'', '\''icinga2'\'', '\''icingapowershell'\'', '\''MpsSvc'\'', '\''EventLog'\''' '-Exclude' '$null' '-Status' 'Running' '-Verbosity' '3'

Metadata

Metadata

Assignees

Labels

EnhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions