-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds feature to set process priority for Icinga for Windows to BelowN…
…ormal for improved Host performance
- Loading branch information
1 parent
d9ba095
commit 0b0eafc
Showing
6 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Load the basic framework data | ||
Use-Icinga -Minimal; | ||
|
||
# Wait 10 seconds before procedding | ||
Start-Sleep -Seconds 10; | ||
|
||
# Fetch the process information for JEA and the Icinga for Windows PID | ||
$JeaProcess = Get-Process -Id (Get-IcingaJEAServicePid) -ErrorAction SilentlyContinue; | ||
$IfWProcess = Get-Process -Id (Get-IcingaForWindowsServicePid) -ErrorAction SilentlyContinue; | ||
|
||
# Set the JEA pid to below normal | ||
if ($null -ne $JeaProcess -And $JeaProcess.ProcessName -eq 'wsmprovhost') { | ||
$JeaProcess.PriorityClass = 'BelowNormal'; | ||
} | ||
|
||
# Set the Icinga for Windows pid to below normal | ||
if ($null -ne $IfWProcess -And $IfWProcess.ProcessName -eq 'powershell') { | ||
$IfWProcess.PriorityClass = 'BelowNormal'; | ||
} | ||
|
||
# Exit with okay | ||
exit 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
lib/core/wintasks/daemon/Register-TaskIcingaForWindowsProcessPriority.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
function Register-IcingaWindowsScheduledTaskProcessPriority() | ||
{ | ||
param ( | ||
[switch]$Force = $FALSE | ||
); | ||
|
||
[string]$TaskName = 'Set Process Priority'; | ||
[string]$TaskPath = '\Icinga\Icinga for Windows\'; | ||
|
||
$SetProcessPriorityTask = Get-ScheduledTask -TaskName $TaskName -TaskPath $TaskPath -ErrorAction SilentlyContinue; | ||
|
||
if ($null -ne $SetProcessPriorityTask -And $Force -eq $FALSE) { | ||
Write-IcingaConsoleWarning -Message 'The {0} task is already present. User -Force to enforce the re-creation' -Objects $TaskName; | ||
return; | ||
} | ||
|
||
$ScriptPath = Join-Path -Path (Get-IcingaFrameworkRootPath) -ChildPath '\jobs\SetProcessPriority.ps1'; | ||
$TaskAction = New-ScheduledTaskAction -Execute 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' -Argument ([string]::Format("-WindowStyle Hidden -Command &{{ & '{0}' }}", $ScriptPath)); | ||
$TaskPrincipal = New-ScheduledTaskPrincipal -UserId 'S-1-5-18' -RunLevel 'Highest' -LogonType ServiceAccount; | ||
$TaskSettings = New-ScheduledTaskSettingsSet -DontStopIfGoingOnBatteries -AllowStartIfOnBatteries -StartWhenAvailable; | ||
|
||
Register-ScheduledTask -TaskName $TaskName -TaskPath $TaskPath -Force -Principal $TaskPrincipal -Action $TaskAction -Settings $TaskSettings | Out-Null; | ||
|
||
Write-IcingaConsoleNotice -Message 'The task "{0}" has been successfully registered at location "{1}".' -Objects $TaskName, $TaskPath; | ||
} |
14 changes: 14 additions & 0 deletions
14
lib/core/wintasks/daemon/Start-TaskSetProcessPriority.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function Start-IcingaWindowsScheduledTaskProcessPriority() | ||
{ | ||
[string]$TaskName = 'Set Process Priority'; | ||
[string]$TaskPath = '\Icinga\Icinga for Windows\'; | ||
|
||
$SetProcessPriorityTask = Get-ScheduledTask -TaskName $TaskName -TaskPath $TaskPath -ErrorAction SilentlyContinue; | ||
|
||
if ($null -eq $SetProcessPriorityTask) { | ||
Write-IcingaConsoleNotice -Message 'The "{0}" task is not present on this system.' -Objects $TaskName; | ||
return; | ||
} | ||
|
||
Start-ScheduledTask -TaskName $TaskName -TaskPath $TaskPath; | ||
} |