mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Merge branch 'master' of https://github.com/LordHepipud/icinga-module-windows
This commit is contained in:
commit
01badf1c6d
4 changed files with 36 additions and 7 deletions
|
|
@ -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
|
||||
* [#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
|
||||
* [#94](https://github.com/Icinga/icinga-powershell-framework/issues/94) Adds `Namespace` argument for Get-IcingaWindowsInformation for additional filtering
|
||||
|
||||
### Bugfixes
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ function Get-IcingaWindowsInformation()
|
|||
param (
|
||||
[string]$ClassName,
|
||||
$Filter,
|
||||
$Namespace,
|
||||
[switch]$ForceWMI = $FALSE
|
||||
);
|
||||
|
||||
|
|
@ -15,6 +16,11 @@ function Get-IcingaWindowsInformation()
|
|||
'Filter', $Filter
|
||||
);
|
||||
}
|
||||
if ([string]::IsNullOrEmpty($Namespace) -eq $FALSE) {
|
||||
$Arguments.Add(
|
||||
'Namespace', $Namespace
|
||||
);
|
||||
}
|
||||
|
||||
if ($ForceWMI -eq $FALSE -And (Get-Command 'Get-CimInstance' -ErrorAction SilentlyContinue)) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -25,15 +25,37 @@
|
|||
function Show-IcingaTimer()
|
||||
{
|
||||
param (
|
||||
[string]$Name = 'DefaultTimer'
|
||||
[string]$Name = 'DefaultTimer',
|
||||
[switch]$ShowAll = $FALSE
|
||||
);
|
||||
|
||||
$TimerObject = Get-IcingaTimer -Name $Name;
|
||||
|
||||
if ($null -eq $TimerObject) {
|
||||
Write-IcingaConsoleNotice 'A timer with the name "{0}" does not exist' -Objects $Name;
|
||||
return;
|
||||
}
|
||||
if (-Not $ShowAll) {
|
||||
if ($null -eq $TimerObject) {
|
||||
Write-IcingaConsoleNotice 'A timer with the name "{0}" does not exist' -Objects $Name;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ function Start-IcingaTimer()
|
|||
[string]$Name = 'DefaultTimer'
|
||||
);
|
||||
|
||||
if ((Test-IcingaTimer)) {
|
||||
if ((Test-IcingaTimer -Name $Name)) {
|
||||
Write-IcingaConsoleNotice 'The timer with the name "{0}" is already active' -Objects $Name;
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue