Fixes code styling

This commit is contained in:
Lord Hepipud 2019-10-29 10:47:24 +01:00
parent d170b69721
commit 9d6968595f
10 changed files with 159 additions and 159 deletions

View file

@ -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));

View file

@ -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);
}

View file

@ -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;

View file

@ -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;

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}