This commit is contained in:
Christian Stein 2020-08-06 09:02:42 +02:00
commit 01badf1c6d
4 changed files with 36 additions and 7 deletions

View file

@ -21,6 +21,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#76](https://github.com/Icinga/icinga-powershell-framework/issues/76) Adds support to test for required .NET Framework Version 4.6.0 or above before trying to install the Icinga Agent * [#76](https://github.com/Icinga/icinga-powershell-framework/issues/76) Adds support to test for required .NET Framework Version 4.6.0 or above before trying to install the Icinga Agent
* [#87](https://github.com/Icinga/icinga-powershell-framework/issues/87) Adds wrapper command to test new code or functionality of Framework and/or plugins * [#87](https://github.com/Icinga/icinga-powershell-framework/issues/87) Adds wrapper command to test new code or functionality of Framework and/or plugins
* [#88](https://github.com/Icinga/icinga-powershell-framework/issues/88) Adds Start/Stop timer functionality for performance analysis * [#88](https://github.com/Icinga/icinga-powershell-framework/issues/88) Adds Start/Stop timer functionality for performance analysis
* [#94](https://github.com/Icinga/icinga-powershell-framework/issues/94) Adds `Namespace` argument for Get-IcingaWindowsInformation for additional filtering
### Bugfixes ### Bugfixes

View file

@ -3,6 +3,7 @@ function Get-IcingaWindowsInformation()
param ( param (
[string]$ClassName, [string]$ClassName,
$Filter, $Filter,
$Namespace,
[switch]$ForceWMI = $FALSE [switch]$ForceWMI = $FALSE
); );
@ -15,6 +16,11 @@ function Get-IcingaWindowsInformation()
'Filter', $Filter 'Filter', $Filter
); );
} }
if ([string]::IsNullOrEmpty($Namespace) -eq $FALSE) {
$Arguments.Add(
'Namespace', $Namespace
);
}
if ($ForceWMI -eq $FALSE -And (Get-Command 'Get-CimInstance' -ErrorAction SilentlyContinue)) { if ($ForceWMI -eq $FALSE -And (Get-Command 'Get-CimInstance' -ErrorAction SilentlyContinue)) {
try { try {

View file

@ -25,15 +25,37 @@
function Show-IcingaTimer() function Show-IcingaTimer()
{ {
param ( param (
[string]$Name = 'DefaultTimer' [string]$Name = 'DefaultTimer',
[switch]$ShowAll = $FALSE
); );
$TimerObject = Get-IcingaTimer -Name $Name; $TimerObject = Get-IcingaTimer -Name $Name;
if (-Not $ShowAll) {
if ($null -eq $TimerObject) { if ($null -eq $TimerObject) {
Write-IcingaConsoleNotice 'A timer with the name "{0}" does not exist' -Objects $Name; Write-IcingaConsoleNotice 'A timer with the name "{0}" does not exist' -Objects $Name;
return; return;
} }
return $TimerObject.Elapsed.TotalSeconds; $TimerOutput = New-Object -TypeName PSObject;
$TimerOutput | Add-Member -MemberType NoteProperty -Name 'Timer Name' -Value $Name;
$TimerOutput | Add-Member -MemberType NoteProperty -Name 'Elapsed Seconds' -Value $TimerObject.Elapsed.TotalSeconds;
$TimerOutput | Format-Table -AutoSize;
} else {
$TimerObjects = Get-IcingaHashtableItem -Key 'IcingaTimers' -Hashtable $global:IcingaDaemonData;
[array]$MultiOutput = @();
foreach ($TimerName in $TimerObjects.Keys) {
$TimerObject = $TimerObjects[$TimerName].Timer;
$TimerOutput = New-Object -TypeName PSObject;
$TimerOutput | Add-Member -MemberType NoteProperty -Name 'Timer Name' -Value $TimerName;
$TimerOutput | Add-Member -MemberType NoteProperty -Name 'Elapsed Seconds' -Value $TimerObject.Elapsed.TotalSeconds;
$MultiOutput += $TimerOutput;
}
$MultiOutput | Format-Table -AutoSize;
}
} }

View file

@ -26,7 +26,7 @@ function Start-IcingaTimer()
[string]$Name = 'DefaultTimer' [string]$Name = 'DefaultTimer'
); );
if ((Test-IcingaTimer)) { if ((Test-IcingaTimer -Name $Name)) {
Write-IcingaConsoleNotice 'The timer with the name "{0}" is already active' -Objects $Name; Write-IcingaConsoleNotice 'The timer with the name "{0}" is already active' -Objects $Name;
return; return;
} }