Fixes custom daemon example for restart_error counter

This commit is contained in:
Lord Hepipud 2020-05-06 11:36:15 +02:00
parent cac7e941f0
commit 10c9add973

View file

@ -296,7 +296,13 @@ function Start-IcingaAgentServiceTest()
if ($ServiceState.Status -ne 'Running') {
try {
# Try to restart the service
Restart-Service 'icinga2';
Restart-Service 'icinga2' -ErrorAction Stop;
Add-IcingaHashtableItem `
-Hashtable $IcingaDaemonData.BackgroundDaemon.TestIcingaAgentService.ServiceState `
-Key 'restart_error' `
-Value 0 `
-Override | Out-Null;
} catch {
# Add an error counter in case we failed
$RestartErrors += 1;
@ -378,7 +384,13 @@ function Start-IcingaAgentServiceTest()
if ($ServiceState.Status -ne 'Running') {
try {
# Try to restart the service
Restart-Service 'icinga2';
Restart-Service 'icinga2' -ErrorAction Stop;
Add-IcingaHashtableItem `
-Hashtable $IcingaDaemonData.BackgroundDaemon.TestIcingaAgentService.ServiceState `
-Key 'restart_error' `
-Value 0 `
-Override | Out-Null;
} catch {
# Add an error counter in case we failed
$RestartErrors += 1;