Merge pull request #453 from Icinga:feature/optimize_imc

Feature: Rework IMC menu and extend feature set

Reworks the menu structure of the Icinga for Windows Management Console and makes it the default when running the command `icinga`.

For developers you can use `icinga -Shell` to receive the Icinga shell as before. In addition improves error handling of IMC, by caching all `Errors` and `Warnings` during action execution, printing them afterwards.
This commit is contained in:
Lord Hepipud 2022-02-04 16:13:08 +01:00 committed by GitHub
commit f923a9e6e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
52 changed files with 840 additions and 359 deletions

View file

@ -16,7 +16,7 @@ Otherwise the service will not start and crash! You can either download the serv
Update-Icinga -Name 'service';
```
After upgrading to Icinga for Windows v1.8.0, you will require to open a new Icinga shell by calling `icinga` or by using `Use-Icinga` once, to run the new migration process.
After upgrading to Icinga for Windows v1.8.0, you will require to open a new Icinga shell by calling `icinga -Shell` or simply `icinga` to open the IMC for running the migration tasks.
**NOTE:** In some cases the changes for the EventLog will only apply, **after** the system has been rebooted. Afterwards every Icinga for Windows EventLog entry is written in a newly created `Icinga for Windows` log.

View file

@ -52,6 +52,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#445](https://github.com/Icinga/icinga-powershell-framework/pull/445) Adds command `Repair-IcingaService` to repair Icinga Agent service in case it was broken during upgrades, mostly caused by `The specified service has been marked for deletion`
* [#448](https://github.com/Icinga/icinga-powershell-framework/pull/448) Adds support to sort arrays without ScriptBlocks
* [#450](https://github.com/Icinga/icinga-powershell-framework/pull/450) Improves show command `Show-IcingaRegisteredServiceChecks`, adds new command `Show-IcingaRegisteredBackgroundDaemons` and extends `Show-Icinga` by both commands and adds debug and api forwarder features to environment list
* [#453](https://github.com/Icinga/icinga-powershell-framework/pull/453) Reworks Icinga Management Console menu structure and naming and changes the default behavior of executing `icinga` to now open the IMC by default and `icinga -Shell` to open a shell as done previously
* [#455](https://github.com/Icinga/icinga-powershell-framework/pull/455) Adds support for remote execution plugin [check_by_icingaforwindows](https://github.com/LordHepipud/check_by_icingaforwindows)
## 1.7.1 (2021-11-11)

View file

@ -5,7 +5,7 @@ As we now have deployed our Icinga PowerShell Framework on our Windows machine,
**Note:** You can always open the IMC by running the following command:
```powershell
icinga -Manage;
icinga;
```
## Navigating the IMC

View file

@ -5,7 +5,7 @@ We can now use the Icinga Management Console to configure our local Windows syst
If we are not already inside the IMC, we can open it with
```powershell
icinga -Manage;
icinga;
```
## Installation menu

View file

@ -2,7 +2,7 @@
The Icinga PowerShell Framework is shipping wish a bunch of Cmdlets to manage the Icinga Agent in a very easy way. This includes the managing for features enabled or disabled for the Icinga Agent.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`
## List Icinga Agent Features

View file

@ -2,7 +2,7 @@
The Icinga PowerShell Framework is shipping wish a bunch of Cmdlets to manage the Icinga Agent in a very easy way. This includes reading the Icinga Agent log/debug log file.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`
## Read the default Icinga Agent log file

View file

@ -2,11 +2,11 @@
The Icinga PowerShell Framework is shipping wish a bunch of Cmdlets to manage the Icinga Agent in a very easy way. This includes a test for the entire configuration and state of the Icinga Agent on the machine.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`
## Testing for errors
A very important part of an Agent is to ensure that it is running properly and no configuration error is present. In addition it is important that required directories are accessable by the service user the Icinga Agent is running with. For this you can use the Cmdlet `Test-IcingaAgent`:
A very important part of an Agent is to ensure that it is running properly and no configuration error is present. In addition it is important that required directories are accessible by the service user the Icinga Agent is running with. For this you can use the Cmdlet `Test-IcingaAgent`:
```powershell
Test-IcingaAgent;
@ -51,7 +51,7 @@ In addition for testing, the Icinga PowerShell Framework will suggest methods to
[Passed]: Icinga Agent debug log is disabled
```
As you can see, the mandatory directory `C:\ProgramData\icinga2\var` is not accessable by our `NT AUTHORITY\NetworkService` user. To resolve this, the Framework provides the Cmdlet `Set-IcingaAcl`. It will automatically set the correct permissions for a specific directory for the service user the Icinga Agent is running with:
As you can see, the mandatory directory `C:\ProgramData\icinga2\var` is not accessible by our `NT AUTHORITY\NetworkService` user. To resolve this, the Framework provides the Cmdlet `Set-IcingaAcl`. It will automatically set the correct permissions for a specific directory for the service user the Icinga Agent is running with:
```powershell
Set-IcingaAcl -Directory 'C:\ProgramData\icinga2\var';
@ -97,7 +97,7 @@ As our configuration is for some reason broken we have to resolve this. The Icin
Test-IcingaAgentConfig -WriteStackTrace | Out-Null;
```
By using the argument `-WriteStackTrace` we will print the actual error ouptut from the Icinga Agent binary to our console for troubleshooting:
By using the argument `-WriteStackTrace` we will print the actual error output from the Icinga Agent binary to our console for troubleshooting:
```text
[2020-08-12 16:54:26 +0200] information/cli: Icinga application loader (version: v2.12.0)

View file

@ -2,7 +2,7 @@
The Icinga PowerShell Framework is shipping wish a bunch of Cmdlets to manage the Icinga Agent in a very easy way. This includes changing the current assigned Service User of the Icinga Agent to another one.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`
## Getting started

View file

@ -1,14 +1,6 @@
# Developer Guide: Testing of Commands
Actively developing new code for the Framework will result in core files to be changed or new functionality added. To load the Framework we use in general `Use-Icinga`, which does how ever not cover changes we made afterwards. To keep track of the changes for new features or while testing something, we always have to open a new PowerShell instance.
To make things more usable, we can of course run a PowerShell command directly from our shell:
```powershell
powershell -C { Use-Icinga; <# your code #> }
```
While this is straight forward and easy to use, the idea is to make this way simpler.
Actively developing new code for the Framework will result in core files to be changed or new functionality added. To load the Framework we use in general `icinga -Shell`, which does how ever not cover changes we made afterwards. To keep track of the changes for new features or while testing something, we always have to open a new PowerShell instance.
## Invoke-IcingaCommand or simply icinga
@ -58,7 +50,7 @@ icinga> Exit-IcingaThrowException -Force -CustomMessage 'Force Exit of our Shell
Unhandled exception occured:
```
Instead of our own shell closing, we still have our previous one open and can start another shell by using `icinga` with the entire Framework loaded.
Instead of our own shell closing, we still have our previous one open and can start another shell by using `icinga -Shell` with the entire Framework loaded.
This also works for code we directly invoke to the `icinga` alias:

View file

@ -10,7 +10,7 @@ To start the Icinga Agent installation wizard you will have to open a PowerShell
Use-Icinga
```
*Note:* Starting with Icinga PowerShell Framework `1.2.0` you can simply type `icinga` to open an Icinga PowerShell Framework shell,
*Note:* Starting with Icinga PowerShell Framework `1.2.0` you can simply type `icinga -Shell` to open an Icinga PowerShell Framework shell,
Once the command is executed, the Framework and all required components are loaded. To get started, we can now run

View file

@ -2,7 +2,7 @@
While the main purpose of the Icinga for Windows solution is check your systems and provided all required tools, including the Icinga Agent, it might be required to entirely uninstall the Icinga Agent. This sometimes might even include to flush the entire `ProgramData` folder, where certificates and other configurations are stored.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`
## Uninstalling the Icinga Agent

View file

@ -2,7 +2,7 @@
Managing the Icinga Agent is one of the main goals for Icinga for Windows. This also includes installing and updating the Icinga Agent itself.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `Use-Icinga`. Starting with version `1.2.0` of the Framework you can also simply type `icinga` into the command line.
**Note:** Before using any of the commands below you will have to initialize the Icinga PowerShell Framework inside a new PowerShell instance with `icinga -Shell`
## Installing the Icinga Agent

View file

@ -30,7 +30,7 @@ There is a detailed description on the [Microsoft Docs](https://docs.microsoft.c
#### Using PowerShell
To add permissions for WMI namespaces you can use our Icinga for Windows Cmdlets. Simply open a new PowerShell as `Administrator` and create a new Icinga Shell instance by typing `icinga`.
To add permissions for WMI namespaces you can use our Icinga for Windows Cmdlets. Simply open a new PowerShell as `Administrator` and create a new Icinga Shell instance by typing `icinga -Shell`.
After the Icinga PowerShell Framework is loaded, we can use our Wmi permission Cmdlet:
```powershell

View file

@ -4,7 +4,7 @@
GUID = 'fcd7a805-a41b-49f9-afee-9d17a2b76d42'
Author = 'Lord Hepipud'
CompanyName = 'Icinga GmbH'
Copyright = '(c) 2021 Icinga GmbH | MIT'
Copyright = '(c) 2022 Icinga GmbH | MIT'
Description = 'Icinga for Windows module which allows to entirely monitor the Windows Host system.'
PowerShellVersion = '4.0'
NestedModules = @( '.\cache\framework_cache.psm1' )

View file

@ -179,7 +179,8 @@ function Invoke-IcingaCommand()
param (
$ScriptBlock,
[switch]$SkipHeader = $FALSE,
[switch]$Manage = $FALSE,
[switch]$Manage = $FALSE, # Only for backwards compatibility, has no use at all
[switch]$Shell = $FALSE,
[switch]$RebuildCache = $FALSE,
[array]$ArgumentList = @()
);
@ -191,7 +192,7 @@ function Invoke-IcingaCommand()
# Print a header informing our user that loaded the Icinga Framework with a specific
# version. We can also skip the header by using $SKipHeader
if ([string]::IsNullOrEmpty($ScriptBlock) -And $SkipHeader -eq $FALSE -And $Manage -eq $FALSE) {
if ([string]::IsNullOrEmpty($ScriptBlock) -And $SkipHeader -eq $FALSE -And $Shell) {
[array]$Headers = @(
'Icinga for Windows $FrameworkVersion',
'Copyright $Copyright',
@ -209,7 +210,7 @@ function Invoke-IcingaCommand()
Write-IcingaFrameworkCodeCache;
}
if ($Manage -And $null -ne $psISE) {
if ($null -ne $psISE) {
Use-Icinga;
Write-IcingaConsoleError -Message 'Icinga for Windows was loaded, but the Icinga Management Console is not available within the PowerShell ISE context. Please start a regular PowerShell to use it.';
return;
@ -224,7 +225,7 @@ function Invoke-IcingaCommand()
$Script = $args[0];
$RootPath = $args[1];
$Version = $args[2];
$Manage = $args[3];
$Shell = $args[3];
$IcingaShellArgs = $args[4];
# Load our Icinga Framework
@ -235,7 +236,7 @@ function Invoke-IcingaCommand()
# Set the location to the Icinga Framework module folder
Set-Location $RootPath;
if ($Manage) {
if ($Shell -eq $FALSE -And [string]::IsNullOrEmpty($Script)) {
Install-Icinga;
exit $LASTEXITCODE;
}
@ -253,7 +254,7 @@ function Invoke-IcingaCommand()
return "> "
}
} -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version, ([bool]$Manage), $ArgumentList;
} -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version, ([bool]$Shell), $ArgumentList;
}
function Start-IcingaShellAsUser()

View file

@ -16,6 +16,8 @@
"icinga", you require to specify the user to remove it entirely
.PARAMETER Force
Suppress the question if you are sure to uninstall everything
.PARAMETER ComponentsOnly
Only uninstalls components like Icinga Agent, plugins, and so on and keeps the Framework
.INPUTS
System.String
.OUTPUTS
@ -27,8 +29,9 @@
function Uninstall-IcingaForWindows()
{
param (
$IcingaUser = 'icinga',
[switch]$Force = $FALSE
$IcingaUser = 'icinga',
[switch]$Force = $FALSE,
[switch]$ComponentsOnly = $FALSE
);
$ModuleList = Get-Module 'icinga-powershell-*' -ListAvailable;
@ -53,15 +56,21 @@ function Uninstall-IcingaForWindows()
Uninstall-IcingaSecurity -IcingaUser $IcingaUser;
Write-IcingaConsoleNotice 'Uninstalling Icinga Agent';
Uninstall-IcingaAgent -RemoveDataFolder | Out-Null;
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows EventLog';
Unregister-IcingaEventLog;
if ($ComponentsOnly -eq $FALSE) {
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows EventLog';
Unregister-IcingaEventLog;
}
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows service';
Uninstall-IcingaForWindowsService | Out-Null;
$HasErrors = $FALSE;
foreach ($module in $ModuleList.Name) {
[string]$ModuleName = $module.Replace('icinga-powershell-', '');
[string]$ModuleName = $module.Replace('icinga-powershell-', '').ToLower();
if ($ModuleName -eq 'framework' -And $ComponentsOnly) {
continue;
}
if ((Uninstall-IcingaFrameworkComponent -Name $ModuleName)) {
continue;
@ -70,7 +79,9 @@ function Uninstall-IcingaForWindows()
$HasErrors = $TRUE;
}
Remove-Module 'icinga-powershell-framework' -Force -ErrorAction SilentlyContinue;
if ($ComponentsOnly -eq $FALSE) {
Remove-Module 'icinga-powershell-framework' -Force -ErrorAction SilentlyContinue;
}
if ($HasErrors) {
Write-Host 'Not all components could be removed. Please ensure no other PowerShell/Application is currently open and accessing Icinga for Windows files';

View file

@ -15,7 +15,8 @@ function Install-Icinga()
'AdminShell' = (Test-AdministrativeShell);
'LastInput' = '';
'LastNotice' = '';
'LastError' = '';
'LastWarning' = @();
'LastError' = @();
'DirectorError' = '';
'HeaderPreview' = '';
'DirectorSelfService' = $FALSE;
@ -41,6 +42,9 @@ function Install-Icinga()
'Closing' = $FALSE;
}
);
} else {
$Global:Icinga.InstallWizard.LastWarning.Clear();
$Global:Icinga.InstallWizard.LastError.Clear();
}
if ([string]::IsNullOrEmpty($InstallFile) -eq $FALSE) {
@ -119,37 +123,30 @@ function Install-Icinga()
-Header 'What do you want to do?' `
-Entries @(
@{
'Caption' = 'Installation';
'Caption' = 'Base Installation';
'Command' = 'Show-IcingaForWindowsInstallerMenuInstallWindows';
'Help' = 'Allows you to install Icinga for Windows with all required components and options.'
},
@{
'Caption' = 'Install components';
'Command' = 'Show-IcingaForWindowsMenuInstallComponents';
'Help' = 'Allows you to install new components for Icinga for Windows from your repositories.';
'Disabled' = (-Not ($global:Icinga.InstallWizard.AdminShell));
'Caption' = 'Component Manager';
'Command' = 'Show-IcingaForWindowsManagementConsoleComponentManager';
'Help' = 'Allows you to manage components for Icinga for Windows.';
'AdminMenu' = $TRUE;
},
@{
'Caption' = 'Update components';
'Command' = 'Show-IcingaForWindowsMenuUpdateComponents';
'Help' = 'Allows you to modify your current Icinga for Windows installation.';
'Disabled' = (-Not ($global:Icinga.InstallWizard.AdminShell));
},
@{
'Caption' = 'Remove components';
'Command' = 'Show-IcingaForWindowsMenuRemoveComponents';
'Help' = 'Allows you to modify your current Icinga for Windows installation.';
'Disabled' = (-Not ($global:Icinga.InstallWizard.AdminShell));
},
@{
'Caption' = 'Manage environment';
'Caption' = 'Settings';
'Command' = 'Show-IcingaForWindowsMenuManage';
'Help' = 'Allows you to modify your current Icinga for Windows installation.';
},
@{
'Caption' = 'List environment';
'Caption' = 'Overview';
'Command' = 'Show-IcingaForWindowsMenuListEnvironment';
'Help' = 'Shows you an overview of your current Icinga for Windows installation, including installed components and system informations.';
},
@{
'Caption' = 'Icinga Shell';
'Command' = 'Invoke-IcingaForWindowsMenuStartIcingaShell';
'Help' = 'Shows you an overview of your current Icinga for Windows installation, including installed components and system informations.';
}
) `
-DefaultIndex 0;
@ -172,7 +169,7 @@ function Install-Icinga()
} catch {
$ErrMsg = $_.Exception.Message;
$global:Icinga.InstallWizard.LastError = [string]::Format('Failed to enter menu "{0}". Error "{1}', $global:Icinga.InstallWizard.NextCommand, $ErrMsg);
$global:Icinga.InstallWizard.LastError += [string]::Format('Failed to enter menu "{0}". Error "{1}', $global:Icinga.InstallWizard.NextCommand, $ErrMsg);
$global:Icinga.InstallWizard.NextCommand = 'Install-Icinga';
$global:Icinga.InstallWizard.NextArguments = @{ };
}

View file

@ -18,6 +18,7 @@ function Start-IcingaForWindowsInstallation()
$ConnectionType = Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectConnection';
$HostnameType = Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectHostname';
$CustomHostname = Get-IcingaForWindowsInstallerValuesFromStep -InstallerStep 'Show-IcingaForWindowsInstallationMenuEnterCustomHostname';
$FirewallType = Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectOpenWindowsFirewall';
# Certificate handler
@ -70,6 +71,8 @@ function Start-IcingaForWindowsInstallation()
$PluginPackageRelease = $FALSE;
$PluginPackageSnapshot = $FALSE;
$ForceCertificateGen = $FALSE;
[bool]$InstallJEA = $FALSE;
[bool]$InstallRESTApi = $FALSE;
if ([string]::IsNullOrEmpty($IcingaStableRepo) -eq $FALSE) {
Add-IcingaRepository -Name 'Icinga Stable' -RemotePath $IcingaStableRepo -Force;
@ -106,6 +109,10 @@ function Start-IcingaForWindowsInstallation()
$Hostname = (Get-IcingaHostname -AutoUseHostname 1 -UpperCase 1);
break;
};
'6' {
$Hostname = $CustomHostname;
break;
}
}
switch ($GlobalZonesType) {
@ -245,10 +252,12 @@ function Start-IcingaForWindowsInstallation()
switch ($InstallJEAProfile) {
'0' {
Install-IcingaJEAProfile;
$InstallJEA = $TRUE;
break;
};
'1' {
Install-IcingaSecurity;
$InstallJEA = $TRUE;
break;
};
'2' {
@ -265,6 +274,7 @@ function Start-IcingaForWindowsInstallation()
Register-IcingaBackgroundDaemon -Command 'Start-IcingaWindowsRESTApi';
Add-IcingaRESTApiCommand -Command 'Invoke-IcingaCheck*' -Endpoint 'apichecks';
Enable-IcingaFrameworkApiChecks;
$InstallRESTApi = $TRUE;
if ($InstallService) {
Restart-IcingaWindowsService;
} else {
@ -274,6 +284,11 @@ function Start-IcingaForWindowsInstallation()
};
}
# Install Icinga for Windows certificate if both, JEA and REST is installed
if ($InstallJEA -And $InstallRESTApi) {
Install-IcingaForWindowsCertificate;
}
# Update configuration and clear swap
$ConfigSwap = Get-IcingaPowerShellConfig -Path 'Framework.Config.Swap';
Set-IcingaPowerShellConfig -Path 'Framework.Config.Swap' -Value $null;

View file

@ -16,8 +16,9 @@ function Resolve-IcingaForWindowsManagementConsoleInstallationDirectorTemplate()
Add-IcingaForWindowsInstallerConfigEntry -Selection 'c' -Values $SelfServiceKey -OverwriteValues -OverwriteMenu 'Show-IcingaForWindowsManagementConsoleInstallationEnterDirectorSelfServiceKey';
} else {
$Global:Icinga.InstallWizard.DirectorRegisteredHost = $TRUE;
$HostnameType = Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectHostname';
$Hostname = '';
$HostnameType = Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectHostname';
$CustomHostname = Get-IcingaForWindowsInstallerValuesFromStep -InstallerStep 'Show-IcingaForWindowsInstallationMenuEnterCustomHostname';
$Hostname = '';
switch ($HostnameType) {
'0' {
@ -44,6 +45,10 @@ function Resolve-IcingaForWindowsManagementConsoleInstallationDirectorTemplate()
$Hostname = (Get-IcingaHostname -AutoUseHostname 1 -UpperCase 1);
break;
};
'6' {
$Hostname = $CustomHostname;
break;
}
}
[bool]$RegisterFailed = $FALSE;
@ -75,7 +80,7 @@ function Resolve-IcingaForWindowsManagementConsoleInstallationDirectorTemplate()
$DirectorConfig = Get-IcingaDirectorSelfServiceConfig -DirectorUrl $DirectorUrl -ApiKey $SelfServiceKey;
} catch {
Set-IcingaForWindowsManagementConsoleMenu 'Show-IcingaForWindowsInstallerConfigurationSummary';
$global:Icinga.InstallWizard.LastError = 'Failed to fetch host configuration with the given Director Url and Self-Service key. Please ensure the template key is correct and in case a previous host key was used, that it matches the one configured within the Icinga Director. In case this form was loaded previously with a key, it might be that the host key is no longer valid and requires to be dropped. In addition please ensure that this host can connect to the Icinga Director and the SSL certificate is trusted. Otherwise run "Enable-IcingaUntrustedCertificateValidation" before starting the management console. Otherwise modify the "DirectorSelfServiceKey" configuration element above with the correct key and try again.';
$global:Icinga.InstallWizard.LastError += 'Failed to fetch host configuration with the given Director Url and Self-Service key. Please ensure the template key is correct and in case a previous host key was used, that it matches the one configured within the Icinga Director. In case this form was loaded previously with a key, it might be that the host key is no longer valid and requires to be dropped. In addition please ensure that this host can connect to the Icinga Director and the SSL certificate is trusted. Otherwise run "Enable-IcingaUntrustedCertificateValidation" before starting the management console. Otherwise modify the "DirectorSelfServiceKey" configuration element above with the correct key and try again.';
$global:Icinga.InstallWizard.DirectorError = $global:Icinga.InstallWizard.LastError;
$global:Icinga.InstallWizard.DirectorInstallError = $TRUE;
return;
@ -204,13 +209,18 @@ function Resolve-IcingaForWindowsManagementConsoleInstallationDirectorTemplate()
Disable-IcingaFrameworkConsoleOutput;
$HostRegisterSetting = (Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectHostname');
$HostRegisterSetting = Get-IcingaForWindowsInstallerStepSelection -InstallerStep 'Show-IcingaForWindowsInstallerMenuSelectHostname';
if ($null -ne $HostRegisterSetting -And $HostnameSelection -ne $HostRegisterSetting) {
$HostnameSelection = $HostRegisterSetting;
}
Show-IcingaForWindowsInstallerMenuSelectHostname -DefaultInput $HostnameSelection -Automated;
if ($HostnameSelection -eq '6') {
Show-IcingaForWindowsInstallationMenuEnterCustomHostname -Value $CustomHostname -Automated;
}
Add-IcingaForWindowsInstallationAdvancedEntries;
Disable-IcingaFrameworkConsoleOutput;

View file

@ -1,19 +1,20 @@
function Show-IcingaForWindowsInstallerMenuFinishInstaller()
{
if ($global:Icinga.InstallWizard.DirectorSelfService -eq $TRUE -And $global:Icinga.InstallWizard.DirectorRegisteredHost -eq $FALSE) {
$global:Icinga.InstallWizard.LastNotice = 'To install this host while using "Icinga Director Self-Service API", you need to register the host in the previous step first.';
$global:Icinga.InstallWizard.LastNotice = 'You are using the Icinga Director Self-Service API but have not registered the host inside the Self-Service API on the previous menu';
}
Show-IcingaForWindowsInstallerMenu `
-Header 'How you do want to proceed:' `
-Entries @(
@{
'Caption' = 'Start installation';
'Command' = 'Start-IcingaForWindowsInstallation';
'Help' = 'Apply the just configured configuration and install components as selected';
'Disabled' = (-Not ($global:Icinga.InstallWizard.AdminShell) -Or ($global:Icinga.InstallWizard.DirectorSelfService -eq $TRUE -And $global:Icinga.InstallWizard.DirectorRegisteredHost -eq $FALSE));
'Action' = @{
'Caption' = 'Start installation';
'Command' = 'Start-IcingaForWindowsInstallation';
'Help' = 'Apply the just configured configuration and install components as selected';
'Disabled' = ($global:Icinga.InstallWizard.DirectorSelfService -eq $TRUE -And $global:Icinga.InstallWizard.DirectorRegisteredHost -eq $FALSE);
'DisabledReason' = 'You are using the Icinga Director Self-Service API but have not registered the host inside the Self-Service API on the previous menu';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Clear-IcingaForWindowsManagementConsolePaginationCache';
}
},

View file

@ -13,7 +13,7 @@ function Export-IcingaForWindowsManagementConsoleInstallationAnswerFile()
$global:Icinga.InstallWizard.LastNotice = ([string]::Format('Answer file "IfW_answer.json" successfully exported into "{0}"', $FilePath));
Clear-IcingaForWindowsManagementConsolePaginationCache;
} else {
$global:Icinga.InstallWizard.LastError = ([string]::Format('The provided path to store the answer file is invalid: "{0}"', $FilePath));
$global:Icinga.InstallWizard.LastError += ([string]::Format('The provided path to store the answer file is invalid: "{0}"', $FilePath));
$global:Icinga.InstallWizard.NextCommand = 'Show-IcingaForWindowsManagementConsoleInstallationFileExport';
}
}

View file

@ -0,0 +1,30 @@
function Show-IcingaForWindowsInstallationMenuEnterCustomHostname()
{
param (
[array]$Value = @( (Get-IcingaHostname -AutoUseHostname 1 -LowerCase 1) ),
[string]$DefaultInput = 'c',
[switch]$JumpToSummary = $FALSE,
[switch]$Automated = $FALSE,
[switch]$Advanced = $FALSE
);
Show-IcingaForWindowsInstallerMenu `
-Header 'Please enter your hostname:' `
-Entries @(
@{
'Command' = 'Show-IcingaForWindowsInstallerMenuEnterIcingaParentZone';
'Help' = 'A custom hostname being used for generating certificates and for usage within Icinga';
}
) `
-DefaultIndex $DefaultInput `
-AddConfig `
-ConfigLimit 1 `
-DefaultValues $Value `
-MandatoryValue `
-JumpToSummary:$JumpToSummary `
-ConfigElement `
-Automated:$Automated `
-Advanced:$Advanced;
}
Set-Alias -Name 'IfW-CustomHostname' -Value 'Show-IcingaForWindowsInstallationMenuEnterCustomHostname';

View file

@ -39,7 +39,7 @@ function Show-IcingaForWindowsInstallerMenuEnterIcingaParentAddresses()
continue;
}
$global:Icinga.InstallWizard.LastError = ([string]::Format('Failed to resolve the address for the following endpoint: {0}', $EndpointConfig.Endpoint));
$global:Icinga.InstallWizard.LastError += ([string]::Format('Failed to resolve the address for the following endpoint: {0}', $EndpointConfig.Endpoint));
$Address = Get-IcingaForWindowsInstallerValuesFromStep -InstallerStep 'Show-IcingaForWindowsInstallerMenuEnterIcingaParentAddresses' -Parent $EndpointConfig.Endpoint;

View file

@ -8,8 +8,6 @@ function Show-IcingaForWindowsInstallerMenuSelectForceCertificateGeneration()
[switch]$Advanced = $FALSE
);
$Global:Icinga.InstallWizard.DirectorSelfService = $FALSE;
Show-IcingaForWindowsInstallerMenu `
-Header 'Do you want to force the creation of possible existing Icinga Agent certificates?' `
-Entries @(

View file

@ -40,6 +40,11 @@ function Show-IcingaForWindowsInstallerMenuSelectHostname()
'Caption' = ([string]::Format('"{0}": Hostname (uppercase)', (Get-IcingaHostname -AutoUseHostname 1 -UpperCase 1)));
'Command' = 'Show-IcingaForWindowsInstallerMenuEnterIcingaParentZone';
'Help' = 'This will use the hostname only without FQDN extension and modify all characters to uppercase';
},
@{
'Caption' = 'Set custom Hostname';
'Command' = 'Show-IcingaForWindowsInstallationMenuEnterCustomHostname';
'Help' = 'Allows you to set a custom hostname';
}
) `
-DefaultIndex $DefaultInput `
@ -47,6 +52,16 @@ function Show-IcingaForWindowsInstallerMenuSelectHostname()
-ConfigElement `
-Automated:$Automated `
-Advanced:$Advanced;
$LastInput = Get-IcingaForWindowsManagementConsoleLastInput;
if ([string]::IsNullOrEmpty($LastInput) -eq $FALSE -and $LastInput -ne '6') {
# Remove the set hostname in case we choose a different option
Remove-IcingaForWindowsInstallerConfigEntry -Menu 'Show-IcingaForWindowsInstallationMenuEnterCustomHostname';
} elseif ($LastInput -eq '6' -And $JumpToSummary) {
$global:Icinga.InstallWizard.NextCommand = 'Show-IcingaForWindowsInstallationMenuEnterCustomHostname';
$global:Icinga.InstallWizard.NextArguments = @{ 'JumpToSummary' = $TRUE; };
}
}
Set-Alias -Name 'IfW-Hostname' -Value 'Show-IcingaForWindowsInstallerMenuSelectHostname';

View file

@ -1,81 +0,0 @@
function Show-IcingaForWindowsMenuManageIcingaAgent()
{
$IcingaService = Get-Service 'icinga2' -ErrorAction SilentlyContinue;
$AdminShell = $global:Icinga.InstallWizard.AdminShell;
$ServiceStatus = $null;
if ($null -ne $IcingaService) {
$ServiceStatus = $IcingaService.Status;
}
Show-IcingaForWindowsInstallerMenu `
-Header 'Manage Icinga Agent:' `
-Entries @(
@{
'Caption' = 'Manage Features';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaAgentFeatures';
'Help' = 'Allows you to install Icinga for Windows with all required components and options';
'Disabled' = ($null -eq $IcingaService -Or (-Not $AdminShell));
},
@{
'Caption' = 'Read Icinga Agent Log File';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaAgent';
'Help' = 'Allows to read the Icinga Agent log file in case the "mainlog" feature of the Icinga Agent is enabled';
'Disabled' = ((-Not $AdminShell) -Or -Not (Test-IcingaAgentFeatureEnabled -Feature 'mainlog'));
'Action' = @{
'Command' = 'Start-Process';
'Arguments' = @{ '-FilePath' = 'powershell.exe'; '-ArgumentList' = "-Command `"&{ icinga { Read-IcingaAgentLogFile; }; }`"" };
}
},
@{
'Caption' = 'Read Icinga Debug Log File';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaAgent';
'Help' = 'Allows to read the Icinga Agent debug log file in case the "debuglog" feature of the Icinga Agent is enabled';
'Disabled' = ((-Not $AdminShell) -Or -Not (Test-IcingaAgentFeatureEnabled -Feature 'debuglog'));
'Action' = @{
'Command' = 'Start-Process';
'Arguments' = @{ '-FilePath' = 'powershell.exe'; '-ArgumentList' = "-Command `"&{ icinga { Read-IcingaAgentDebugLogFile; }; }`"" };
}
},
@{
'Caption' = 'Flush API directory (will restart Agent)';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaAgent';
'Help' = 'Allows you to flush the Icinga Agent API directory for cleanup. This will restart the Icinga Agent';
'Disabled' = ($null -eq $IcingaService -Or (-Not $AdminShell));
'Action' = @{
'Command' = 'Clear-IcingaAgentApiDirectory';
'Arguments' = @{ '-Force' = $TRUE };
}
},
@{
'Caption' = 'Start Icinga Agent';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaAgent';
'Help' = 'Allows you to start the Icinga Agent if the service is not running';
'Disabled' = ($null -eq $IcingaService -Or $ServiceStatus -eq 'Running' -Or (-Not $AdminShell));
'Action' = @{
'Command' = 'Start-Service';
'Arguments' = @{ '-Name' = 'icinga2'; };
}
},
@{
'Caption' = 'Stop Icinga Agent';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaAgent';
'Help' = 'Allows you to stop the Icinga Agent if the service is not running';
'Disabled' = ($null -eq $IcingaService -Or $ServiceStatus -ne 'Running' -Or (-Not $AdminShell));
'Action' = @{
'Command' = 'Stop-Service';
'Arguments' = @{ '-Name' = 'icinga2'; };
}
},
@{
'Caption' = 'Restart Icinga Agent';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaAgent';
'Help' = 'Allows you to restart the Icinga Agent if the service is installed';
'Disabled' = ($null -eq $IcingaService -Or (-Not $AdminShell));
'Action' = @{
'Command' = 'Restart-Service';
'Arguments' = @{ '-Name' = 'icinga2'; };
}
}
);
}

View file

@ -3,8 +3,8 @@ function Invoke-IcingaForWindowsManagementConsoleReconfigureAgent()
$LiveConfig = Get-IcingaPowerShellConfig -Path 'Framework.Config.Live';
if ($null -eq $LiveConfig) {
$global:Icinga.InstallWizard.NextCommand = 'Show-IcingaForWindowsMenuManageIcingaAgent';
$global:Icinga.InstallWizard.LastError = 'Unable to load any previous live configuration. Reconfiguring not possible.';
$global:Icinga.InstallWizard.NextCommand = 'Show-IcingaForWindowsInstallerMenuInstallWindows';
$global:Icinga.InstallWizard.LastError += 'Unable to load any previous live configuration. Reconfiguring not possible.';
return;
}

View file

@ -1,8 +1,13 @@
function Show-IcingaForWindowsManagementConsoleFrameworkExperimental()
{
$ApiChecks = Get-IcingaFrameworkApiChecks;
[array]$Entries = @();
Show-IcingaForWindowsInstallerMenu `
if ($Entries.Count -ne 0) {
Show-IcingaForWindowsInstallerMenu `
-Header 'Manage Icinga for Windows experimental features. Not recommended for production!' `
-Entries @();
-Entries $Entries;
} else {
Show-IcingaForWindowsInstallerMenu `
-Header 'No experimental features for Icinga for Windows available';
}
}

View file

@ -0,0 +1,35 @@
function Show-IcingaForWindowsManagementConsoleManageIcingaForWindowsFeatures()
{
$FrameworkDebug = Get-IcingaFrameworkDebugMode;
$ApiChecks = Get-IcingaFrameworkApiChecks;
Show-IcingaForWindowsInstallerMenu `
-Header 'Manage Icinga for Windows features:' `
-Entries @(
@{
'Caption' = ([string]::Format('Api-Check Forwarder: {0}', (& { if ($ApiChecks) { 'Enabled' } else { 'Disabled' } } )));
'Command' = 'Show-IcingaForWindowsManagementConsoleManageIcingaForWindowsFeatures';
'Help' = 'In case enabled, all check commands executed by "Exit-IcingaExecutePlugin" (Icinga default) are forwarded to an internal REST-Api and executed from within the Icinga for Windows background daemon. Requires the Icinga for Windows background daemon';
'Disabled' = $FALSE;
'Action' = @{
'Command' = 'Invoke-IcingaForWindowsManagementConsoleToggleFrameworkApiChecks';
'Arguments' = @{ };
}
},
@{
'Caption' = ([string]::Format('Debug Mode: {0}', (& { if ($FrameworkDebug) { 'Enabled' } else { 'Disabled' } } )));
'Command' = 'Show-IcingaForWindowsManagementConsoleManageIcingaForWindowsFeatures';
'Help' = 'Disable or enable the Icinga for Windows debug mode';
'Disabled' = $FALSE;
'Action' = @{
'Command' = 'Invoke-IcingaForWindowsManagementConsoleToggleFrameworkDebug';
}
},
@{
'Caption' = 'Experimental';
'Command' = 'Show-IcingaForWindowsManagementConsoleFrameworkExperimental';
'Help' = 'Allows you to manage experimental features for Icinga for Windows';
'Disabled' = $FALSE
}
);
}

View file

@ -1,114 +0,0 @@
function Show-IcingaForWindowsManagementConsoleManageFramework()
{
$FrameworkDebug = Get-IcingaFrameworkDebugMode;
$ApiChecks = Get-IcingaFrameworkApiChecks;
$IcingaService = Get-Service 'icingapowershell' -ErrorAction SilentlyContinue;
$AdminShell = $global:Icinga.InstallWizard.AdminShell;
$ServiceStatus = $null;
$JEADisabled = $FALSE;
if ($PSVersionTable.PSVersion -lt (New-IcingaVersionObject -Version 5, 0) -Or $AdminShell -eq $FALSE) {
$JEADisabled = $TRUE;
}
if ($null -ne $IcingaService) {
$ServiceStatus = $IcingaService.Status;
}
Show-IcingaForWindowsInstallerMenu `
-Header 'Manage Icinga for Windows:' `
-Entries @(
@{
'Caption' = 'Manage background daemons';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageBackgroundDaemons';
'Help' = 'Allows you to manage Icinga for Windows background daemons';
'Disabled' = ($null -eq (Get-Service 'icingapowershell' -ErrorAction SilentlyContinue));
'DisabledReason' = 'Icinga for Windows service is not installed';
},
@{
'Caption' = 'Manage Icinga Repositories';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageIcingaRepositories';
'Help' = 'Allows you to manage Icinga for Windows repositories';
},
@{
'Caption' = 'Manage JEA profile';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageJEA';
'Help' = 'Allows you to manage Icinga for Windows JEA profile';
'Disabled' = $JEADisabled;
'DisabledReason' = ([string]::Format('PowerShell version "{0}" is lower than 5.0 or you are not inside an administrative shell', $PSVersionTable.PSVersion.ToString(2)));
},
@{
'Caption' = ([string]::Format('Forward checks to Api: {0}', (& { if ($ApiChecks) { 'Enabled' } else { 'Disabled' } } )));
'Command' = 'Show-IcingaForWindowsManagementConsoleManageFramework';
'Help' = 'In case enabled, all check commands executed by "Exit-IcingaExecutePlugin" are forwarded to an internal REST-Api and executed from within the Icinga for Windows background daemon. Requires the Icinga for Windows background daemon';
'Disabled' = $FALSE;
'Action' = @{
'Command' = 'Invoke-IcingaForWindowsManagementConsoleToggleFrameworkApiChecks';
'Arguments' = @{ };
}
},
@{
'Caption' = ([string]::Format('Framework Debug Mode: {0}', (& { if ($FrameworkDebug) { 'Enabled' } else { 'Disabled' } } )));
'Command' = 'Show-IcingaForWindowsManagementConsoleManageFramework';
'Help' = 'Disable or enable the Icinga PowerShell Framework debug mode';
'Disabled' = $FALSE;
'Action' = @{
'Command' = 'Invoke-IcingaForWindowsManagementConsoleToggleFrameworkDebug';
}
},
@{
'Caption' = 'Update Framework Code Cache';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageFramework';
'Help' = 'Updates the Icinga PowerShell Framework Code Cache';
'Action' = @{
'Command' = 'Write-IcingaFrameworkCodeCache';
}
},
@{
'Caption' = 'Allow untrusted certificate communication (this session only)';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageFramework';
'Help' = 'Enables the Icinga untrusted certificate validation, allowing you to communicate with web servers which ships with a self-signed certificate not installed on this system. This applies only to this PowerShell session and is not permanent. Might be helpful in case you want to connect to the Icinga Director and the SSL is not trusted by this host';
'Disabled' = $FALSE
'Action' = @{
'Command' = 'Enable-IcingaUntrustedCertificateValidation';
}
},
@{
'Caption' = 'Configure experimental features';
'Command' = 'Show-IcingaForWindowsManagementConsoleFrameworkExperimental';
'Help' = 'Allows you to manage experimental features for Icinga for Windows';
'Disabled' = $FALSE
},
@{
'Caption' = 'Start Icinga for Windows Service';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageFramework';
'Help' = 'Allows you to start the Icinga for Windows Service if the service is not running';
'Disabled' = ($null -eq $IcingaService -Or $ServiceStatus -eq 'Running' -Or (-Not $AdminShell));
'DisabledReason' = 'The service is either not installed, already running or you are not inside an administrative shell';
'Action' = @{
'Command' = 'Start-Service';
'Arguments' = @{ '-Name' = 'icingapowershell'; };
}
},
@{
'Caption' = 'Stop Icinga for Windows Service';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageFramework';
'Help' = 'Allows you to stop the Icinga for Windows Service if the service is not running';
'Disabled' = ($null -eq $IcingaService -Or $ServiceStatus -ne 'Running' -Or (-Not $AdminShell));
'DisabledReason' = 'The service is either not installed, already stopped or you are not inside an administrative shell';
'Action' = @{
'Command' = 'Stop-IcingaWindowsService';
}
},
@{
'Caption' = 'Restart Icinga for Windows Service';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageFramework';
'Help' = 'Allows you to restart the Icinga for Windows Service if the service is installed';
'Disabled' = ($null -eq $IcingaService -Or (-Not $AdminShell));
'DisabledReason' = 'The service is either not installed or you are not inside an administrative shell';
'Action' = @{
'Command' = 'Restart-IcingaWindowsService';
}
}
);
}

View file

@ -3,6 +3,16 @@ function Invoke-IcingaForWindowsManagementConsoleToggleFrameworkApiChecks()
if (Get-IcingaFrameworkApiChecks) {
Disable-IcingaFrameworkApiChecks;
} else {
if ((Get-IcingaBackgroundDaemons).ContainsKey('Start-IcingaWindowsRESTApi') -eq $FALSE) {
Register-IcingaBackgroundDaemon -Command 'Start-IcingaWindowsRESTApi';
Add-IcingaRESTApiCommand -Command 'Invoke-IcingaCheck*' -Endpoint 'apichecks';
}
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
Install-IcingaForWindowsCertificate;
}
Enable-IcingaFrameworkApiChecks;
}
Restart-IcingaWindowsService;
}

View file

@ -0,0 +1,30 @@
function Show-IcingaForWindowsManagementConsoleComponentManager()
{
Show-IcingaForWindowsInstallerMenu `
-Header 'Choose what you want to do with components' `
@{
'Caption' = 'Install';
'Command' = 'Show-IcingaForWindowsMenuInstallComponents';
'Help' = 'Allows you to install new components for Icinga for Windows from your repositories.';
},
@{
'Caption' = 'Install from Snapshot';
'Command' = 'Show-IcingaForWindowsMenuInstallComponentsSnapshot';
'Help' = 'Allows you to install new components for Icinga for Windows from your repositories.';
},
@{
'Caption' = 'Update';
'Command' = 'Show-IcingaForWindowsMenuUpdateComponents';
'Help' = 'Allows you to modify your current Icinga for Windows installation.';
},
@{
'Caption' = 'Update from Snapshot';
'Command' = 'Show-IcingaForWindowsMenuUpdateComponentsSnapshot';
'Help' = 'Allows you to modify your current Icinga for Windows installation.';
},
@{
'Caption' = 'Remove';
'Command' = 'Show-IcingaForWindowsMenuRemoveComponents';
'Help' = 'Allows you to modify your current Icinga for Windows installation.';
}
}

View file

@ -1,7 +1,21 @@
function Show-IcingaForWindowsManagementConsoleManageJEA()
{
[bool]$JEAContext = (-Not [string]::IsNullOrEmpty((Get-IcingaJEAContext)));
$ServiceData = Get-IcingaAgentInstallation;
$ServiceUser = 'No service installed';
if ($ServiceData.Installed -eq $FALSE) {
$ServiceData = Get-IcingaServices 'icingapowershell';
if ($null -ne $ServiceData) {
$ServiceUser = $ServiceData.icingapowershell.configuration.ServiceUser;
}
} else {
$ServiceUser = $ServiceData.User;
}
Show-IcingaForWindowsInstallerMenu `
-Header 'Manage Icinga for Windows JEA configuration:' `
-Header ([string]::Format('Manage Icinga for Windows JEA configuration:{0}=> Current User: {1}{0}=> JEA installed: {2}', (New-IcingaNewLine), $ServiceUser, $JEAContext)) `
-DefaultIndex '0' `
-Entries @(
@{
'Caption' = 'Install JEA profile with managed user "icinga"';
@ -10,24 +24,45 @@ function Show-IcingaForWindowsManagementConsoleManageJEA()
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Install JEA profile with managed user "icinga"';
'-Command' = 'Install-IcingaSecurity';
'-Caption' = 'Install JEA profile with managed user "icinga"';
'-Command' = 'Install-IcingaSecurity';
'-CmdArguments' = @{
'-RebuildFramework' = $TRUE;
}
}
}
},
@{
'Caption' = 'Install/Update JEA profile';
'Caption' = 'Install JEA profile without managed user';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageJEA';
'Help' = 'Installs or updates the JEA profile for Icinga for Windows for the current user assigned to the "icinga2" service';
'Help' = 'Installs the JEA profile for Icinga for Windows for the current user assigned to the "icinga2" service';
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Install/Update JEA profile';
'-Command' = 'Install-IcingaJEAProfile';
'-Caption' = 'Install JEA profile without managed user';
'-Command' = 'Install-IcingaJEAProfile';
'-CmdArguments' = @{
'-RebuildFramework' = $TRUE;
}
}
}
},
@{
'Caption' = 'Update JEA profile';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageJEA';
'Help' = 'Update JEA profile';
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Update JEA profile';
'-Command' = 'Install-IcingaJEAProfile';
'-CmdArguments' = @{
'-RebuildFramework' = $TRUE;
}
}
}
},
<#@{
'Caption' = 'Install JEA profile with "ConstrainedLanguage" and managed user "icinga"';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageJEA';
'Help' = 'Will create a managed user called "icinga", updates the services "icinga2" and "icingapowershell" with the new user and creates a JEA profile with "ConstrainedLanguage" based on installed modules. This is NOT recommended in case you are using the Icinga for Windows service, as it will not work in "ConstrainedLanguage" mode';
@ -56,7 +91,7 @@ function Show-IcingaForWindowsManagementConsoleManageJEA()
}
}
}
},
},#>
@{
'Caption' = 'Uninstall JEA profile and managed user "icinga"';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageJEA';
@ -70,31 +105,16 @@ function Show-IcingaForWindowsManagementConsoleManageJEA()
}
},
@{
'Caption' = 'Uninstall JEA profile';
'Caption' = 'Uninstall JEA profile without managed user';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageJEA';
'Help' = 'Uninstalls the JEA profile from this system';
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Uninstall JEA profile';
'-Caption' = 'Uninstall JEA profile without managed user';
'-Command' = 'Uninstall-IcingaJEAProfile';
}
}
},
@{
'Caption' = 'Rebuild Icinga PowerShell Framework dependency cache';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageJEA';
'Help' = 'Rebuilds the Icinga for Windows Framework dependency cache for JEA profile generation';
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Rebuild Icinga PowerShell Framework dependency cache';
'-Command' = 'Get-IcingaJEAConfiguration';
'-CmdArguments' = @{
'-RebuildFramework' = $TRUE;
}
}
}
}
);
}

View file

@ -0,0 +1,54 @@
function Show-IcingaForWindowsMenuInstallComponentsSnapshot()
{
$IcingaInstallation = Get-IcingaComponentList -Snapshot;
$CurrentComponents = Get-IcingaInstallation -Snapshot;
[int]$MaxComponentLength = Get-IcingaMaxTextLength -TextArray $IcingaInstallation.Components.Keys;
[array]$InstallList = @();
foreach ($entry in $IcingaInstallation.Components.Keys) {
$LatestVersion = $IcingaInstallation.Components[$entry];
$LockedVersion = Get-IcingaComponentLock -Name $entry;
$VersionText = $LatestVersion;
# Only show not installed components
if ($CurrentComponents.ContainsKey($entry)) {
continue;
}
if ($null -ne $LockedVersion) {
$VersionText = [string]::Format('{0}*', $LockedVersion);
$LatestVersion = $LockedVersion;
}
$InstallList += @{
'Caption' = ([string]::Format('{0} [{1}]', (Add-IcingaWhiteSpaceToString -Text $entry -Length $MaxComponentLength), $VersionText));
'Command' = 'Show-IcingaForWindowsMenuInstallComponents';
'Help' = ([string]::Format('This will install the component "{0}" with version "{1}"', $entry, $VersionText));
'Disabled' = $FALSE;
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = ([string]::Format('Install component "{0}" with version "{1}"', $entry, $VersionText));
'-Command' = 'Install-IcingaComponent';
'-CmdArguments' = @{
'-Name' = $entry;
'-Version' = $LatestVersion;
'-Snapshot' = $TRUE;
'-Force' = $TRUE;
'-Confirm' = $TRUE;
}
}
}
}
}
if ($InstallList.Count -ne 0) {
Show-IcingaForWindowsInstallerMenu `
-Header 'Install Icinga for Windows components. Select an entry to continue:' `
-Entries $InstallList;
} else {
Show-IcingaForWindowsInstallerMenu `
-Header 'There are no packages found for installation'
}
}

View file

@ -1,19 +1,65 @@
function Show-IcingaForWindowsMenuManage()
{
$AgentInstalled = (Get-IcingaAgentInstallation).Installed;
$JEADisabled = $FALSE;
if ($PSVersionTable.PSVersion -lt (New-IcingaVersionObject -Version 5, 0)) {
$JEADisabled = $TRUE;
}
Show-IcingaForWindowsInstallerMenu `
-Header 'Manage Icinga for Windows:' `
-Header 'Icinga for Windows Settings:' `
-Entries @(
@{
'Caption' = 'Icinga Agent';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaAgent';
'Help' = 'Allows you to manage the installed Icinga Agent';
'Disabled' = (-Not ([bool](Get-Service 'icinga2' -ErrorAction SilentlyContinue)));
'Caption' = 'Services';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaForWindowsServices';
'Help' = 'Allows you to manage the Icinga Agent and Icinga for Windows service';
'Disabled' = (-Not $AgentInstalled -And -Not ([bool](Get-Service 'icingapowershell' -ErrorAction SilentlyContinue)));
'AdminMenu' = $TRUE;
},
@{
'Caption' = 'Icinga PowerShell Framework';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageFramework';
'Help' = 'Allows you to modify certain settings for the Icinga PowerShell Framework and to register background daemons';
}<#,
'Caption' = 'Icinga Agent Features';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaAgentFeatures';
'Help' = 'Allows you to install Icinga for Windows with all required components and options';
'Disabled' = (-Not $AgentInstalled);
'AdminMenu' = $TRUE;
},
@{
'Caption' = 'Background Daemons';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageBackgroundDaemons';
'Help' = 'Allows you to manage Icinga for Windows background daemons';
'Disabled' = ($null -eq (Get-Service 'icingapowershell' -ErrorAction SilentlyContinue));
'DisabledReason' = 'Icinga for Windows service is not installed';
},
@{
'Caption' = 'Repositories';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageIcingaRepositories';
'Help' = 'Allows you to manage Icinga for Windows repositories';
},
@{
'Caption' = 'JEA';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageJEA';
'Help' = 'Allows you to manage Icinga for Windows JEA profile';
'Disabled' = $JEADisabled;
'DisabledReason' = ([string]::Format('PowerShell version "{0}" is lower than 5.0 or you are not inside an administrative shell', $PSVersionTable.PSVersion.ToString(2)));
'AdminMenu' = $TRUE;
},
@{
'Caption' = 'Logging';
'Command' = 'Show-IcingaForWindowsMenuManageViewLogs';
'Help' = 'View different logs';
},
@{
'Caption' = 'Icinga for Windows Features';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageIcingaForWindowsFeatures';
'Help' = 'Allows you to modify certain settings for Icinga for Windows';
},
@{
'Caption' = 'Troubleshooting';
'Command' = 'Show-IcingaForWindowsMenuManageTroubleshooting';
'Help' = 'Resolve problems with your Icinga for Windows environment with pre-defined actions';
}
<#,
@{
'Caption' = 'Health Check';
'Command' = '';

View file

@ -24,14 +24,14 @@ function Show-IcingaForWindowsMenuRemoveComponents()
}
$UninstallFeatures += @{
'Caption' = 'Uninstall Icinga Agent (include ProgramData)';
'Caption' = 'Uninstall Icinga Agent including ProgramData';
'Command' = 'Show-IcingaForWindowsMenuRemoveComponents';
'Help' = 'Will remove the Icinga Agent from this system. Please note that this option will leave content inside "ProgramData", like certificates, alone'
'Disabled' = (-Not (Test-Path -Path (Join-Path -Path $Env:ProgramData -ChildPath 'icinga2')));
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Uninstall Icinga Agent (include ProgramData)';
'-Caption' = 'Uninstall Icinga Agent including ProgramData';;
'-Command' = 'Uninstall-IcingaComponent';
'-CmdArguments' = @{
'-Name' = 'agent';
@ -59,14 +59,14 @@ function Show-IcingaForWindowsMenuRemoveComponents()
}
$UninstallFeatures += @{
'Caption' = 'Uninstall Icinga for Windows Service (include files)';
'Caption' = 'Uninstall Icinga for Windows Service including binary';
'Command' = 'Show-IcingaForWindowsMenuRemoveComponents';
'Help' = 'This will remove the icingapowershell service for Icinga for Windows if installed and the service binary including the folder, if empty afterwards'
'Disabled' = (-Not (Test-Path $IcingaWindowsServiceData.Directory));
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Uninstall Icinga for Windows service (include files)';
'-Caption' = 'Uninstall Icinga for Windows Service including binary';
'-Command' = 'Uninstall-IcingaComponent';
'-CmdArguments' = @{
'-Name' = 'service';
@ -78,7 +78,7 @@ function Show-IcingaForWindowsMenuRemoveComponents()
foreach ($module in $ModuleList) {
$ComponentName = $module.Name.Replace('icinga-powershell-', '');
$Caption = ([string]::Format('Uninstall component "{0}"', $ComponentName));
$Caption = ([string]::Format('Uninstall "{0}"', $ComponentName));
if ($ComponentName -eq 'framework' -Or $ComponentName -eq 'service' -Or $ComponentName -eq 'agent') {
continue;
@ -102,6 +102,39 @@ function Show-IcingaForWindowsMenuRemoveComponents()
}
}
$UninstallFeatures += @{
'Caption' = 'Uninstall all components';
'Command' = 'Show-IcingaForWindowsMenuRemoveComponents';
'Help' = 'This will remove all current installed components of Icinga for Windows, but will keep the Framework installed'
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Uninstall all components';
'-Command' = 'Uninstall-IcingaForWindows';
'-CmdArguments' = @{
'-Force' = $TRUE;
'-ComponentsOnly' = $TRUE;
}
}
}
}
$UninstallFeatures += @{
'Caption' = 'Uninstall Icinga for Windows';
'Command' = 'Show-IcingaForWindowsMenuRemoveComponents';
'Help' = 'This will remove everything installed and configured by Icinga for Windows on this machine'
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Uninstall Icinga for Windows';
'-Command' = 'Uninstall-IcingaForWindows';
'-CmdArguments' = @{
'-Force' = $TRUE;
}
}
}
}
Show-IcingaForWindowsInstallerMenu `
-Header 'Uninstall Icinga for Windows components. Select an entry to continue:' `
-Entries $UninstallFeatures;

View file

@ -19,15 +19,19 @@ function Show-IcingaForWindowsMenuUpdateComponents()
continue;
}
if ([Version]$Component.CurrentVersion -eq [Version]$LatestVersion) {
continue;
}
$UpdateList += @{
'Caption' = ([string]::Format('{0} [{1}] => [{2}]', (Add-IcingaWhiteSpaceToString -Text $entry -Length $MaxComponentLength), $Component.CurrentVersion, $LatestVersion));
'Command' = 'Show-IcingaForWindowsMenuUpdateComponents';
'Help' = ([string]::Format('This will update the component "{0}" from current version "{1}" to stable version "{2}"', $entry, $Component.CurrentVersion, $LatestVersion));
'Help' = ([string]::Format('This will update "{0}" from current version "{1}" to stable version "{2}"', $entry, $Component.CurrentVersion, $LatestVersion));
'Disabled' = $FALSE;
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = ([string]::Format('Update component "{0}" from version "{1}" to stable version "{2}"', $entry, $Component.CurrentVersion, $LatestVersion));
'-Caption' = ([string]::Format('Update "{0}" from version "{1}" to stable version "{2}"', $entry, $Component.CurrentVersion, $LatestVersion));
'-Command' = 'Update-Icinga';
'-CmdArguments' = @{
'-Name' = $entry;

View file

@ -0,0 +1,70 @@
function Show-IcingaForWindowsMenuUpdateComponentsSnapshot()
{
$IcingaInstallation = Get-IcingaInstallation -Snapshot;
[int]$MaxComponentLength = Get-IcingaMaxTextLength -TextArray $IcingaInstallation.Keys;
[array]$UpdateList = @();
foreach ($entry in $IcingaInstallation.Keys) {
$Component = $IcingaInstallation[$entry];
$LatestVersion = $Component.LatestVersion;
if ([string]::IsNullOrEmpty($Component.LockedVersion) -eq $FALSE) {
if ([Version]$Component.CurrentVersion -ge [Version]$Component.LockedVersion) {
continue;
}
$LatestVersion = [string]::Format('{0}*', $Component.LockedVersion);
}
if ([string]::IsNullOrEmpty($LatestVersion)) {
continue;
}
$UpdateList += @{
'Caption' = ([string]::Format('{0} [{1}] => [snapshot]', (Add-IcingaWhiteSpaceToString -Text $entry -Length $MaxComponentLength), $Component.CurrentVersion));
'Command' = 'Show-IcingaForWindowsMenuUpdateComponents';
'Help' = ([string]::Format('This will update "{0}" from current version "{1}" to latest snapshot version', $entry, $Component.CurrentVersion));
'Disabled' = $FALSE;
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = ([string]::Format('Update "{0}" from version "{1}" to latest snapshot version', $entry, $Component.CurrentVersion));
'-Command' = 'Update-Icinga';
'-CmdArguments' = @{
'-Name' = $entry;
'-Snapshot' = $TRUE;
'-Confirm' = $TRUE;
'-Force' = $TRUE;
}
}
}
}
}
if ($UpdateList.Count -ne 0) {
$UpdateList += @{
'Caption' = 'Update entire environment';
'Command' = 'Show-IcingaForWindowsMenuUpdateComponents';
'Help' = 'This will update all components listed above to the mentioned snapshot version'
'Disabled' = $FALSE;
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Update entire Icinga for Windows environment';
'-Command' = 'Update-Icinga';
'-CmdArguments' = @{
'-Snapshot' = $TRUE;
'-Confirm' = $TRUE;
'-Force' = $TRUE;
}
}
}
}
Show-IcingaForWindowsInstallerMenu `
-Header 'Updates Icinga for Windows components. Select an entry to continue:' `
-Entries $UpdateList;
} else {
Show-IcingaForWindowsInstallerMenu `
-Header 'There are no updates pending for your environment'
}
}

View file

@ -0,0 +1,51 @@
function Show-IcingaForWindowsMenuManageViewLogs()
{
Show-IcingaForWindowsInstallerMenu `
-Header 'View all related logs:' `
-Entries @(
@{
'Caption' = 'View Icinga Agent Main Log';
'Command' = 'Show-IcingaForWindowsMenuManageViewLogs';
'Help' = 'Allows to view the Icinga Agent main log in case the "mainlog" feature of the Icinga Agent is enabled';
'Disabled' = ((-Not (Test-IcingaAgentFeatureEnabled -Feature 'mainlog') -And -Not (Test-IcingaAgentFeatureEnabled -Feature 'windowseventlog')));
'DisabledReason' = 'It seems like neither the "mainlog" nor the "windowseventlog" feature of the Icinga Agent is enabled';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Start-Process';
'Arguments' = @{ '-FilePath' = 'powershell.exe'; '-ArgumentList' = "-Command `"&{ icinga { Read-IcingaAgentLogFile; }; }`"" };
}
},
@{
'Caption' = 'View Icinga Agent Debug Log';
'Command' = 'Show-IcingaForWindowsMenuManageViewLogs';
'Help' = 'Allows to read the Icinga Agent debug log in case the "debuglog" feature of the Icinga Agent is enabled';
'Disabled' = (-Not (Test-IcingaAgentFeatureEnabled -Feature 'debuglog'));
'DisabledReason' = 'The "debuglog" feature of the Icinga Agent is not enabled';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Start-Process';
'Arguments' = @{ '-FilePath' = 'powershell.exe'; '-ArgumentList' = "-Command `"&{ icinga { Read-IcingaAgentDebugLogFile; }; }`"" };
}
},
@{
'Caption' = 'View Icinga for Windows EventLog';
'Command' = 'Show-IcingaForWindowsMenuManageViewLogs';
'Help' = 'Allows to read the Icinga for Windows from the EventLog';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Start-Process';
'Arguments' = @{ '-FilePath' = 'powershell.exe'; '-ArgumentList' = "-Command `"&{ icinga { Read-IcingaForWindowsLog; }; }`"" };
}
},
@{
'Caption' = 'View Icinga for Windows Debug EventLog';
'Command' = 'Show-IcingaForWindowsMenuManageViewLogs';
'Help' = 'Allows to read the Icinga for Windows EventLog, filtered by debug messages';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Start-Process';
'Arguments' = @{ '-FilePath' = 'powershell.exe'; '-ArgumentList' = "-Command `"&{ icinga { Read-IcingaWindowsEventLog -LogName 'Icinga for Windows' -Source 'IfW::Debug'; }; }`"" };
}
}
);
}

View file

@ -0,0 +1,101 @@
function Show-IcingaForWindowsMenuManageIcingaForWindowsServices()
{
$IcingaAgentService = Get-Service 'icinga2' -ErrorAction SilentlyContinue;
$IcingaAgentStatus = 'Not Installed';
$IcingaForWindowsService = Get-Service 'icingapowershell' -ErrorAction SilentlyContinue;
$IcingaForWindowsStatus = 'Not Installed';
if ($null -ne $IcingaAgentService) {
$IcingaAgentStatus = $IcingaAgentService.Status;
}
if ($null -ne $IcingaForWindowsService) {
$IcingaForWindowsStatus = $IcingaForWindowsService.Status;
}
Show-IcingaForWindowsInstallerMenu `
-Header ([string]::Format('Manage Services:{0}=> Icinga Agent Service: {1}{0}=> Icinga for Windows Service: {2}', (New-IcingaNewLine), $IcingaAgentStatus, $IcingaForWindowsStatus)) `
-Entries @(
@{
'Caption' = 'Start Icinga Agent Service';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaForWindowsServices';
'Help' = 'Allows you to start the Icinga Agent if the service is not running';
'Disabled' = ($null -eq $IcingaAgentService -Or $IcingaAgentStatus -eq 'Running');
'DisabledReason' = 'The Icinga Agent service is either not installed or the service is already running';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Start-Service';
'Arguments' = @{ '-Name' = 'icinga2'; };
}
},
@{
'Caption' = 'Stop Icinga Agent Service';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaForWindowsServices';
'Help' = 'Allows you to stop the Icinga Agent if the service is not running';
'Disabled' = ($null -eq $IcingaAgentService -Or $IcingaAgentStatus -ne 'Running');
'DisabledReason' = 'The Icinga Agent service is either not installed or the service is not running';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Stop-Service';
'Arguments' = @{ '-Name' = 'icinga2'; };
}
},
@{
'Caption' = 'Restart Icinga Agent Service';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaForWindowsServices';
'Help' = 'Allows you to restart the Icinga Agent if the service is installed';
'Disabled' = ($null -eq $IcingaAgentService);
'DisabledReason' = 'The Icinga Agent service is not installed';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Restart-Service';
'Arguments' = @{ '-Name' = 'icinga2'; };
}
},
@{
'Caption' = 'Repair Icinga Agent Service';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaForWindowsServices';
'Help' = 'Allows to repair the Icinga Agent service in case it was removed or broke during installation/upgrade';
'Disabled' = ($null -ne $IcingaAgentService);
'DisabledReason' = 'The Icinga Agent service is already present';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Repair-IcingaService';
}
},
@{
'Caption' = 'Start Icinga for Windows Service';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaForWindowsServices';
'Help' = 'Allows you to start the Icinga for Windows Service if the service is not running';
'Disabled' = ($null -eq $IcingaForWindowsService -Or $IcingaForWindowsStatus -eq 'Running');
'DisabledReason' = 'The Icinga for Windows service is either not installed or already running';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Start-Service';
'Arguments' = @{ '-Name' = 'icingapowershell'; };
}
},
@{
'Caption' = 'Stop Icinga for Windows Service';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaForWindowsServices';
'Help' = 'Allows you to stop the Icinga for Windows Service if the service is not running';
'Disabled' = ($null -eq $IcingaForWindowsService -Or $IcingaForWindowsStatus -ne 'Running');
'DisabledReason' = 'The Icinga for Windows service is either not installed or not running';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Stop-IcingaWindowsService';
}
},
@{
'Caption' = 'Restart Icinga for Windows Service';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaForWindowsServices';
'Help' = 'Allows you to restart the Icinga for Windows Service if the service is installed';
'Disabled' = ($null -eq $IcingaForWindowsService);
'DisabledReason' = 'The Icinga for Windows service is not installed';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Restart-IcingaWindowsService';
}
}
);
}

View file

@ -0,0 +1,65 @@
function Show-IcingaForWindowsMenuManageTroubleshooting()
{
$IcingaAgentService = Get-Service 'icinga2' -ErrorAction SilentlyContinue;
Show-IcingaForWindowsInstallerMenu `
-Header 'Troubleshooting options for problems:' `
-Entries @(
@{
'Caption' = 'Flush Icinga Agent API directory (Restarts service)';
'Command' = 'Show-IcingaForWindowsMenuManageTroubleshooting';
'Help' = 'Allows you to flush the Icinga Agent API directory for cleanup. This will restart the Icinga Agent service';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Flush Icinga Agent API Directory (Restarts Service)';
'-Command' = 'Clear-IcingaAgentApiDirectory';
'-CmdArguments' = @{
'-Force' = $TRUE;
}
}
}
},
@{
'Caption' = 'Update Icinga for Windows cache';
'Command' = 'Show-IcingaForWindowsMenuManageTroubleshooting';
'Help' = 'Updates the Icinga for Windows Code Cache by re-compiling every module to ensure nothing is missing and up-to-date';
'Action' = @{
'Command' = 'Write-IcingaFrameworkCodeCache';
}
},
@{
'Caption' = 'Install Icinga for Windows certificate';
'Command' = 'Show-IcingaForWindowsManagementConsoleManageJEA';
'Help' = 'Uses the Icinga Agent certificate on this system to create a certificate for Icinga for Windows, which is required inside a JEA context in case the REST-Api feature is used, as the background daemon will be unable to perform certain actions requires for using the certificate otherwise';
'Action' = @{
'Command' = 'Show-IcingaWindowsManagementConsoleYesNoDialog';
'Arguments' = @{
'-Caption' = 'Install Icinga for Windows certificate';
'-Command' = 'Install-IcingaForWindowsCertificate';
}
}
},
@{
'Caption' = 'Repair Icinga Agent service';
'Command' = 'Show-IcingaForWindowsMenuManageIcingaForWindowsServices';
'Help' = 'Allows to repair the Icinga Agent service in case it was removed or broke during installation/upgrade';
'Disabled' = ($null -ne $IcingaAgentService);
'DisabledReason' = 'The Icinga Agent service is already present';
'AdminMenu' = $TRUE;
'Action' = @{
'Command' = 'Repair-IcingaService';
}
},
@{
'Caption' = 'Allow untrusted certificate communication (This session)';
'Command' = 'Show-IcingaForWindowsMenuManageTroubleshooting';
'Help' = 'Enables the Icinga untrusted certificate validation, allowing you to communicate with web servers which ships with a self-signed certificate not installed on this system. This applies only to this PowerShell session and is not permanent. Might be helpful in case you want to connect to the Icinga Director and the SSL is not trusted by this host';
'Disabled' = $FALSE
'Action' = @{
'Command' = 'Enable-IcingaUntrustedCertificateValidation';
}
}
);
}

View file

@ -0,0 +1,6 @@
function Invoke-IcingaForWindowsMenuStartIcingaShell()
{
Clear-Host;
$global:Icinga.InstallWizard.Closing = $TRUE;
Invoke-IcingaCommand -Shell;
}

View file

@ -121,6 +121,10 @@ function Show-IcingaForWindowsInstallerMenu()
$FontColor = 'DarkGray';
}
if ($Global:Icinga.InstallWizard.AdminShell -eq $FALSE -And $null -ne $entry.AdminMenu -And $entry.AdminMenu -eq $TRUE) {
$FontColor = 'DarkGray';
}
# Mark our previous selection in another color for better highlighting
if ($null -ne $SelectionForCurrentMenu -And $SelectionForCurrentMenu -eq $EntryIndex) {
$FontColor = 'Green';
@ -240,15 +244,30 @@ function Show-IcingaForWindowsInstallerMenu()
Write-IcingaConsolePlain '';
if ([string]::IsNullOrEmpty($global:Icinga.InstallWizard.LastError) -eq $FALSE) {
Write-IcingaConsoleError ($global:Icinga.InstallWizard.LastError);
$global:Icinga.InstallWizard.LastError = '';
if ($Global:Icinga.InstallWizard.LastError.Count -ne 0) {
foreach ($entry in $global:Icinga.InstallWizard.LastError) {
if ([string]::IsNullOrEmpty($entry)) {
continue;
}
Write-IcingaConsoleError -Message $entry;
}
$Global:Icinga.InstallWizard.LastError.Clear();
Write-IcingaConsolePlain '';
}
if ($Global:Icinga.InstallWizard.LastWarning.Count -ne 0) {
foreach ($entry in $Global:Icinga.InstallWizard.LastWarning) {
if ([string]::IsNullOrEmpty($entry)) {
continue;
}
Write-IcingaConsoleWarning -Message $entry;
}
$Global:Icinga.InstallWizard.LastWarning.Clear();
Write-IcingaConsolePlain '';
}
if ([string]::IsNullOrEmpty($global:Icinga.InstallWizard.LastNotice) -eq $FALSE) {
Write-IcingaConsoleNotice ($global:Icinga.InstallWizard.LastNotice);
$global:Icinga.InstallWizard.LastNotice = '';
if ([string]::IsNullOrEmpty($Global:Icinga.InstallWizard.LastNotice) -eq $FALSE) {
Write-IcingaConsoleNotice ($Global:Icinga.InstallWizard.LastNotice);
$Global:Icinga.InstallWizard.LastNotice = '';
Write-IcingaConsolePlain '';
}
@ -306,7 +325,7 @@ function Show-IcingaForWindowsInstallerMenu()
return;
}
$global:Icinga.InstallWizard.LastError = 'You cannot move to the previous menu from here.';
$global:Icinga.InstallWizard.LastError += 'You cannot move to the previous menu from here.';
if ($global:Icinga.InstallWizard.LastParent.Count -eq 0) {
$global:Icinga.InstallWizard.NextCommand = $null;
$global:Icinga.InstallWizard.NextArguments = $null;
@ -327,7 +346,7 @@ function Show-IcingaForWindowsInstallerMenu()
};
'c' {
if ($MandatoryValue -And $StoredValues.Count -eq 0) {
$global:Icinga.InstallWizard.LastError = 'You need to add at least one value!';
$global:Icinga.InstallWizard.LastError += 'You need to add at least one value!';
return;
}
@ -357,17 +376,17 @@ function Show-IcingaForWindowsInstallerMenu()
if ($DefaultValues.Count -ne 0) {
$global:Icinga.InstallWizard.LastNotice = 'Empty values are not allowed! Resetting to default.';
} else {
$global:Icinga.InstallWizard.LastError = 'You cannot add an empty value!';
$global:Icinga.InstallWizard.LastError += 'You cannot add an empty value!';
}
}
} else {
$global:Icinga.InstallWizard.LastError = [string]::Format('You can only add {0} value(s)', $ConfigLimit);
$global:Icinga.InstallWizard.LastError += [string]::Format('You can only add {0} value(s)', $ConfigLimit);
}
return;
}
if ((Test-Numeric $Result) -eq $FALSE -Or $KnownIndexes.ContainsKey([string]$Result) -eq $FALSE) {
$global:Icinga.InstallWizard.LastError = [string]::Format('Invalid selection has been made: {0}', $Result);
$global:Icinga.InstallWizard.LastError += [string]::Format('Invalid selection has been made: {0}', $Result);
return;
}
@ -376,6 +395,7 @@ function Show-IcingaForWindowsInstallerMenu()
};
}
[bool]$AdminMenu = $FALSE;
[bool]$DisabledMenu = $FALSE;
[string]$DisabledReason = '';
$NextMenu = $null;
@ -395,6 +415,10 @@ function Show-IcingaForWindowsInstallerMenu()
$DisabledReason = $Entries[0].DisabledReason;
}
}
if ($null -ne $Entries[0].AdminMenu) {
$AdminMenu = $Entries[0].AdminMenu;
}
}
$ActionCmd = $Entries[0].Action.Command;
$ActionArgs = $Entries[0].Action.Arguments;
@ -402,10 +426,15 @@ function Show-IcingaForWindowsInstallerMenu()
$NextMenu = $Entries[$Result].Command;
if ($null -ne $Entries[$Result].Disabled) {
$DisabledMenu = $Entries[$Result].Disabled;
if ($null -ne $Entries[0].DisabledReason) {
$DisabledReason = $Entries[0].DisabledReason;
if ($null -ne $Entries[$Result].DisabledReason) {
$DisabledReason = $Entries[$Result].DisabledReason;
}
}
if ($null -ne $Entries[$Result].AdminMenu) {
$AdminMenu = $Entries[$Result].AdminMenu;
}
if ($Entries[$Result].ContainsKey('Arguments')) {
$NextArguments = $Entries[$Result].Arguments;
}
@ -414,11 +443,17 @@ function Show-IcingaForWindowsInstallerMenu()
}
}
if ($AdminMenu -And (Test-AdministrativeShell) -eq $FALSE) {
$Global:Icinga.InstallWizard.LastNotice = [string]::Format('This menu is not enabled: [{0}] => You require to run this shell in administrative mode', $Result);
return;
}
if ($DisabledMenu) {
if ([string]::IsNullOrEmpty($DisabledReason) -eq $FALSE) {
$DisabledReason = [string]::Format(' => Reason: {0}', $DisabledReason);
}
$global:Icinga.InstallWizard.LastNotice = [string]::Format('This menu is not enabled: {0}{1}', $Result, $DisabledReason);
$global:Icinga.InstallWizard.LastNotice = [string]::Format('This menu is not enabled: [{0}]{1}', $Result, $DisabledReason);
return;
}

View file

@ -24,6 +24,10 @@ function Install-IcingaJEAProfile()
Write-IcingaJEAProfile -RebuildFramework:$RebuildFramework -AllowScriptBlocks:$AllowScriptBlocks;
Write-IcingaConsoleNotice 'Registering Icinga for Windows JEA profile'
Register-IcingaJEAProfile -IcingaUser $IcingaUser -TestEnv:$TestEnv -ConstrainedLanguage:$ConstrainedLanguage;
if ((Get-IcingaBackgroundDaemons).ContainsKey('Start-IcingaWindowsRESTApi')) {
Install-IcingaForWindowsCertificate;
}
}
Set-Alias -Name 'Update-IcingaJEAProfile' -Value 'Install-IcingaJEAProfile';

View file

@ -68,6 +68,19 @@ function Write-IcingaConsoleOutput()
$Index++;
}
if ($Global:Icinga.ContainsKey('InstallWizard') -And [string]::IsNullOrEmpty($OutputMessage) -eq $FALSE) {
if ($Severity -eq 'Error') {
if ($Global:Icinga.InstallWizard.LastError -NotContains $OutputMessage) {
$Global:Icinga.InstallWizard.LastError += $OutputMessage;
}
}
if ($Severity -eq 'Warning') {
if ($Global:Icinga.InstallWizard.LastWarning -NotContains $OutputMessage) {
$Global:Icinga.InstallWizard.LastWarning += $OutputMessage;
}
}
}
if ([string]::IsNullOrEmpty($Severity) -eq $FALSE) {
Write-Host '[' -NoNewline;
Write-Host $Severity -NoNewline -ForegroundColor $ForeColor;

View file

@ -57,6 +57,16 @@ function Get-IcingaComponentList()
continue;
}
if ($Snapshot -And (Test-Numeric $package.Version.Replace('.', '')) -eq $FALSE) {
# Branch snapshot
[string]$SnapshotPackageName = ([string]::Format('{0}/{1}', $repoEntry, $package.Version));
if ($SearchList.Components.ContainsKey($SnapshotPackageName) -eq $FALSE) {
$SearchList.Components.Add($SnapshotPackageName, $package.Version);
}
continue;
}
if ($SearchList.Components.ContainsKey($repoEntry) -eq $FALSE) {
$SearchList.Components.Add($repoEntry, $package.Version);
}

View file

@ -14,6 +14,11 @@ function Install-IcingaComponent()
return;
}
# Branch snapshot versions will have '/' inside their name
if ($Name.Contains('/') -And $Snapshot) {
$Name = $Name.Split('/')[0];
}
Set-IcingaTLSVersion;
if ($Version -eq 'release') {

View file

@ -5,7 +5,7 @@ function Show-Icinga()
);
$IcingaInstallation = Get-IcingaInstallation -Release;
[array]$Output = @( 'Icinga for Windows environment' );
[array]$Output = @( 'Icinga for Windows environment:' );
[array]$VersionList = @();
[int]$MaxComponentLength = Get-IcingaMaxTextLength -TextArray $IcingaInstallation.Keys;
@ -30,31 +30,6 @@ function Show-Icinga()
[array]$Output = @();
}
$Output += 'Installed components on this system';
$Output += '';
$Output += [string]::Format('{0} {1} Available', $ComponentHeader, ((Add-IcingaWhiteSpaceToString -Text 'Version' -Length $MaxVersionLength)));
$Output += [string]::Format('{0} {1} ---', $ComponentLine, ((Add-IcingaWhiteSpaceToString -Text '---' -Length $MaxVersionLength)));
foreach ($component in $IcingaInstallation.Keys) {
$Data = $IcingaInstallation[$component];
$LatestVersion = $Data.LatestVersion;
$CurrentVersion = $Data.CurrentVersion;
if ([string]::IsNullOrEmpty($Data.LockedVersion) -eq $FALSE) {
if ($Data.LockedVersion -eq $Data.CurrentVersion) {
$CurrentVersion = [string]::Format('{0}*', $CurrentVersion);
} else {
$LatestVersion = [string]::Format('{0}*', $Data.LockedVersion);
}
}
[string]$ComponentName = Add-IcingaWhiteSpaceToString -Text $component -Length $MaxComponentLength;
$Output += [string]::Format('{0} {1} {2}', $ComponentName, (Add-IcingaWhiteSpaceToString -Text $CurrentVersion -Length $MaxVersionLength), $LatestVersion);
}
$Output += '';
$Output += 'Available versions flagged with "*" mean that this component is locked to this version';
$IcingaForWindowsService = Get-IcingaForWindowsServiceData;
$IcingaAgentService = Get-IcingaAgentInstallation;
$WindowsInformation = Get-IcingaWindowsInformation Win32_OperatingSystem | Select-Object Version, BuildNumber, Caption;
@ -77,7 +52,7 @@ function Show-Icinga()
}
$Output += '';
$Output += 'Environment configuration';
$Output += 'Environment configuration:';
$Output += '';
$Output += ([string]::Format('PowerShell Root => {0}', (Get-IcingaForWindowsRootPath)));
$Output += ([string]::Format('Icinga for Windows Service Path => {0}', $IcingaForWindowsService.Directory));
@ -103,5 +78,32 @@ function Show-Icinga()
$Output += (Show-IcingaRegisteredServiceChecks);
$Output += (Show-IcingaRepository);
$Output += 'Installed components on this system:';
$Output += '';
$Output += [string]::Format('{0} {1} Available', $ComponentHeader, ((Add-IcingaWhiteSpaceToString -Text 'Version' -Length $MaxVersionLength)));
$Output += [string]::Format('{0} {1} ---', $ComponentLine, ((Add-IcingaWhiteSpaceToString -Text '---' -Length $MaxVersionLength)));
$IcingaInstallation = $IcingaInstallation.GetEnumerator() | Sort-Object -Property Name;
foreach ($component in $IcingaInstallation) {
$Data = $component.Value;
$LatestVersion = $Data.LatestVersion;
$CurrentVersion = $Data.CurrentVersion;
if ([string]::IsNullOrEmpty($Data.LockedVersion) -eq $FALSE) {
if ($Data.LockedVersion -eq $Data.CurrentVersion) {
$CurrentVersion = [string]::Format('{0}*', $CurrentVersion);
} else {
$LatestVersion = [string]::Format('{0}*', $Data.LockedVersion);
}
}
[string]$ComponentName = Add-IcingaWhiteSpaceToString -Text $component.Name -Length $MaxComponentLength;
$Output += [string]::Format('{0} {1} {2}', $ComponentName, (Add-IcingaWhiteSpaceToString -Text $CurrentVersion -Length $MaxVersionLength), $LatestVersion);
}
$Output += '';
$Output += 'Available versions flagged with "*" mean that this component is locked to this version';
Write-Output $Output;
}

View file

@ -2,7 +2,7 @@ function Show-IcingaRepository()
{
[hashtable]$Repositories = @{ };
[array]$RepoSummary = @(
'List of configured repositories on this system. The list order matches the apply order.',
'List of configured repositories on this system. The list order matches the apply order:',
''
);
[array]$RepoList = Get-IcingaRepositories;

View file

@ -39,6 +39,12 @@ function Update-Icinga()
continue;
}
Install-IcingaComponent -Name $entry -Version $NewVersion -Release:$Release -Snapshot:$Snapshot -Confirm:$Confirm -Force:$Force
Install-IcingaComponent -Name $entry -Version $NewVersion -Release:$Release -Snapshot:$Snapshot -Confirm:$Confirm -Force:$Force;
}
# Update JEA profile if JEA is enabled once the update is complete
if ([string]::IsNullOrEmpty((Get-IcingaJEAContext)) -eq $FALSE) {
Update-IcingaJEAProfile;
Restart-IcingaWindowsService;
}
}

View file

@ -1,7 +1,7 @@
function Show-IcingaRegisteredBackgroundDaemons()
{
[array]$DaemonSummary = @(
'List of configured background daemons on this system.',
'List of configured background daemons on this system:',
''
);

View file

@ -1,7 +1,7 @@
function Show-IcingaRegisteredServiceChecks()
{
[array]$ServiceSummary = @(
'List of configured background service checks on this system.',
'List of configured background service checks on this system:',
'=> https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/',
''
);