mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-21 07:10:15 -05:00
Fixes various code stylings, whitespaces, line handling, and so on
This commit is contained in:
parent
76f27caba4
commit
ac02ec7e3e
69 changed files with 752 additions and 737 deletions
|
|
@ -18,7 +18,7 @@ function Get-IcingaWindowsInformation()
|
|||
|
||||
if ($ForceWMI -eq $FALSE -And (Get-Command 'Get-CimInstance' -ErrorAction SilentlyContinue)) {
|
||||
try {
|
||||
return (Get-CimInstance @Arguments -ErrorAction Stop)
|
||||
return (Get-CimInstance @Arguments -ErrorAction Stop);
|
||||
} catch {
|
||||
$ErrorName = $_.Exception.NativeErrorCode;
|
||||
$ErrorMessage = $_.Exception.Message;
|
||||
|
|
@ -43,7 +43,7 @@ function Get-IcingaWindowsInformation()
|
|||
|
||||
if ((Get-Command 'Get-WmiObject' -ErrorAction SilentlyContinue)) {
|
||||
try {
|
||||
return (Get-WmiObject @Arguments -ErrorAction Stop)
|
||||
return (Get-WmiObject @Arguments -ErrorAction Stop);
|
||||
} catch {
|
||||
$ErrorName = $_.CategoryInfo.Category;
|
||||
$ErrorMessage = $_.Exception.Message;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@ function Invoke-IcingaNamespaceCmdlets()
|
|||
Import-Module $Cmdlet.Module.Path -WarningAction SilentlyContinue -ErrorAction Stop;
|
||||
|
||||
$Content = (& $CmmandName);
|
||||
Add-IcingaHashtableItem -Hashtable $CommandConfig `
|
||||
Add-IcingaHashtableItem `
|
||||
-Hashtable $CommandConfig `
|
||||
-Key $Cmdlet.Name `
|
||||
-Value $Content | Out-Null;
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ function Restart-IcingaService()
|
|||
|
||||
Restart-Service "$Service";
|
||||
} -Args $Service;
|
||||
|
||||
} else {
|
||||
Write-IcingaConsoleWarning -Message 'The service "{0}" is not installed' -Objects $Service;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,10 +36,12 @@ function Start-IcingaTimer()
|
|||
$TimerObject = New-Object System.Diagnostics.Stopwatch;
|
||||
$TimerObject.Start();
|
||||
|
||||
Add-IcingaHashtableItem -Key $Name -Value ([hashtable]::Synchronized(
|
||||
Add-IcingaHashtableItem -Key $Name -Value (
|
||||
[hashtable]::Synchronized(
|
||||
@{
|
||||
'Active' = $TRUE;
|
||||
'Timer' = $TimerObject;
|
||||
}
|
||||
)) -Hashtable $global:IcingaDaemonData.IcingaTimers -Override | Out-Null;
|
||||
)
|
||||
) -Hashtable $global:IcingaDaemonData.IcingaTimers -Override | Out-Null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,10 +35,12 @@ function Stop-IcingaTimer()
|
|||
if ($TimerObject.IsRunning) {
|
||||
$TimerObject.Stop();
|
||||
}
|
||||
Add-IcingaHashtableItem -Key $Name -Value ([hashtable]::Synchronized(
|
||||
Add-IcingaHashtableItem -Key $Name -Value (
|
||||
[hashtable]::Synchronized(
|
||||
@{
|
||||
'Active' = $FALSE;
|
||||
'Timer' = $TimerObject;
|
||||
}
|
||||
)) -Hashtable $global:IcingaDaemonData.IcingaTimers -Override | Out-Null;
|
||||
)
|
||||
) -Hashtable $global:IcingaDaemonData.IcingaTimers -Override | Out-Null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,15 +3,19 @@ function Get-IcingaAgentFeatures()
|
|||
$Binary = Get-IcingaAgentBinary;
|
||||
$ConfigResult = Start-IcingaProcess -Executable $Binary -Arguments 'feature list';
|
||||
|
||||
$DisabledFeatures = ($ConfigResult.Message.SubString(
|
||||
$DisabledFeatures = (
|
||||
$ConfigResult.Message.SubString(
|
||||
0,
|
||||
$ConfigResult.Message.IndexOf('Enabled features')
|
||||
)).Replace('Disabled features: ', '').Replace("`r`n", '').Replace("`r", '').Replace("`n", '');
|
||||
)
|
||||
).Replace('Disabled features: ', '').Replace("`r`n", '').Replace("`r", '').Replace("`n", '');
|
||||
|
||||
$EnabledFeatures = ($ConfigResult.Message.SubString(
|
||||
$EnabledFeatures = (
|
||||
$ConfigResult.Message.SubString(
|
||||
$ConfigResult.Message.IndexOf('Enabled features'),
|
||||
$ConfigResult.Message.Length - $ConfigResult.Message.IndexOf('Enabled features')
|
||||
)).Replace('Enabled features: ', '').Replace("`r`n", '').Replace("`r", '').Replace("`n", '');
|
||||
)
|
||||
).Replace('Enabled features: ', '').Replace("`r`n", '').Replace("`r", '').Replace("`n", '');
|
||||
|
||||
return @{
|
||||
'Enabled' = ($EnabledFeatures.Split(' '));
|
||||
|
|
|
|||
|
|
@ -29,11 +29,13 @@ function Install-IcingaAgent()
|
|||
}
|
||||
$IcingaInstaller.Version = 'snapshot';
|
||||
} elseif ($IcingaInstaller.Version -eq $InstalledVersion.Full) {
|
||||
Write-IcingaConsoleNotice ([string]::Format(
|
||||
Write-IcingaConsoleNotice (
|
||||
[string]::Format(
|
||||
'No installation required. Your installed version [{0}] is matching the online version [{1}]',
|
||||
$InstalledVersion.Full,
|
||||
$IcingaInstaller.Version
|
||||
));
|
||||
)
|
||||
);
|
||||
return $FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -563,11 +563,15 @@ function Start-IcingaAgentInstallWizard()
|
|||
Write-IcingaAgentApiConfig -Port $CAPort;
|
||||
if ($EmptyCA -eq $TRUE -Or $CertsInstalled -eq $FALSE) {
|
||||
Disable-IcingaAgentFeature 'api';
|
||||
Write-IcingaConsoleWarning -Message '{0}{1}{2}{3}{4}' -Objects 'Your Icinga Agent API feature has been disabled. Please provide either your ca.crt ',
|
||||
Write-IcingaConsoleWarning `
|
||||
-Message '{0}{1}{2}{3}{4}' `
|
||||
-Objects (
|
||||
'Your Icinga Agent API feature has been disabled. Please provide either your ca.crt ',
|
||||
'or connect to a parent node for certificate requests. You can run "Install-IcingaAgentCertificates" ',
|
||||
'with your configuration to properly create the host certificate and a valid certificate request. ',
|
||||
'After this you can enable the API feature by using "Enable-IcingaAgentFeature api" and restart the ',
|
||||
'Icinga Agent service "Restart-IcingaService icinga2"';
|
||||
'Icinga Agent service "Restart-IcingaService icinga2"'
|
||||
);
|
||||
}
|
||||
Write-IcingaAgentZonesConfig -Endpoints $Endpoints -EndpointConnections $EndpointConnections -ParentZone $ParentZone -GlobalZones $GlobalZoneConfig -Hostname $Hostname;
|
||||
if ($AddFirewallRule) {
|
||||
|
|
|
|||
|
|
@ -13,14 +13,14 @@
|
|||
);
|
||||
|
||||
$pc_instance = New-Object -TypeName PSObject;
|
||||
$pc_instance | Add-Member -membertype NoteProperty -name 'FullName' -value $FullName;
|
||||
$pc_instance | Add-Member -membertype NoteProperty -name 'ErrorMessage' -value $ErrorMessage;
|
||||
$pc_instance | Add-Member -MemberType NoteProperty -Name 'FullName' -Value $FullName;
|
||||
$pc_instance | Add-Member -MemberType NoteProperty -Name 'ErrorMessage' -Value $ErrorMessage;
|
||||
|
||||
$pc_instance | Add-Member -membertype ScriptMethod -name 'Name' -value {
|
||||
$pc_instance | Add-Member -MemberType ScriptMethod -Name 'Name' -Value {
|
||||
return $this.FullName;
|
||||
}
|
||||
|
||||
$pc_instance | Add-Member -membertype ScriptMethod -name 'Value' -value {
|
||||
$pc_instance | Add-Member -MemberType ScriptMethod -Name 'Value' -Value {
|
||||
[hashtable]$ErrorMessage = @{};
|
||||
|
||||
$ErrorMessage.Add('value', $null);
|
||||
|
|
@ -34,4 +34,3 @@
|
|||
|
||||
return $pc_instance;
|
||||
}
|
||||
|
||||
|
|
@ -20,14 +20,14 @@
|
|||
);
|
||||
|
||||
$pc_instance = New-Object -TypeName PSObject;
|
||||
$pc_instance | Add-Member -membertype NoteProperty -name 'FullName' -value $FullName;
|
||||
$pc_instance | Add-Member -membertype NoteProperty -name 'Category' -value $Category;
|
||||
$pc_instance | Add-Member -membertype NoteProperty -name 'Instance' -value $Instance;
|
||||
$pc_instance | Add-Member -membertype NoteProperty -name 'Counter' -value $Counter;
|
||||
$pc_instance | Add-Member -membertype NoteProperty -name 'PerfCounter' -value $Counter;
|
||||
$pc_instance | Add-Member -membertype NoteProperty -name 'SkipWait' -value $SkipWait;
|
||||
$pc_instance | Add-Member -MemberType NoteProperty -Name 'FullName' -Value $FullName;
|
||||
$pc_instance | Add-Member -MemberType NoteProperty -Name 'Category' -Value $Category;
|
||||
$pc_instance | Add-Member -MemberType NoteProperty -Name 'Instance' -Value $Instance;
|
||||
$pc_instance | Add-Member -MemberType NoteProperty -Name 'Counter' -Value $Counter;
|
||||
$pc_instance | Add-Member -MemberType NoteProperty -Name 'PerfCounter' -Value $Counter;
|
||||
$pc_instance | Add-Member -MemberType NoteProperty -Name 'SkipWait' -Value $SkipWait;
|
||||
|
||||
$pc_instance | Add-Member -membertype ScriptMethod -name 'Init' -value {
|
||||
$pc_instance | Add-Member -MemberType ScriptMethod -Name 'Init' -Value {
|
||||
|
||||
Write-IcingaConsoleDebug `
|
||||
-Message 'Creating new Counter for Category "{0}" with Instance "{1}" and Counter "{2}". Full Name "{3}"' `
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
}
|
||||
|
||||
# Return the name of the counter as string
|
||||
$pc_instance | Add-Member -membertype ScriptMethod -name 'Name' -value {
|
||||
$pc_instance | Add-Member -MemberType ScriptMethod -Name 'Name' -Value {
|
||||
return $this.FullName;
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@
|
|||
# Sample values for the counter itself. In case we run into an error,
|
||||
# keep the counter construct but add an error message in addition.
|
||||
#>
|
||||
$pc_instance | Add-Member -membertype ScriptMethod -name 'Value' -value {
|
||||
$pc_instance | Add-Member -MemberType ScriptMethod -Name 'Value' -Value {
|
||||
[hashtable]$CounterData = @{};
|
||||
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@
|
|||
);
|
||||
|
||||
$pc_instance = New-Object -TypeName PSObject;
|
||||
$pc_instance | Add-Member -membertype NoteProperty -name 'FullName' -value $FullName;
|
||||
$pc_instance | Add-Member -membertype NoteProperty -name 'Counters' -value $PerformanceCounters;
|
||||
$pc_instance | Add-Member -MemberType NoteProperty -Name 'FullName' -Value $FullName;
|
||||
$pc_instance | Add-Member -MemberType NoteProperty -Name 'Counters' -Value $PerformanceCounters;
|
||||
|
||||
$pc_instance | Add-Member -membertype ScriptMethod -name 'Name' -value {
|
||||
$pc_instance | Add-Member -MemberType ScriptMethod -Name 'Name' -Value {
|
||||
return $this.FullName;
|
||||
}
|
||||
|
||||
$pc_instance | Add-Member -membertype ScriptMethod -name 'Value' -value {
|
||||
$pc_instance | Add-Member -MemberType ScriptMethod -Name 'Value' -Value {
|
||||
[hashtable]$CounterResults = @{};
|
||||
|
||||
foreach ($counter in $this.Counters) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
#
|
||||
function Show-IcingaPerformanceCounterCategories()
|
||||
{
|
||||
$RegistryData = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009' `
|
||||
$RegistryData = Get-ItemProperty `
|
||||
-Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009' `
|
||||
-Name 'counter' | Select-Object -ExpandProperty Counter;
|
||||
[array]$Counters = @();
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ function Convert-Bytes()
|
|||
{ 'KB', 'MB', 'GB', 'TB', 'PB' -contains $_ } { $CurrentValue = ConvertTo-ByteSI $CurrentValue $CurrentUnit; $boolOption = $true; }
|
||||
}
|
||||
|
||||
|
||||
switch ($Unit) {
|
||||
{ 'B' -contains $_ } { $FinalValue = $CurrentValue; $boolOption = $true; }
|
||||
{ 'KB' -contains $_ } { $FinalValue = ConvertTo-Kilobyte $CurrentValue -Unit B; $boolOption = $true; }
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@
|
|||
function Get-IcingaCheckCommandConfig()
|
||||
{
|
||||
param(
|
||||
[Parameter(ValueFromPipeline)]
|
||||
[array]$CheckName,
|
||||
[string]$OutDirectory
|
||||
);
|
||||
|
|
@ -159,8 +158,8 @@ function Get-IcingaCheckCommandConfig()
|
|||
|
||||
$Basket.Command[$Data.Name].vars.Add($parameter.Name, $FALSE);
|
||||
|
||||
# Conditional whether type of parameter is array
|
||||
} elseif ($parameter.type.name -eq 'Array') {
|
||||
# Conditional whether type of parameter is array
|
||||
$Basket.Command[$Data.Name].arguments.Add(
|
||||
[string]::Format('-{0}', $parameter.Name), @{
|
||||
'value' = @{
|
||||
|
|
|
|||
|
|
@ -59,26 +59,19 @@ function Get-IcingaNetworkInterface()
|
|||
foreach ($destinationIP in $IPBinStringMaster) {
|
||||
[string]$Key = '';
|
||||
[string]$MaskKey = '';
|
||||
############################################################################
|
||||
################################ IPv4 ####################################
|
||||
############################################################################
|
||||
<# IPv4 #>
|
||||
if ($destinationIP.name -eq 'IPv4') {
|
||||
if ($IP -like '*.*') {
|
||||
############################################################################
|
||||
if ([int]$Mask -lt 10) {
|
||||
$MaskKey = [string]::Format('00{0}', $Mask);
|
||||
} else {
|
||||
$MaskKey = [string]::Format('0{0}', $Mask);
|
||||
}
|
||||
############################################################################
|
||||
}
|
||||
}
|
||||
############################################################################
|
||||
################################ IPv6 ####################################
|
||||
############################################################################
|
||||
<# IPv6 #>
|
||||
if ($destinationIP.name -eq 'IPv6') {
|
||||
if ($IP -like '*:*') {
|
||||
############################################################################
|
||||
if ([int]$Mask -lt 10) {
|
||||
$MaskKey = [string]::Format('00{0}', $Mask);
|
||||
} elseif ([int]$Mask -lt 100) {
|
||||
|
|
@ -86,7 +79,6 @@ function Get-IcingaNetworkInterface()
|
|||
} else {
|
||||
$MaskKey = $Mask;
|
||||
}
|
||||
############################################################################
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +136,7 @@ function Get-IcingaNetworkInterface()
|
|||
|
||||
if ($ExternalInterfaces.Count -eq 0) {
|
||||
foreach ($destinationIP in $IPBinStringMaster) {
|
||||
$ExternalInterface = ((Get-NetIPAddress -InterfaceIndex (Get-NetRoute | Where-Object -Property DestinationPrefix -like '0.0.0.0/0')[0].IfIndex -AddressFamily $destinationIP.name).IPAddress).split('%')[0];
|
||||
$ExternalInterface = ((Get-NetIPAddress -InterfaceIndex (Get-NetRoute | Where-Object -Property DestinationPrefix -Like '0.0.0.0/0')[0].IfIndex -AddressFamily $destinationIP.name).IPAddress).split('%')[0];
|
||||
if ($ExternalInterfaces.ContainsKey($ExternalInterface)) {
|
||||
$ExternalInterfaces[$ExternalInterface].count += 1;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -15,35 +15,35 @@ function New-IcingaCheck()
|
|||
);
|
||||
|
||||
$Check = New-Object -TypeName PSObject;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'name' -value $Name;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'verbose' -value 0;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'messages' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'oks' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'warnings' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'criticals' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'unknowns' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'okchecks' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'warningchecks' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'criticalchecks' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'unknownchecks' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'value' -value $Value;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'exitcode' -value -1;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'unit' -value $Unit;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'spacing' -value 0;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'compiled' -value $FALSE;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'perfdata' -value (-Not $NoPerfData);
|
||||
$Check | Add-Member -membertype NoteProperty -name 'warning' -value '';
|
||||
$Check | Add-Member -membertype NoteProperty -name 'critical' -value '';
|
||||
$Check | Add-Member -membertype NoteProperty -name 'minimum' -value $Minimum;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'maximum' -value $Maximum;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'objectexists' -value $ObjectExists;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'translation' -value $Translation;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'checks' -value $null;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'completed' -value $FALSE;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'checkcommand' -value '';
|
||||
$Check | Add-Member -membertype NoteProperty -name 'checkpackage' -value $FALSE;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'name' -Value $Name;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'verbose' -Value 0;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'messages' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'oks' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'warnings' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'criticals' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'unknowns' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'okchecks' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'warningchecks' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'criticalchecks' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'unknownchecks' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'value' -Value $Value;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'exitcode' -Value -1;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'unit' -Value $Unit;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'spacing' -Value 0;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'compiled' -Value $FALSE;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'perfdata' -Value (-Not $NoPerfData);
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'warning' -Value '';
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'critical' -Value '';
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'minimum' -Value $Minimum;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'maximum' -Value $Maximum;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'objectexists' -Value $ObjectExists;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'translation' -Value $Translation;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'checks' -Value $null;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'completed' -Value $FALSE;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'checkcommand' -Value '';
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'checkpackage' -Value $FALSE;
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'HandleDaemon' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'HandleDaemon' -Value {
|
||||
# Only apply this once the checkcommand is set
|
||||
if ([string]::IsNullOrEmpty($this.checkcommand) -Or $global:IcingaDaemonData.FrameworkRunningAsDaemon -eq $FALSE) {
|
||||
return;
|
||||
|
|
@ -71,30 +71,30 @@ function New-IcingaCheck()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AddSpacing' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AddSpacing' -Value {
|
||||
$this.spacing += 1;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AssignCheckCommand' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AssignCheckCommand' -Value {
|
||||
param($CheckCommand);
|
||||
|
||||
$this.checkcommand = $CheckCommand;
|
||||
$this.HandleDaemon();
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetWarnings' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetWarnings' -Value {
|
||||
return $this.warningchecks;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetCriticals' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetCriticals' -Value {
|
||||
return $this.criticalchecks;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetUnknowns' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetUnknowns' -Value {
|
||||
return $this.unknownchecks;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'SetUnknown' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'SetUnknown' -Value {
|
||||
$this.AddInternalCheckMessage(
|
||||
$IcingaEnums.IcingaExitCode.Unknown,
|
||||
$null,
|
||||
|
|
@ -104,7 +104,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'SetWarning' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'SetWarning' -Value {
|
||||
$this.AddInternalCheckMessage(
|
||||
$IcingaEnums.IcingaExitCode.Warning,
|
||||
$null,
|
||||
|
|
@ -114,7 +114,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnOutOfRange' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnOutOfRange' -Value {
|
||||
param($warning);
|
||||
|
||||
if ([string]::IsNullOrEmpty($warning)) {
|
||||
|
|
@ -156,7 +156,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnIfLike' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnIfLike' -Value {
|
||||
param($warning);
|
||||
|
||||
if ($this.value -Like $warning) {
|
||||
|
|
@ -172,7 +172,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnIfNotLike' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnIfNotLike' -Value {
|
||||
param($warning);
|
||||
|
||||
if (-Not ($this.value -Like $warning)) {
|
||||
|
|
@ -188,7 +188,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnIfMatch' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnIfMatch' -Value {
|
||||
param($warning);
|
||||
|
||||
if ($this.value -eq $warning) {
|
||||
|
|
@ -204,7 +204,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnIfNotMatch' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnIfNotMatch' -Value {
|
||||
param($warning);
|
||||
|
||||
if ($this.value -ne $warning) {
|
||||
|
|
@ -220,7 +220,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnIfBetweenAndEqual' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnIfBetweenAndEqual' -Value {
|
||||
param($min, $max);
|
||||
|
||||
if ($this.value -ge $min -And $this.value -le $max) {
|
||||
|
|
@ -236,7 +236,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnIfBetween' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnIfBetween' -Value {
|
||||
param($min, $max);
|
||||
|
||||
if ($this.value -gt $min -And $this.value -lt $max) {
|
||||
|
|
@ -252,7 +252,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnIfLowerThan' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnIfLowerThan' -Value {
|
||||
param($warning);
|
||||
|
||||
if ($this.value -lt $warning) {
|
||||
|
|
@ -268,7 +268,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnIfLowerEqualThan' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnIfLowerEqualThan' -Value {
|
||||
param($warning);
|
||||
|
||||
if ($this.value -le $warning) {
|
||||
|
|
@ -284,7 +284,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnIfGreaterThan' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnIfGreaterThan' -Value {
|
||||
param($warning);
|
||||
|
||||
if ($this.value -gt $warning) {
|
||||
|
|
@ -300,7 +300,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WarnIfGreaterEqualThan' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WarnIfGreaterEqualThan' -Value {
|
||||
param($warning);
|
||||
|
||||
if ($this.value -ge $warning) {
|
||||
|
|
@ -316,7 +316,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'SetCritical' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'SetCritical' -Value {
|
||||
$this.AddInternalCheckMessage(
|
||||
$IcingaEnums.IcingaExitCode.Critical,
|
||||
$null,
|
||||
|
|
@ -326,7 +326,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritOutOfRange' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritOutOfRange' -Value {
|
||||
param($critical);
|
||||
|
||||
if ([string]::IsNullOrEmpty($critical)) {
|
||||
|
|
@ -368,7 +368,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritIfLike' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritIfLike' -Value {
|
||||
param($critical);
|
||||
|
||||
if ($this.value -Like $critical) {
|
||||
|
|
@ -384,7 +384,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritIfNotLike' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritIfNotLike' -Value {
|
||||
param($critical);
|
||||
|
||||
if (-Not ($this.value -Like $critical)) {
|
||||
|
|
@ -400,7 +400,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritIfMatch' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritIfMatch' -Value {
|
||||
param($critical);
|
||||
|
||||
if ($this.value -eq $critical) {
|
||||
|
|
@ -416,7 +416,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritIfNotMatch' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritIfNotMatch' -Value {
|
||||
param($critical);
|
||||
|
||||
if ($this.value -ne $critical) {
|
||||
|
|
@ -432,7 +432,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritIfBetweenAndEqual' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritIfBetweenAndEqual' -Value {
|
||||
param($min, $max);
|
||||
|
||||
if ($this.value -ge $min -And $this.value -le $max) {
|
||||
|
|
@ -448,7 +448,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritIfBetween' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritIfBetween' -Value {
|
||||
param($min, $max);
|
||||
|
||||
if ($this.value -gt $min -And $this.value -lt $max) {
|
||||
|
|
@ -464,7 +464,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritIfLowerThan' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritIfLowerThan' -Value {
|
||||
param($critical);
|
||||
|
||||
if ($this.value -lt $critical) {
|
||||
|
|
@ -480,7 +480,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritIfLowerEqualThan' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritIfLowerEqualThan' -Value {
|
||||
param($critical);
|
||||
|
||||
if ($this.value -le $critical) {
|
||||
|
|
@ -496,7 +496,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritIfGreaterThan' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritIfGreaterThan' -Value {
|
||||
param($critical);
|
||||
|
||||
if ($this.value -gt $critical) {
|
||||
|
|
@ -512,7 +512,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CritIfGreaterEqualThan' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CritIfGreaterEqualThan' -Value {
|
||||
param($critical);
|
||||
|
||||
if ($this.value -ge $critical) {
|
||||
|
|
@ -528,7 +528,7 @@ function New-IcingaCheck()
|
|||
return $this;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'TranslateValue' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'TranslateValue' -Value {
|
||||
param($value);
|
||||
|
||||
$value = Format-IcingaPerfDataValue $value;
|
||||
|
|
@ -552,14 +552,17 @@ function New-IcingaCheck()
|
|||
return $value;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AddInternalCheckMessage' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AddInternalCheckMessage' -Value {
|
||||
param($state, $value, $type);
|
||||
|
||||
if ($this.objectexists -ne -1 -And $null -eq $this.objectexists) {
|
||||
$this.SetExitCode($IcingaEnums.IcingaExitCode.Unknown);
|
||||
$this.AddMessage([string]::Format(
|
||||
$this.AddMessage(
|
||||
[string]::Format(
|
||||
'{0} does not exist', $this.name
|
||||
), $IcingaEnums.IcingaExitCode.Unknown);
|
||||
),
|
||||
$IcingaEnums.IcingaExitCode.Unknown
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -596,7 +599,7 @@ function New-IcingaCheck()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AddMessage' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AddMessage' -Value {
|
||||
param($message, [int]$exitcode);
|
||||
|
||||
[string]$outputMessage = [string]::Format(
|
||||
|
|
@ -626,7 +629,7 @@ function New-IcingaCheck()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AddCheckStateArrays' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AddCheckStateArrays' -Value {
|
||||
switch ([int]$this.exitcode) {
|
||||
$IcingaEnums.IcingaExitCode.Ok {
|
||||
$this.okchecks += $this.name;
|
||||
|
|
@ -647,27 +650,27 @@ function New-IcingaCheck()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'PrintOkMessages' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'PrintOkMessages' -Value {
|
||||
param([string]$spaces);
|
||||
$this.OutputMessageArray($this.oks, $spaces);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'PrintWarningMessages' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'PrintWarningMessages' -Value {
|
||||
param([string]$spaces);
|
||||
$this.OutputMessageArray($this.warnings, $spaces);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'PrintCriticalMessages' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'PrintCriticalMessages' -Value {
|
||||
param([string]$spaces);
|
||||
$this.OutputMessageArray($this.criticals, $spaces);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'PrintUnknownMessages' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'PrintUnknownMessages' -Value {
|
||||
param([string]$spaces);
|
||||
$this.OutputMessageArray($this.unknowns, $spaces);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'PrintAllMessages' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'PrintAllMessages' -Value {
|
||||
[string]$spaces = New-StringTree $this.spacing;
|
||||
$this.OutputMessageArray($this.unknowns, $spaces);
|
||||
$this.OutputMessageArray($this.criticals, $spaces);
|
||||
|
|
@ -675,7 +678,7 @@ function New-IcingaCheck()
|
|||
$this.OutputMessageArray($this.oks, $spaces);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'OutputMessageArray' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'OutputMessageArray' -Value {
|
||||
param($msgArray, [string]$spaces);
|
||||
|
||||
foreach ($msg in $msgArray) {
|
||||
|
|
@ -683,7 +686,7 @@ function New-IcingaCheck()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'PrintOutputMessages' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'PrintOutputMessages' -Value {
|
||||
[string]$spaces = New-StringTree $this.spacing;
|
||||
if ($this.unknowns.Count -ne 0) {
|
||||
$this.PrintUnknownMessages($spaces);
|
||||
|
|
@ -698,7 +701,7 @@ function New-IcingaCheck()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'SetExitCode' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'SetExitCode' -Value {
|
||||
param([int]$code);
|
||||
|
||||
# Only overwrite the exit code in case our new value is greater then
|
||||
|
|
@ -729,7 +732,7 @@ function New-IcingaCheck()
|
|||
$this.exitcode = $code;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'ValidateUnit' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'ValidateUnit' -Value {
|
||||
if ($null -ne $this.unit -And (-Not $IcingaEnums.IcingaMeasurementUnits.ContainsKey($this.unit))) {
|
||||
$this.AddMessage(
|
||||
[string]::Format(
|
||||
|
|
@ -745,7 +748,7 @@ function New-IcingaCheck()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AddOkOutput' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AddOkOutput' -Value {
|
||||
if ([int]$this.exitcode -eq -1) {
|
||||
$this.exitcode = $IcingaEnums.IcingaExitCode.Ok;
|
||||
$this.AddMessage(
|
||||
|
|
@ -760,7 +763,7 @@ function New-IcingaCheck()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'SilentCompile' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'SilentCompile' -Value {
|
||||
if ($this.compiled) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -770,7 +773,7 @@ function New-IcingaCheck()
|
|||
$this.AddCheckStateArrays();
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'Compile' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'Compile' -Value {
|
||||
param([bool]$Verbose = $FALSE);
|
||||
|
||||
if ($this.compiled) {
|
||||
|
|
@ -789,7 +792,7 @@ function New-IcingaCheck()
|
|||
return $this.exitcode;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetPerfData' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetPerfData' -Value {
|
||||
|
||||
if ($this.completed -Or -Not $this.perfdata) {
|
||||
return $null;
|
||||
|
|
@ -818,7 +821,7 @@ function New-IcingaCheck()
|
|||
return $perfdata;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AutodiscoverMinMax' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AutodiscoverMinMax' -Value {
|
||||
if ([string]::IsNullOrEmpty($this.minimum) -eq $FALSE -Or [string]::IsNullOrEmpty($this.maximum) -eq $FALSE) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,27 +16,27 @@ function New-IcingaCheckPackage()
|
|||
);
|
||||
|
||||
$Check = New-Object -TypeName PSObject;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'name' -value $Name;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'exitcode' -value -1;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'verbose' -value $Verbose;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'hidden' -value $Hidden;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'checks' -value $Checks;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'opand' -value $OperatorAnd;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'opor' -value $OperatorOr;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'opnone' -value $OperatorNone;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'opmin' -value $OperatorMin;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'opmax' -value $OperatorMax;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'spacing' -value 0;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'compiled' -value $FALSE;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'perfdata' -value $FALSE;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'checkcommand' -value '';
|
||||
$Check | Add-Member -membertype NoteProperty -name 'headermsg' -value '';
|
||||
$Check | Add-Member -membertype NoteProperty -name 'checkpackage' -value $TRUE;
|
||||
$Check | Add-Member -membertype NoteProperty -name 'warningchecks' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'criticalchecks' -value @();
|
||||
$Check | Add-Member -membertype NoteProperty -name 'unknownchecks' -value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'name' -Value $Name;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'exitcode' -Value -1;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'verbose' -Value $Verbose;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'hidden' -Value $Hidden;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'checks' -Value $Checks;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'opand' -Value $OperatorAnd;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'opor' -Value $OperatorOr;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'opnone' -Value $OperatorNone;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'opmin' -Value $OperatorMin;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'opmax' -Value $OperatorMax;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'spacing' -Value 0;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'compiled' -Value $FALSE;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'perfdata' -Value $FALSE;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'checkcommand' -Value '';
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'headermsg' -Value '';
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'checkpackage' -Value $TRUE;
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'warningchecks' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'criticalchecks' -Value @();
|
||||
$Check | Add-Member -MemberType NoteProperty -Name 'unknownchecks' -Value @();
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'HasChecks' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'HasChecks' -Value {
|
||||
if ($this.checks -ne 0) {
|
||||
return $TRUE
|
||||
}
|
||||
|
|
@ -44,13 +44,13 @@ function New-IcingaCheckPackage()
|
|||
return $FALSE;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'Initialise' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'Initialise' -Value {
|
||||
foreach ($check in $this.checks) {
|
||||
$this.InitCheck($check);
|
||||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'InitCheck' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'InitCheck' -Value {
|
||||
param($check);
|
||||
|
||||
if ($null -eq $check) {
|
||||
|
|
@ -62,7 +62,7 @@ function New-IcingaCheckPackage()
|
|||
$check.SilentCompile();
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AddSpacing' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AddSpacing' -Value {
|
||||
$this.spacing += 1;
|
||||
foreach ($check in $this.checks) {
|
||||
$check.spacing = $this.spacing;
|
||||
|
|
@ -70,7 +70,7 @@ function New-IcingaCheckPackage()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AddCheck' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AddCheck' -Value {
|
||||
param($check);
|
||||
|
||||
if ($null -eq $check) {
|
||||
|
|
@ -81,7 +81,7 @@ function New-IcingaCheckPackage()
|
|||
$this.checks += $check;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetWarnings' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetWarnings' -Value {
|
||||
foreach ($check in $this.checks) {
|
||||
$this.warningchecks += $check.GetWarnings();
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ function New-IcingaCheckPackage()
|
|||
return $this.warningchecks;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetCriticals' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetCriticals' -Value {
|
||||
foreach ($check in $this.checks) {
|
||||
$this.criticalchecks += $check.GetCriticals();
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ function New-IcingaCheckPackage()
|
|||
return $this.criticalchecks;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetUnknowns' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetUnknowns' -Value {
|
||||
foreach ($check in $this.checks) {
|
||||
$this.unknownchecks += $check.GetUnknowns();
|
||||
}
|
||||
|
|
@ -105,7 +105,7 @@ function New-IcingaCheckPackage()
|
|||
return $this.unknownchecks;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AssignCheckCommand' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AssignCheckCommand' -Value {
|
||||
param($CheckCommand);
|
||||
|
||||
$this.checkcommand = $CheckCommand;
|
||||
|
|
@ -115,7 +115,7 @@ function New-IcingaCheckPackage()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'Compile' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'Compile' -Value {
|
||||
param([bool]$Verbose);
|
||||
|
||||
if ($this.compiled) {
|
||||
|
|
@ -168,11 +168,11 @@ function New-IcingaCheckPackage()
|
|||
return $this.exitcode;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'SilentCompile' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'SilentCompile' -Value {
|
||||
$this.Compile($FALSE) | Out-Null;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetOkCount' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetOkCount' -Value {
|
||||
[int]$okCount = 0;
|
||||
foreach ($check in $this.checks) {
|
||||
if ([int]$check.exitcode -eq [int]$IcingaEnums.IcingaExitCode.Ok) {
|
||||
|
|
@ -183,12 +183,14 @@ function New-IcingaCheckPackage()
|
|||
return $okCount;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CheckMinimumOk' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CheckMinimumOk' -Value {
|
||||
if ($this.opmin -gt $this.checks.Count) {
|
||||
Write-IcingaPluginOutput ([string]::Format(
|
||||
Write-IcingaPluginOutput (
|
||||
[string]::Format(
|
||||
'Unknown: The minimum argument ({0}) is exceeding the amount of assigned checks ({1}) to this package "{2}"',
|
||||
$this.opmin, $this.checks.Count, $this.name
|
||||
));
|
||||
)
|
||||
);
|
||||
$this.exitcode = $IcingaEnums.IcingaExitCode.Unknown;
|
||||
return $FALSE;
|
||||
}
|
||||
|
|
@ -202,12 +204,14 @@ function New-IcingaCheckPackage()
|
|||
return $FALSE;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CheckMaximumOk' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CheckMaximumOk' -Value {
|
||||
if ($this.opmax -gt $this.checks.Count) {
|
||||
Write-IcingaPluginOutput ([string]::Format(
|
||||
Write-IcingaPluginOutput (
|
||||
[string]::Format(
|
||||
'Unknown: The maximum argument ({0}) is exceeding the amount of assigned checks ({1}) to this package "{2}"',
|
||||
$this.opmax, $this.checks.Count, $this.name
|
||||
));
|
||||
)
|
||||
);
|
||||
$this.exitcode = $IcingaEnums.IcingaExitCode.Unknown;
|
||||
return $FALSE;
|
||||
}
|
||||
|
|
@ -221,7 +225,7 @@ function New-IcingaCheckPackage()
|
|||
return $FALSE;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CheckAllOk' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CheckAllOk' -Value {
|
||||
foreach ($check in $this.checks) {
|
||||
if ([int]$check.exitcode -ne [int]$IcingaEnums.IcingaExitCode.Ok) {
|
||||
return $FALSE;
|
||||
|
|
@ -231,7 +235,7 @@ function New-IcingaCheckPackage()
|
|||
return $TRUE;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'CheckOneOk' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'CheckOneOk' -Value {
|
||||
foreach ($check in $this.checks) {
|
||||
if ([int]$check.exitcode -eq [int]$IcingaEnums.IcingaExitCode.Ok) {
|
||||
$this.exitcode = $check.exitcode;
|
||||
|
|
@ -242,7 +246,7 @@ function New-IcingaCheckPackage()
|
|||
return $FALSE;
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetPackageConfigMessage' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetPackageConfigMessage' -Value {
|
||||
if ($this.opand) {
|
||||
return 'Match All';
|
||||
} elseif ($this.opor) {
|
||||
|
|
@ -256,7 +260,7 @@ function New-IcingaCheckPackage()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'PrintOutputMessageSorted' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'PrintOutputMessageSorted' -Value {
|
||||
param($skipHidden, $skipExitCode);
|
||||
|
||||
if ($this.hidden -And $skipHidden) {
|
||||
|
|
@ -291,20 +295,20 @@ function New-IcingaCheckPackage()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WriteAllOutput' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WriteAllOutput' -Value {
|
||||
$this.PrintOutputMessageSorted($TRUE, -1);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'PrintAllMessages' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'PrintAllMessages' -Value {
|
||||
$this.WritePackageOutputStatus();
|
||||
$this.WriteAllOutput();
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WriteCheckErrors' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WriteCheckErrors' -Value {
|
||||
$this.PrintOutputMessageSorted($FALSE, $IcingaEnums.IcingaExitCode.Ok);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'PrintNoChecksConfigured' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'PrintNoChecksConfigured' -Value {
|
||||
if ($this.checks.Count -eq 0) {
|
||||
Write-IcingaPluginOutput (
|
||||
[string]::Format(
|
||||
|
|
@ -318,7 +322,7 @@ function New-IcingaCheckPackage()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'WritePackageOutputStatus' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'WritePackageOutputStatus' -Value {
|
||||
if ($this.hidden) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -344,7 +348,7 @@ function New-IcingaCheckPackage()
|
|||
);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'PrintOutputMessages' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'PrintOutputMessages' -Value {
|
||||
[bool]$printAll = $FALSE;
|
||||
|
||||
switch ($this.verbose) {
|
||||
|
|
@ -375,7 +379,7 @@ function New-IcingaCheckPackage()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'AddUniqueSortedChecksToHeader' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'AddUniqueSortedChecksToHeader' -Value {
|
||||
param($checkarray, $state);
|
||||
|
||||
[hashtable]$CheckHash = @{};
|
||||
|
|
@ -397,7 +401,7 @@ function New-IcingaCheckPackage()
|
|||
}
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetWorstExitCode' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetWorstExitCode' -Value {
|
||||
if ([int]$this.exitcode -eq [int]$IcingaEnums.IcingaExitCode.Unknown) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -428,7 +432,7 @@ function New-IcingaCheckPackage()
|
|||
);
|
||||
}
|
||||
|
||||
$Check | Add-Member -membertype ScriptMethod -name 'GetPerfData' -value {
|
||||
$Check | Add-Member -MemberType ScriptMethod -Name 'GetPerfData' -Value {
|
||||
[string]$perfData = '';
|
||||
[hashtable]$CollectedPerfData = @{};
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ function New-IcingaCheckresult()
|
|||
);
|
||||
|
||||
$CheckResult = New-Object -TypeName PSObject;
|
||||
$CheckResult | Add-Member -membertype NoteProperty -name 'check' -value $Check;
|
||||
$CheckResult | Add-Member -membertype NoteProperty -name 'noperfdata' -value $NoPerfData;
|
||||
$CheckResult | Add-Member -MemberType NoteProperty -Name 'check' -Value $Check;
|
||||
$CheckResult | Add-Member -MemberType NoteProperty -Name 'noperfdata' -Value $NoPerfData;
|
||||
|
||||
$CheckResult | Add-Member -membertype ScriptMethod -name 'Compile' -value {
|
||||
$CheckResult | Add-Member -MemberType ScriptMethod -Name 'Compile' -Value {
|
||||
if ($null -eq $this.check) {
|
||||
return $IcingaEnums.IcingaExitCode.Unknown;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ function New-IcingaPerformanceDataEntry()
|
|||
$maximum = [string]::Format(';{0}', $PerfDataObject.maximum);
|
||||
}
|
||||
|
||||
return ([string]::Format(
|
||||
return (
|
||||
[string]::Format(
|
||||
"'{0}'={1}{2};{3};{4}{5}{6} ",
|
||||
$LabelName.ToLower(),
|
||||
(Format-IcingaPerfDataValue $PerfValue),
|
||||
|
|
@ -39,5 +40,6 @@ function New-IcingaPerformanceDataEntry()
|
|||
(Format-IcingaPerfDataValue $PerfDataObject.critical),
|
||||
(Format-IcingaPerfDataValue $minimum),
|
||||
(Format-IcingaPerfDataValue $maximum)
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,11 +59,9 @@ function Convert-Base64ToCredentials()
|
|||
);
|
||||
$Credentials.Add(
|
||||
'password',
|
||||
(ConvertTo-IcingaSecureString `
|
||||
$AuthString.Substring(
|
||||
$AuthString.IndexOf(':') + 1,
|
||||
$AuthString.Length - $UserData.Length - 1
|
||||
)
|
||||
(
|
||||
ConvertTo-IcingaSecureString `
|
||||
$AuthString.Substring($AuthString.IndexOf(':') + 1, $AuthString.Length - $UserData.Length - 1)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -77,8 +75,8 @@ function Convert-Base64ToCredentials()
|
|||
$Credentials.Add('domain', $AuthData[0]);
|
||||
$Credentials.Add(
|
||||
'user',
|
||||
(ConvertTo-IcingaSecureString `
|
||||
$AuthData[1]
|
||||
(
|
||||
ConvertTo-IcingaSecureString $AuthData[1]
|
||||
)
|
||||
);
|
||||
$AuthData = $null;
|
||||
|
|
@ -86,8 +84,8 @@ function Convert-Base64ToCredentials()
|
|||
$Credentials.Add('domain', $null);
|
||||
$Credentials.Add(
|
||||
'user',
|
||||
(ConvertTo-IcingaSecureString `
|
||||
$UserData
|
||||
(
|
||||
ConvertTo-IcingaSecureString $UserData
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ function Enable-IcingaUntrustedCertificateValidation()
|
|||
try {
|
||||
# There is no other way as to use C# for this specific
|
||||
# case to configure the certificate validation check
|
||||
add-type @"
|
||||
Add-Type @"
|
||||
using System.Net;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,9 @@ function Get-IcingaSSLCertForSocket()
|
|||
# Windows cert store. Try to look it up an return it if
|
||||
# it is found
|
||||
if ([string]::IsNullOrEmpty($CertThumbprint) -eq $FALSE) {
|
||||
$Certificates = Get-ChildItem -Path 'cert:\*' -Recurse `
|
||||
$Certificates = Get-ChildItem `
|
||||
-Path 'cert:\*' `
|
||||
-Recurse `
|
||||
-Include $CertThumbprint `
|
||||
-ErrorAction SilentlyContinue `
|
||||
-WarningAction SilentlyContinue;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ function Read-IcingaRESTMessage()
|
|||
# Arguments
|
||||
$ArgumentsSplit = $Arguments.Split('&');
|
||||
$ArgumentsSplit+='\\\\\\\\\\\\=FIN';
|
||||
foreach ( $Argument in $ArgumentsSplit | Sort-Object -descending) {
|
||||
foreach ( $Argument in $ArgumentsSplit | Sort-Object -Descending) {
|
||||
if ($Argument.Contains('=')) {
|
||||
$Argument -match '(.+)=(.+)' | Out-Null;
|
||||
If (($Matches[1] -ne $Current) -And ($NULL -ne $Current)) {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Tests provided credentials against either the local machine or a domain controller
|
||||
|
|
@ -65,7 +66,8 @@ function Test-IcingaRESTCredentials()
|
|||
[bool]$AuthResult = [int]($AccountService.ValidateCredentials(
|
||||
(ConvertFrom-IcingaSecureString $UserName),
|
||||
(ConvertFrom-IcingaSecureString $Password)
|
||||
));
|
||||
)
|
||||
);
|
||||
|
||||
return $AuthResult;
|
||||
} catch {
|
||||
|
|
|
|||
Loading…
Reference in a new issue