From ac41041f4ec5bb26906dd3e439e07fe49367e01a Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Tue, 29 Oct 2019 10:47:24 +0100 Subject: [PATCH] Fixes code styling --- lib/plugins/Invoke-IcingaCheckCPU.psm1 | 4 +- lib/plugins/Invoke-IcingaCheckDirectory.psm1 | 40 ++++++------- lib/plugins/Invoke-IcingaCheckEventlog.psm1 | 6 +- .../Invoke-IcingaCheckPerfcounter.psm1 | 6 +- .../Invoke-IcingaCheckProcessCount.psm1 | 48 +++++++-------- lib/plugins/Invoke-IcingaCheckService.psm1 | 60 +++++++++---------- lib/plugins/Invoke-IcingaCheckUpdates.psm1 | 6 +- lib/plugins/Invoke-IcingaCheckUptime.psm1 | 32 +++++----- .../Invoke-IcingaCheckUsedPartitionSpace.psm1 | 58 +++++++++--------- lib/plugins/Invoke-IcingaCheckUsers.psm1 | 58 +++++++++--------- 10 files changed, 159 insertions(+), 159 deletions(-) diff --git a/lib/plugins/Invoke-IcingaCheckCPU.psm1 b/lib/plugins/Invoke-IcingaCheckCPU.psm1 index 7fdd5c7..f3b3d49 100644 --- a/lib/plugins/Invoke-IcingaCheckCPU.psm1 +++ b/lib/plugins/Invoke-IcingaCheckCPU.psm1 @@ -40,10 +40,10 @@ function Invoke-IcingaCheckCPU() param( [int]$Warning = $null, [int]$Critical = $null, - [string]$Core = '*', + [string]$Core = '*', [switch]$NoPerfData, [ValidateSet(0, 1, 2, 3)] - [int]$Verbosity = 0 + [int]$Verbosity = 0 ); $CpuCounter = New-IcingaPerformanceCounter -Counter ([string]::Format('\Processor({0})\% processor time', $Core)); diff --git a/lib/plugins/Invoke-IcingaCheckDirectory.psm1 b/lib/plugins/Invoke-IcingaCheckDirectory.psm1 index 9f7f26d..d901f7b 100644 --- a/lib/plugins/Invoke-IcingaCheckDirectory.psm1 +++ b/lib/plugins/Invoke-IcingaCheckDirectory.psm1 @@ -58,29 +58,29 @@ Import-IcingaLib provider\directory; function Invoke-IcingaCheckDirectory() { - param( - [string]$Path, - [array]$FileNames, - [switch]$Recurse, - [int]$Critical = $null, - [int]$Warning = $null, - [string]$YoungerThen, - [string]$OlderThen, - [ValidateSet(0, 1, 2, 3)] - [int]$Verbosity = 0 + param( + [string]$Path, + [array]$FileNames, + [switch]$Recurse, + [int]$Critical = $null, + [int]$Warning = $null, + [string]$YoungerThen, + [string]$OlderThen, + [ValidateSet(0, 1, 2, 3)] + [int]$Verbosity = 0 ); - $DirectoryData = Get-IcingaDirectoryAll -Path $Path -FileNames $FileNames ` - -Recurse $Recurse -YoungerThen $YoungerThen -OlderThen $OlderThen; - $DirectoryCheck = New-IcingaCheck -Name $Path -Value $DirectoryData.Count -NoPerfData; + $DirectoryData = Get-IcingaDirectoryAll -Path $Path -FileNames $FileNames ` + -Recurse $Recurse -YoungerThen $YoungerThen -OlderThen $OlderThen; + $DirectoryCheck = New-IcingaCheck -Name $Path -Value $DirectoryData.Count -NoPerfData; - $DirectoryCheck.WarnOutOfRange( - ($Warning) - ).CritOutOfRange( - ($Critical) - ) | Out-Null; + $DirectoryCheck.WarnOutOfRange( + ($Warning) + ).CritOutOfRange( + ($Critical) + ) | Out-Null; - $DirectoryPackage = New-IcingaCheckPackage -Name $Path -OperatorAnd -Checks $DirectoryCheck -Verbose $Verbosity; + $DirectoryPackage = New-IcingaCheckPackage -Name $Path -OperatorAnd -Checks $DirectoryCheck -Verbose $Verbosity; - return (New-IcingaCheckresult -Check $DirectoryPackage -NoPerfData $TRUE -Compile); + return (New-IcingaCheckresult -Check $DirectoryPackage -NoPerfData $TRUE -Compile); } \ No newline at end of file diff --git a/lib/plugins/Invoke-IcingaCheckEventlog.psm1 b/lib/plugins/Invoke-IcingaCheckEventlog.psm1 index 1f25d89..a62847f 100644 --- a/lib/plugins/Invoke-IcingaCheckEventlog.psm1 +++ b/lib/plugins/Invoke-IcingaCheckEventlog.psm1 @@ -3,8 +3,8 @@ Import-IcingaLib icinga\plugin; function Invoke-IcingaCheckEventlog() { param( - $Warning = $null, - $Critical = $null, + $Warning = $null, + $Critical = $null, [string]$LogName, [array]$IncludeEventId, [array]$ExcludeEventId, @@ -19,7 +19,7 @@ function Invoke-IcingaCheckEventlog() [switch]$DisableTimeCache = $FALSE, [switch]$NoPerfData, [ValidateSet(0, 1, 2, 3)] - [int]$Verbosity = 0 + [int]$Verbosity = 0 ); $EventLogPackage = New-IcingaCheckPackage -Name 'EventLog' -OperatorAnd -Verbose $Verbosity; diff --git a/lib/plugins/Invoke-IcingaCheckPerfcounter.psm1 b/lib/plugins/Invoke-IcingaCheckPerfcounter.psm1 index 58ea192..b10df7e 100644 --- a/lib/plugins/Invoke-IcingaCheckPerfcounter.psm1 +++ b/lib/plugins/Invoke-IcingaCheckPerfcounter.psm1 @@ -4,11 +4,11 @@ function Invoke-IcingaCheckPerfcounter() { param( [array]$PerfCounter, - [double]$Warning = $null, - [double]$Critical = $null, + [double]$Warning = $null, + [double]$Critical = $null, [switch]$NoPerfData, [ValidateSet(0, 1, 2, 3)] - [int]$Verbosity = 0 + [int]$Verbosity = 0 ); $Counters = New-IcingaPerformanceCounterArray -CounterArray $PerfCounter; diff --git a/lib/plugins/Invoke-IcingaCheckProcessCount.psm1 b/lib/plugins/Invoke-IcingaCheckProcessCount.psm1 index 117602a..a40c6e2 100644 --- a/lib/plugins/Invoke-IcingaCheckProcessCount.psm1 +++ b/lib/plugins/Invoke-IcingaCheckProcessCount.psm1 @@ -39,33 +39,33 @@ Import-IcingaLib icinga\plugin; function Invoke-IcingaCheckProcessCount() { - param( - [int]$Warning = $null, - [int]$Critical = $null, - [array]$Process, - [switch]$NoPerfData, - [ValidateSet(0, 1, 2, 3)] - [int]$Verbosity = 0 - ); + param( + [int]$Warning = $null, + [int]$Critical = $null, + [array]$Process, + [switch]$NoPerfData, + [ValidateSet(0, 1, 2, 3)] + [int]$Verbosity = 0 + ); - $ProcessInformation = (Get-IcingaProcessData -Name $Process) + $ProcessInformation = (Get-IcingaProcessData -Name $Process) - $ProcessPackage = New-icingaCheckPackage -Name "Process Check" -OperatorAnd -Verbose $Verbosity -NoPerfData $NoPerfData; + $ProcessPackage = New-icingaCheckPackage -Name "Process Check" -OperatorAnd -Verbose $Verbosity -NoPerfData $NoPerfData; - if ($Process.Count -eq 0) { - $ProcessCount = $ProcessInformation['Process Count']; - $IcingaCheck = New-IcingaCheck -Name ([string]::Format('Process Count')) -Value $ProcessCount; - $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; - $ProcessPackage.AddCheck($IcingaCheck); - } else { - foreach ($proc in $process) { - $ProcessCount = $ProcessInformation."Processes".$proc.processlist.Count; - $IcingaCheck = New-IcingaCheck -Name ([string]::Format('Process Count "{0}"', $proc)) -Value $ProcessCount; - $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; - $ProcessPackage.AddCheck($IcingaCheck); - } - } + if ($Process.Count -eq 0) { + $ProcessCount = $ProcessInformation['Process Count']; + $IcingaCheck = New-IcingaCheck -Name ([string]::Format('Process Count')) -Value $ProcessCount; + $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; + $ProcessPackage.AddCheck($IcingaCheck); + } else { + foreach ($proc in $process) { + $ProcessCount = $ProcessInformation."Processes".$proc.processlist.Count; + $IcingaCheck = New-IcingaCheck -Name ([string]::Format('Process Count "{0}"', $proc)) -Value $ProcessCount; + $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; + $ProcessPackage.AddCheck($IcingaCheck); + } + } - return (New-IcingaCheckResult -Check $ProcessPackage -NoPerfData $NoPerfData -Compile); + return (New-IcingaCheckResult -Check $ProcessPackage -NoPerfData $NoPerfData -Compile); } diff --git a/lib/plugins/Invoke-IcingaCheckService.psm1 b/lib/plugins/Invoke-IcingaCheckService.psm1 index 3a59d28..59975d9 100644 --- a/lib/plugins/Invoke-IcingaCheckService.psm1 +++ b/lib/plugins/Invoke-IcingaCheckService.psm1 @@ -32,40 +32,40 @@ Import-IcingaLib icinga\plugin; function Invoke-IcingaCheckService() { - param( - [array]$Service, - [ValidateSet('Stopped', 'StartPending', 'StopPending', 'Running', 'ContinuePending', 'PausePending', 'Paused')] - [string]$Status, - [ValidateSet(0, 1, 2, 3)] - [int]$Verbosity = 0 - ); + param( + [array]$Service, + [ValidateSet('Stopped', 'StartPending', 'StopPending', 'Running', 'ContinuePending', 'PausePending', 'Paused')] + [string]$Status, + [ValidateSet(0, 1, 2, 3)] + [int]$Verbosity = 0 + ); - $ServicesPackage = New-IcingaCheckPackage -Name 'Services' -OperatorAnd -Verbose $Verbosity; + $ServicesPackage = New-IcingaCheckPackage -Name 'Services' -OperatorAnd -Verbose $Verbosity; - if ($Service.Count -ne 1) { - foreach ($services in $Service) { - $IcingaCheck = $null; + if ($Service.Count -ne 1) { + foreach ($services in $Service) { + $IcingaCheck = $null; - $FoundService = Get-IcingaServices -Service $services; - $ServiceName = Get-IcingaServiceCheckName -ServiceInput $services -Service $FoundService; - $ConvertedStatus = ConvertTo-ServiceStatusCode -Status $Status; - $StatusRaw = $FoundService.Values.configuration.Status.raw; - - $IcingaCheck = New-IcingaCheck -Name $ServiceName -Value $StatusRaw -ObjectExists $FoundService -Translation $ProviderEnums.ServiceStatusName; - $IcingaCheck.CritIfNotMatch($ConvertedStatus) | Out-Null; - $ServicesPackage.AddCheck($IcingaCheck) - } - } else { + $FoundService = Get-IcingaServices -Service $services; + $ServiceName = Get-IcingaServiceCheckName -ServiceInput $services -Service $FoundService; + $ConvertedStatus = ConvertTo-ServiceStatusCode -Status $Status; + $StatusRaw = $FoundService.Values.configuration.Status.raw; + + $IcingaCheck = New-IcingaCheck -Name $ServiceName -Value $StatusRaw -ObjectExists $FoundService -Translation $ProviderEnums.ServiceStatusName; + $IcingaCheck.CritIfNotMatch($ConvertedStatus) | Out-Null; + $ServicesPackage.AddCheck($IcingaCheck) + } + } else { - $FoundService = Get-IcingaServices -Service $Service; - $ServiceName = Get-IcingaServiceCheckName -ServiceInput $Service -Service $FoundService; - $Status = ConvertTo-ServiceStatusCode -Status $Status; - $StatusRaw = $FoundService.Values.configuration.Status.raw; + $FoundService = Get-IcingaServices -Service $Service; + $ServiceName = Get-IcingaServiceCheckName -ServiceInput $Service -Service $FoundService; + $Status = ConvertTo-ServiceStatusCode -Status $Status; + $StatusRaw = $FoundService.Values.configuration.Status.raw; - $IcingaCheck = New-IcingaCheck -Name $ServiceName -Value $StatusRaw -ObjectExists $FoundService -Translation $ProviderEnums.ServiceStatusName; - $IcingaCheck.CritIfNotMatch($Status) | Out-Null; - $ServicesPackage.AddCheck($IcingaCheck); + $IcingaCheck = New-IcingaCheck -Name $ServiceName -Value $StatusRaw -ObjectExists $FoundService -Translation $ProviderEnums.ServiceStatusName; + $IcingaCheck.CritIfNotMatch($Status) | Out-Null; + $ServicesPackage.AddCheck($IcingaCheck); - } - return (New-IcingaCheckResult -Name 'Services' -Check $ServicesPackage -NoPerfData $TRUE -Compile); + } + return (New-IcingaCheckResult -Name 'Services' -Check $ServicesPackage -NoPerfData $TRUE -Compile); } diff --git a/lib/plugins/Invoke-IcingaCheckUpdates.psm1 b/lib/plugins/Invoke-IcingaCheckUpdates.psm1 index a878db4..4443e35 100644 --- a/lib/plugins/Invoke-IcingaCheckUpdates.psm1 +++ b/lib/plugins/Invoke-IcingaCheckUpdates.psm1 @@ -33,11 +33,11 @@ function Invoke-IcingaCheckUpdates() { param ( [array]$UpdateFilter, - [int]$Warning = $null, - [int]$Critical = $null, + [int]$Warning = $null, + [int]$Critical = $null, [switch]$NoPerfData, [ValidateSet(0, 1, 2, 3)] - [int]$Verbosity = 0 + [int]$Verbosity = 0 ); $PendingUpdates = Get-IcingaUpdatesPending; diff --git a/lib/plugins/Invoke-IcingaCheckUptime.psm1 b/lib/plugins/Invoke-IcingaCheckUptime.psm1 index e9ba339..f71a871 100644 --- a/lib/plugins/Invoke-IcingaCheckUptime.psm1 +++ b/lib/plugins/Invoke-IcingaCheckUptime.psm1 @@ -34,25 +34,25 @@ Import-IcingaLib core\tools; function Invoke-IcingaCheckUptime() { - param( - [string]$Warning = $null, - [string]$Critical = $null, - [switch]$NoPerfData, - [ValidateSet(0, 1, 2, 3)] - [int]$Verbosity = 0 + param( + [string]$Warning = $null, + [string]$Critical = $null, + [switch]$NoPerfData, + [ValidateSet(0, 1, 2, 3)] + [int]$Verbosity = 0 ); - $WindowsData = Get-IcingaWindows; - $Name = ([string]::Format('Windows Uptime: {0}', (ConvertFrom-TimeSpan -Seconds $WindowsData.windows.metadata.uptime.value))); + $WindowsData = Get-IcingaWindows; + $Name = ([string]::Format('Windows Uptime: {0}', (ConvertFrom-TimeSpan -Seconds $WindowsData.windows.metadata.uptime.value))); - $IcingaCheck = New-IcingaCheck -Name 'Windows Uptime' -Value $WindowsData.windows.metadata.uptime.value -Unit 's'; - $IcingaCheck.WarnOutOfRange( - (ConvertTo-SecondsFromIcingaThresholds -Threshold $Warning) - ).CritOutOfRange( - (ConvertTo-SecondsFromIcingaThresholds -Threshold $Critical) - ) | Out-Null; + $IcingaCheck = New-IcingaCheck -Name 'Windows Uptime' -Value $WindowsData.windows.metadata.uptime.value -Unit 's'; + $IcingaCheck.WarnOutOfRange( + (ConvertTo-SecondsFromIcingaThresholds -Threshold $Warning) + ).CritOutOfRange( + (ConvertTo-SecondsFromIcingaThresholds -Threshold $Critical) + ) | Out-Null; - $CheckPackage = New-IcingaCheckPackage -Name $Name -OperatorAnd -Checks $IcingaCheck -Verbose $Verbosity; + $CheckPackage = New-IcingaCheckPackage -Name $Name -OperatorAnd -Checks $IcingaCheck -Verbose $Verbosity; - return (New-IcingaCheckresult -Check $CheckPackage -NoPerfData $NoPerfData -Compile); + return (New-IcingaCheckresult -Check $CheckPackage -NoPerfData $NoPerfData -Compile); } diff --git a/lib/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 b/lib/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 index 6cbcbd5..bfb3ca3 100644 --- a/lib/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 +++ b/lib/plugins/Invoke-IcingaCheckUsedPartitionSpace.psm1 @@ -44,39 +44,39 @@ Import-IcingaLib icinga\plugin; function Invoke-IcingaCheckUsedPartitionSpace() { - param( - [int]$Warning = $null, - [int]$Critical = $null, - [array]$Include = @(), - [array]$Exclude = @(), - [switch]$NoPerfData, - [ValidateSet(0, 1, 2, 3)] - [int]$Verbosity = 0 - ); + param( + [int]$Warning = $null, + [int]$Critical = $null, + [array]$Include = @(), + [array]$Exclude = @(), + [switch]$NoPerfData, + [ValidateSet(0, 1, 2, 3)] + [int]$Verbosity = 0 + ); - $DiskFree = Get-IcingaDiskPartitions; - $DiskPackage = New-IcingaCheckPackage -Name 'Used Partition Space' -OperatorAnd -Verbos $Verbosity; + $DiskFree = Get-IcingaDiskPartitions; + $DiskPackage = New-IcingaCheckPackage -Name 'Used Partition Space' -OperatorAnd -Verbos $Verbosity; - foreach ($Letter in $DiskFree.Keys) { - if ($Include.Count -ne 0) { - $Include = $Include.trim(' :/\'); - if (-Not ($Include.Contains($Letter))) { - continue; - } - } + foreach ($Letter in $DiskFree.Keys) { + if ($Include.Count -ne 0) { + $Include = $Include.trim(' :/\'); + if (-Not ($Include.Contains($Letter))) { + continue; + } + } - if ($Exclude.Count -ne 0) { - $Exclude = $Exclude.trim(' :/\'); - if ($Exclude.Contains($Letter)) { - continue; - } - } + if ($Exclude.Count -ne 0) { + $Exclude = $Exclude.trim(' :/\'); + if ($Exclude.Contains($Letter)) { + continue; + } + } - $IcingaCheck = New-IcingaCheck -Name ([string]::Format('Partition {0}', $Letter)) -Value (100-($DiskFree.([string]::Format($Letter))."Free Space")) -Unit '%'; - $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; - $DiskPackage.AddCheck($IcingaCheck); - } + $IcingaCheck = New-IcingaCheck -Name ([string]::Format('Partition {0}', $Letter)) -Value (100-($DiskFree.([string]::Format($Letter))."Free Space")) -Unit '%'; + $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; + $DiskPackage.AddCheck($IcingaCheck); + } - return (New-IcingaCheckResult -Check $DiskPackage -NoPerfData $NoPerfData -Compile); + return (New-IcingaCheckResult -Check $DiskPackage -NoPerfData $NoPerfData -Compile); } diff --git a/lib/plugins/Invoke-IcingaCheckUsers.psm1 b/lib/plugins/Invoke-IcingaCheckUsers.psm1 index 3139e9f..4a13833 100644 --- a/lib/plugins/Invoke-IcingaCheckUsers.psm1 +++ b/lib/plugins/Invoke-IcingaCheckUsers.psm1 @@ -37,39 +37,39 @@ function Invoke-IcingaCheckUsers() { param ( [array]$Username, - [int]$Warning = $null, - [int]$Critical = $null, + [int]$Warning = $null, + [int]$Critical = $null, [switch]$NoPerfData, [ValidateSet(0, 1, 2, 3)] - [int]$Verbosity = 0 + [int]$Verbosity = 0 ); - - $UsersPackage = New-IcingaCheckPackage -Name 'Users' -OperatorAnd -Verbose $Verbosity; - $LoggedOnUsers = Get-IcingaLoggedOnUsers -UserFilter $Username; - if ($Username.Count -ne 0) { - foreach ($User in $Username) { - $IcingaCheck = $null; - [int]$LoginCount = 0; + $UsersPackage = New-IcingaCheckPackage -Name 'Users' -OperatorAnd -Verbose $Verbosity; + $LoggedOnUsers = Get-IcingaLoggedOnUsers -UserFilter $Username; - if ($LoggedOnUsers.users.ContainsKey($User)) { - $LoginCount = $LoggedOnUsers.users.$User.count; - } + if ($Username.Count -ne 0) { + foreach ($User in $Username) { + $IcingaCheck = $null; + [int]$LoginCount = 0; - $IcingaCheck = New-IcingaCheck -Name ([string]::Format('Logged On User "{0}"', $User)) -Value $LoginCount; - $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; - $UsersPackage.AddCheck($IcingaCheck); - } - } else { - foreach ($User in $LoggedOnUsers.users.Keys) { - $UsersPackage.AddCheck( - (New-IcingaCheck -Name ([string]::Format('Logged On User "{0}"', $User)) -Value $LoggedOnUsers.users.$User.count) - ); - } - $IcingaCheck = New-IcingaCheck -Name 'Logged On Users' -Value $LoggedOnUsers.count; - $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; - $UsersPackage.AddCheck($IcingaCheck) - } - - return (New-IcingaCheckResult -Name 'Users' -Check $UsersPackage -NoPerfData $NoPerfData -Compile); + if ($LoggedOnUsers.users.ContainsKey($User)) { + $LoginCount = $LoggedOnUsers.users.$User.count; + } + + $IcingaCheck = New-IcingaCheck -Name ([string]::Format('Logged On User "{0}"', $User)) -Value $LoginCount; + $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; + $UsersPackage.AddCheck($IcingaCheck); + } + } else { + foreach ($User in $LoggedOnUsers.users.Keys) { + $UsersPackage.AddCheck( + (New-IcingaCheck -Name ([string]::Format('Logged On User "{0}"', $User)) -Value $LoggedOnUsers.users.$User.count) + ); + } + $IcingaCheck = New-IcingaCheck -Name 'Logged On Users' -Value $LoggedOnUsers.count; + $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null; + $UsersPackage.AddCheck($IcingaCheck) + } + + return (New-IcingaCheckResult -Name 'Users' -Check $UsersPackage -NoPerfData $NoPerfData -Compile); }