mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-18 15:46:14 -05:00
Added proper support for custom plugins / lib elements
This commit is contained in:
parent
1f15eee19b
commit
843359d64b
6 changed files with 23 additions and 4 deletions
|
|
@ -10,6 +10,7 @@ Set-Variable -Name Icinga2 -Option Constant -Value @{
|
|||
'Use-Icinga',
|
||||
'Import-IcingaLib',
|
||||
'Get-IcingaPluginDir',
|
||||
'Get-IcingaCustomPluginDir',
|
||||
'Get-IcingaCacheDir',
|
||||
'Get-IcingaPowerShellConfigDir',
|
||||
'Get-Icinga-Lib',
|
||||
|
|
|
|||
3
custom/lib/README.md
Normal file
3
custom/lib/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Custom Libraries
|
||||
|
||||
Here you can place your own libraries for the module. You can either extend the module with this or override existing libraries without having to worry about breaking future updates
|
||||
3
custom/plugins/README.md
Normal file
3
custom/plugins/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# Custom Plugins
|
||||
|
||||
Here you can place your own custom plugins or override existing ones. This will ensure future updates of the module will not rever your changes
|
||||
|
|
@ -25,7 +25,7 @@ Description = 'Icinga 2 Windows Agent Module, which allows to entirely monitor t
|
|||
PowerShellVersion = '3.0'
|
||||
|
||||
# Aus diesem Modul zu exportierende Funktionen. Um optimale Leistung zu erzielen, verwenden Sie keine Platzhalter und löschen den Eintrag nicht. Verwenden Sie ein leeres Array, wenn keine zu exportierenden Funktionen vorhanden sind.
|
||||
FunctionsToExport = @( 'Use-Icinga', 'Import-IcingaLib', 'Get-IcingaPluginDir', 'Get-IcingaCacheDir', 'Get-IcingaPowerShellConfigDir', 'Start-Icinga-Checker', 'Stop-Icinga-Checker', 'Get-Icinga-Lib', 'Get-Icinga-Object', 'Get-Icinga-Service', 'Start-Icinga-Service', 'Stop-Icinga-Service', 'Restart-Icinga-Service', 'Install-Icinga-Service', 'Uninstall-Icinga-Service', 'Get-Icinga-Setup', 'Install-Icinga', 'Start-Icinga-Daemon', 'Stop-Icinga-Daemon', 'Icinga-Client', 'Get-Icinga-Command', 'New-Icinga-Monitoring', 'Get-Icinga-Counter', 'Get-Icinga-Config', 'Set-Icinga-Config', 'Remove-Icinga-Config', 'New-Icinga-Config' )
|
||||
FunctionsToExport = @( 'Use-Icinga', 'Import-IcingaLib', 'Get-IcingaPluginDir', 'Get-IcingaCustomPluginDir', 'Get-IcingaCacheDir', 'Get-IcingaPowerShellConfigDir', 'Start-Icinga-Checker', 'Stop-Icinga-Checker', 'Get-Icinga-Lib', 'Get-Icinga-Object', 'Get-Icinga-Service', 'Start-Icinga-Service', 'Stop-Icinga-Service', 'Restart-Icinga-Service', 'Install-Icinga-Service', 'Uninstall-Icinga-Service', 'Get-Icinga-Setup', 'Install-Icinga', 'Start-Icinga-Daemon', 'Stop-Icinga-Daemon', 'Icinga-Client', 'Get-Icinga-Command', 'New-Icinga-Monitoring', 'Get-Icinga-Counter', 'Get-Icinga-Config', 'Set-Icinga-Config', 'Remove-Icinga-Config', 'New-Icinga-Config' )
|
||||
|
||||
# Aus diesem Modul zu exportierende Cmdlets. Um optimale Leistung zu erzielen, verwenden Sie keine Plat'zhalter und löschen den Eintrag nicht. Verwenden Sie ein leeres Array, wenn keine zu exportierenden Cmdlets vorhanden sind.
|
||||
CmdletsToExport = @()
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ function Use-Icinga()
|
|||
|
||||
# This function will allow us to load this entire module including possible
|
||||
# actions, making it available within our shell environment
|
||||
# First load our custom modules
|
||||
Import-IcingaLib '\' -Init -Custom;
|
||||
Import-IcingaLib '\' -Init;
|
||||
|
||||
if ($LibOnly -eq $FALSE) {
|
||||
|
|
@ -48,7 +50,8 @@ function Import-IcingaLib()
|
|||
# The Force Reload will remove the module in case it's loaded and reload it to track
|
||||
# possible development changes without having to create new PowerShell environments
|
||||
[Switch]$ForceReload,
|
||||
[switch]$Init
|
||||
[switch]$Init,
|
||||
[switch]$Custom
|
||||
);
|
||||
|
||||
# This is just to only allow a global loading of the module. Import-IcingaLib is ignored on every other
|
||||
|
|
@ -57,7 +60,11 @@ function Import-IcingaLib()
|
|||
return;
|
||||
}
|
||||
|
||||
[string]$directory = Join-Path -Path $PSScriptRoot -ChildPath 'lib\';
|
||||
if ($Custom) {
|
||||
[string]$directory = Join-Path -Path $PSScriptRoot -ChildPath 'custom\';
|
||||
} else {
|
||||
[string]$directory = Join-Path -Path $PSScriptRoot -ChildPath 'lib\';
|
||||
}
|
||||
[string]$module = Join-Path -Path $directory -ChildPath $Lib;
|
||||
[string]$moduleName = '';
|
||||
|
||||
|
|
@ -99,6 +106,11 @@ function Get-IcingaPluginDir()
|
|||
return (Join-Path -Path $PSScriptRoot -ChildPath 'lib\plugins\');
|
||||
}
|
||||
|
||||
function Get-IcingaCustomPluginDir()
|
||||
{
|
||||
return (Join-Path -Path $PSScriptRoot -ChildPath 'custom\plugins\');
|
||||
}
|
||||
|
||||
function Get-IcingaCacheDir()
|
||||
{
|
||||
return (Join-Path -Path $PSScriptRoot -ChildPath 'cache');
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ function New-IcingaCheckCommand()
|
|||
$CommandName
|
||||
);
|
||||
|
||||
[string]$ScriptFile = Join-Path -Path (Get-IcingaPluginDir) -ChildPath $CommandFile;
|
||||
[string]$ScriptFile = Join-Path -Path (Get-IcingaCustomPluginDir) -ChildPath $CommandFile;
|
||||
|
||||
if ((Test-Path $ScriptFile) -eq $TRUE) {
|
||||
throw 'This Check-Command does already exist.';
|
||||
|
|
|
|||
Loading…
Reference in a new issue