mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-20 23:00:35 -05:00
Added more details for new Check Plugin Command as starting point
This commit is contained in:
parent
089ad30171
commit
3ec2f44fed
1 changed files with 11 additions and 1 deletions
|
|
@ -6,7 +6,7 @@ function New-IcingaCheckCommand()
|
|||
'Warning',
|
||||
'Critical',
|
||||
'[switch]NoPerfData',
|
||||
'Verbose'
|
||||
'[int]Verbose'
|
||||
),
|
||||
[array]$ImportLib = @()
|
||||
);
|
||||
|
|
@ -72,6 +72,14 @@ function New-IcingaCheckCommand()
|
|||
}
|
||||
|
||||
Add-Content -Path $ScriptFile -Value "";
|
||||
Add-Content -Path $ScriptFile -Value ' <# Icinga Basic Check-Plugin Template. Below you will find an example structure. #>';
|
||||
Add-Content -Path $ScriptFile -Value ([string]::Format(' $CheckPackage = New-IcingaCheckPackage -Name {0}New Package{0} -OperatorAnd -Verbose $Verbose;', "'"));
|
||||
Add-Content -Path $ScriptFile -Value ([string]::Format(' $IcingaCheck = New-IcingaCheck -Name {0}New Check{0} -Value 10 -Unit {0}%{0}', "'"));
|
||||
Add-Content -Path $ScriptFile -Value ([string]::Format(' $IcingaCheck.WarnOutOfRange($Warning).CritOutOfRange($Critical) | Out-Null;', "'"));
|
||||
Add-Content -Path $ScriptFile -Value ([string]::Format(' $CheckPackage.AddCheck($IcingaCheck);', "'"));
|
||||
Add-Content -Path $ScriptFile -Value "";
|
||||
Add-Content -Path $ScriptFile -Value ([string]::Format(' return (New-IcingaCheckresult -Check $CheckPackage -NoPerfData $NoPerfData -Compile);', "'"));
|
||||
|
||||
Add-Content -Path $ScriptFile -Value "}";
|
||||
|
||||
Write-Host ([string]::Format('The Check-Command "{0}" was successfully added.', $CommandName));
|
||||
|
|
@ -80,6 +88,8 @@ function New-IcingaCheckCommand()
|
|||
$DefaultEditor = (Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.psm1\OpenWithList' -Name a).a;
|
||||
$DefaultEditor = $DefaultEditor.Replace('.exe', '');
|
||||
|
||||
Import-Module $ScriptFile -Global;
|
||||
|
||||
if ([string]::IsNullOrEmpty($DefaultEditor) -eq $FALSE -And ((Get-Command $DefaultEditor -ErrorAction SilentlyContinue) -eq $null) -And ((Test-Path $DefaultEditor) -eq $FALSE)) {
|
||||
Write-Host 'No default editor for .psm1 files found. Specify a default editor to automaticly open the newly generated check plugin.';
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue