Skip to content

Commit

Permalink
Adds new start and stop Cmdlets for Icinga
Browse files Browse the repository at this point in the history
  • Loading branch information
LordHepipud committed Sep 19, 2024
1 parent 0b0eafc commit 2f53844
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 24 deletions.
1 change: 1 addition & 0 deletions doc/100-General/10-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
### Enhancements

* [#756](https://github.com/Icinga/icinga-powershell-framework/pull/756) Adds feature to set process priority for Icinga for Windows to BelowNormal for improved Host performance
* [#757](https://github.com/Icinga/icinga-powershell-framework/pull/757) Adds new Cmdlets `Start-Icinga`, `Stop-Icinga`, `Start-IcingaForWindows` and `Stop-IcingaForWindows` in addition to the existing Cmdlets `Restart-Icinga` and `Restart-IcingaForWindows`

## 1.13.0 Beta-1 (2024-08-30)

Expand Down
4 changes: 2 additions & 2 deletions lib/core/framework/Install-IcingaForWindowsService.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function Install-IcingaForWindowsService()

if ($IfWService.Status -eq 'Running') {
Write-IcingaConsoleNotice 'Stopping Icinga PowerShell service';
Stop-IcingaWindowsService;
Stop-IcingaForWindows;
Start-Sleep -Seconds 1;
}

Expand Down Expand Up @@ -93,7 +93,7 @@ function Install-IcingaForWindowsService()
Set-IcingaServiceUser -User 'LocalSystem' -Service 'icingapowershell' | Out-Null;
Restart-IcingaForWindows;
Start-Sleep -Seconds 1;
Stop-IcingaWindowsService;
Stop-IcingaForWindows;
Start-Sleep -Seconds 1;

if ($IfWService.Status -eq 'Running') {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/framework/Install-IcingaFrameworkUpdate.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function Install-IcingaFrameworkUpdate()

if ($ServiceStatus -eq 'Running') {
Write-IcingaConsoleNotice 'Stopping Icinga PowerShell service';
Stop-IcingaWindowsService;
Stop-IcingaForWindows;
Start-Sleep -Seconds 1;
}
if ($AgentStatus -eq 'Running') {
Expand Down
4 changes: 2 additions & 2 deletions lib/core/framework/Invoke-IcingaForWindowsMigration.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function Invoke-IcingaForWindowsMigration()

Write-IcingaConsoleNotice 'Applying pending migrations required for Icinga for Windows v1.8.0';
if ($ServiceStatus -eq 'Running') {
Stop-IcingaWindowsService;
Stop-IcingaForWindows;
}

$ApiChecks = Get-IcingaPowerShellConfig -Path 'Framework.Experimental.UseApiChecks';
Expand Down Expand Up @@ -46,7 +46,7 @@ function Invoke-IcingaForWindowsMigration()
$ServiceStatus = (Get-Service 'icingapowershell' -ErrorAction SilentlyContinue).Status;

if ($ServiceStatus -eq 'Running') {
Stop-IcingaWindowsService;
Stop-IcingaForWindows;
}

# Convert the time intervals for the background daemon services from the previous index handling
Expand Down
2 changes: 1 addition & 1 deletion lib/core/framework/Uninstall-IcingaForWindowsService.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Uninstall-IcingaForWindowsService()

$ServiceData = Get-IcingaForWindowsServiceData;

Stop-IcingaWindowsService;
Stop-IcingaForWindows;
Start-Sleep -Seconds 1;

$ServiceCreation = Start-IcingaProcess -Executable 'sc.exe' -Arguments 'delete icingapowershell';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function Show-IcingaForWindowsMenuManageIcingaForWindowsServices()
'DisabledReason' = 'The Icinga for Windows service is either not installed or not running';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Stop-IcingaWindowsService';
'Command' = 'Stop-IcingaForWindows';
}
},
@{
Expand Down
2 changes: 1 addition & 1 deletion lib/core/jea/Deny-IcingaJEACommand.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function Deny-IcingaJEACommand()
'Restart-IcingaForWindows'.ToLower() {
return $TRUE;
};
'Stop-IcingaWindowsService'.ToLower() {
'Stop-IcingaForWindows'.ToLower() {
return $TRUE;
};
'Stop-IcingaService'.ToLower() {
Expand Down
2 changes: 1 addition & 1 deletion lib/core/repository/Install-IcingaComponent.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function Install-IcingaComponent()

if ($ServiceStatus -eq 'Running') {
Write-IcingaConsoleNotice 'Stopping Icinga for Windows service';
Stop-IcingaWindowsService;
Stop-IcingaForWindows;
Start-Sleep -Seconds 1;
}
if ($AgentStatus -eq 'Running') {
Expand Down
4 changes: 2 additions & 2 deletions lib/core/windows/Restart-Icinga.psm1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function Restart-Icinga()
{
Restart-IcingaService -Service 'icinga2';
Restart-IcingaForWindows;
Stop-Icinga;
Start-Icinga;
}
13 changes: 2 additions & 11 deletions lib/core/windows/Restart-IcingaWindowsService.psm1
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
function Restart-IcingaForWindows()
{
[string]$JeaPid = Get-IcingaJEAServicePid;

Stop-IcingaService -Service 'icingapowershell';

if ((Test-IcingaJEAServiceRunning -JeaPid $JeaPid)) {
Stop-IcingaJEAProcess -JeaPid $JeaPid;
}

Restart-IcingaService -Service 'icingapowershell';
# Update the process priority after each restart
Start-IcingaWindowsScheduledTaskProcessPriority;
Stop-IcingaForWindows;
Start-IcingaForWindows;
}

Set-Alias -Name 'Restart-IcingaWindowsService' -Value 'Restart-IcingaForWindows';
5 changes: 5 additions & 0 deletions lib/core/windows/Start-Icinga.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function Start-Icinga()
{
Start-IcingaService -Service 'icinga2';
Start-IcingaForWindows;
}
6 changes: 6 additions & 0 deletions lib/core/windows/Start-IcingaForWindows.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function Start-IcingaForWindows()
{
Start-IcingaService -Service 'icingapowershell';
# Update the process priority after each restart
Start-IcingaWindowsScheduledTaskProcessPriority;
}
5 changes: 5 additions & 0 deletions lib/core/windows/Stop-Icinga.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function Stop-Icinga()
{
Stop-IcingaService -Service 'icinga2';
Stop-IcingaForWindows;
}
4 changes: 3 additions & 1 deletion lib/core/windows/Stop-IcingaWindowsService.psm1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function Stop-IcingaWindowsService()
function Stop-IcingaForWindows()
{
[string]$JeaPid = Get-IcingaJEAServicePid;

Expand All @@ -8,3 +8,5 @@ function Stop-IcingaWindowsService()
Stop-Process -Id $JeaPid -Force;
}
}

Set-Alias -Name 'Stop-IcingaWindowsService' -Value 'Stop-IcingaForWindows';
2 changes: 1 addition & 1 deletion lib/core/windows/Uninstall-IcingaServiceUser.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function Uninstall-IcingaServiceUser()
Write-IcingaConsoleNotice 'Uninstalling user "{0}"' -Objects $IcingaUser;

Stop-IcingaService 'icinga2';
Stop-IcingaWindowsService;
Stop-IcingaForWindows;

Set-IcingaPowerShellConfig -Path 'Framework.Icinga.ServiceUser' -Value '';

Expand Down

0 comments on commit 2f53844

Please sign in to comment.