Skip to content

Commit c129bb6

Browse files
committed
Optimizes IMC and centralizes data
1 parent d5b1162 commit c129bb6

File tree

52 files changed

+840
-359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+840
-359
lines changed

Diff for: doc/100-General/01-Upgrading.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Otherwise the service will not start and crash! You can either download the serv
1616
Update-Icinga -Name 'service';
1717
```
1818

19-
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.
19+
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.
2020

2121
**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.
2222

Diff for: doc/100-General/10-Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
5050
* [#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`
5151
* [#448](https://github.com/Icinga/icinga-powershell-framework/pull/448) Adds support to sort arrays without ScriptBlocks
5252
* [#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
53+
* [#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
5354
* [#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)
5455

5556
## 1.7.1 (2021-11-11)

Diff for: doc/110-Installation/02-Icinga-Management-Console.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ As we now have deployed our Icinga PowerShell Framework on our Windows machine,
55
**Note:** You can always open the IMC by running the following command:
66

77
```powershell
8-
icinga -Manage;
8+
icinga;
99
```
1010

1111
## Navigating the IMC

Diff for: doc/110-Installation/03-Installation-with-IMC.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ We can now use the Icinga Management Console to configure our local Windows syst
55
If we are not already inside the IMC, we can open it with
66

77
```powershell
8-
icinga -Manage;
8+
icinga;
99
```
1010

1111
## Installation menu

Diff for: doc/160-Features/04-Manage-Icinga-Agent-Features.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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.
44

5-
**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.
5+
**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`
66

77
## List Icinga Agent Features
88

Diff for: doc/160-Features/05-Read-Icinga-Agent-Logs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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.
44

5-
**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.
5+
**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`
66

77
## Read the default Icinga Agent log file
88

Diff for: doc/160-Features/06-Test-Icinga-Installation.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
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.
44

5-
**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.
5+
**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`
66

77
## Testing for errors
88

9-
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`:
9+
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`:
1010

1111
```powershell
1212
Test-IcingaAgent;
@@ -51,7 +51,7 @@ In addition for testing, the Icinga PowerShell Framework will suggest methods to
5151
[Passed]: Icinga Agent debug log is disabled
5252
```
5353

54-
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:
54+
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:
5555

5656
```powershell
5757
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
9797
Test-IcingaAgentConfig -WriteStackTrace | Out-Null;
9898
```
9999

100-
By using the argument `-WriteStackTrace` we will print the actual error ouptut from the Icinga Agent binary to our console for troubleshooting:
100+
By using the argument `-WriteStackTrace` we will print the actual error output from the Icinga Agent binary to our console for troubleshooting:
101101

102102
```text
103103
[2020-08-12 16:54:26 +0200] information/cli: Icinga application loader (version: v2.12.0)

Diff for: doc/160-Features/20-Change-Icinga-Service-User.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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.
44

5-
**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.
5+
**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`
66

77
## Getting started
88

Diff for: doc/900-Developer-Guide/52-Testing-of-Commands.md

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
# Developer Guide: Testing of Commands
22

3-
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.
4-
5-
To make things more usable, we can of course run a PowerShell command directly from our shell:
6-
7-
```powershell
8-
powershell -C { Use-Icinga; <# your code #> }
9-
```
10-
11-
While this is straight forward and easy to use, the idea is to make this way simpler.
3+
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.
124

135
## Invoke-IcingaCommand or simply icinga
146

@@ -58,7 +50,7 @@ icinga> Exit-IcingaThrowException -Force -CustomMessage 'Force Exit of our Shell
5850
Unhandled exception occured:
5951
```
6052

61-
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.
53+
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.
6254

6355
This also works for code we directly invoke to the `icinga` alias:
6456

Diff for: doc/950-Deprecated/04-Icinga-Agent-Wizard.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ To start the Icinga Agent installation wizard you will have to open a PowerShell
1010
Use-Icinga
1111
```
1212

13-
*Note:* Starting with Icinga PowerShell Framework `1.2.0` you can simply type `icinga` to open an Icinga PowerShell Framework shell,
13+
*Note:* Starting with Icinga PowerShell Framework `1.2.0` you can simply type `icinga -Shell` to open an Icinga PowerShell Framework shell,
1414

1515
Once the command is executed, the Framework and all required components are loaded. To get started, we can now run
1616

Diff for: doc/frameworkusage/34-Uninstall-Icinga-Agent.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
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.
44

5-
**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.
5+
**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`
66

77
## Uninstalling the Icinga Agent
88

Diff for: doc/frameworkusage/35-Install-Update-Icinga-Agent.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Managing the Icinga Agent is one of the main goals for Icinga for Windows. This also includes installing and updating the Icinga Agent itself.
44

5-
**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.
5+
**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`
66

77
## Installing the Icinga Agent
88

Diff for: doc/knowledgebase/IWKB000001.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ There is a detailed description on the [Microsoft Docs](https://docs.microsoft.c
3030

3131
#### Using PowerShell
3232

33-
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`.
33+
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`.
3434
After the Icinga PowerShell Framework is loaded, we can use our Wmi permission Cmdlet:
3535

3636
```powershell

Diff for: icinga-powershell-framework.psd1

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

Diff for: icinga-powershell-framework.psm1

+7-6
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ function Invoke-IcingaCommand()
179179
param (
180180
$ScriptBlock,
181181
[switch]$SkipHeader = $FALSE,
182-
[switch]$Manage = $FALSE,
182+
[switch]$Manage = $FALSE, # Only for backwards compatibility, has no use at all
183+
[switch]$Shell = $FALSE,
183184
[switch]$RebuildCache = $FALSE,
184185
[array]$ArgumentList = @()
185186
);
@@ -191,7 +192,7 @@ function Invoke-IcingaCommand()
191192

192193
# Print a header informing our user that loaded the Icinga Framework with a specific
193194
# version. We can also skip the header by using $SKipHeader
194-
if ([string]::IsNullOrEmpty($ScriptBlock) -And $SkipHeader -eq $FALSE -And $Manage -eq $FALSE) {
195+
if ([string]::IsNullOrEmpty($ScriptBlock) -And $SkipHeader -eq $FALSE -And $Shell) {
195196
[array]$Headers = @(
196197
'Icinga for Windows $FrameworkVersion',
197198
'Copyright $Copyright',
@@ -209,7 +210,7 @@ function Invoke-IcingaCommand()
209210
Write-IcingaFrameworkCodeCache;
210211
}
211212

212-
if ($Manage -And $null -ne $psISE) {
213+
if ($null -ne $psISE) {
213214
Use-Icinga;
214215
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.';
215216
return;
@@ -224,7 +225,7 @@ function Invoke-IcingaCommand()
224225
$Script = $args[0];
225226
$RootPath = $args[1];
226227
$Version = $args[2];
227-
$Manage = $args[3];
228+
$Shell = $args[3];
228229
$IcingaShellArgs = $args[4];
229230

230231
# Load our Icinga Framework
@@ -235,7 +236,7 @@ function Invoke-IcingaCommand()
235236
# Set the location to the Icinga Framework module folder
236237
Set-Location $RootPath;
237238

238-
if ($Manage) {
239+
if ($Shell -eq $FALSE -And [string]::IsNullOrEmpty($Script)) {
239240
Install-Icinga;
240241
exit $LASTEXITCODE;
241242
}
@@ -253,7 +254,7 @@ function Invoke-IcingaCommand()
253254
return "> "
254255
}
255256

256-
} -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version, ([bool]$Manage), $ArgumentList;
257+
} -Args $ScriptBlock, $PSScriptRoot, $IcingaFrameworkData.PrivateData.Version, ([bool]$Shell), $ArgumentList;
257258
}
258259

259260
function Start-IcingaShellAsUser()

Diff for: lib/core/framework/Uninstall-IcingaForWindows.psm1

+17-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"icinga", you require to specify the user to remove it entirely
1717
.PARAMETER Force
1818
Suppress the question if you are sure to uninstall everything
19+
.PARAMETER ComponentsOnly
20+
Only uninstalls components like Icinga Agent, plugins, and so on and keeps the Framework
1921
.INPUTS
2022
System.String
2123
.OUTPUTS
@@ -27,8 +29,9 @@
2729
function Uninstall-IcingaForWindows()
2830
{
2931
param (
30-
$IcingaUser = 'icinga',
31-
[switch]$Force = $FALSE
32+
$IcingaUser = 'icinga',
33+
[switch]$Force = $FALSE,
34+
[switch]$ComponentsOnly = $FALSE
3235
);
3336

3437
$ModuleList = Get-Module 'icinga-powershell-*' -ListAvailable;
@@ -53,15 +56,21 @@ function Uninstall-IcingaForWindows()
5356
Uninstall-IcingaSecurity -IcingaUser $IcingaUser;
5457
Write-IcingaConsoleNotice 'Uninstalling Icinga Agent';
5558
Uninstall-IcingaAgent -RemoveDataFolder | Out-Null;
56-
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows EventLog';
57-
Unregister-IcingaEventLog;
59+
if ($ComponentsOnly -eq $FALSE) {
60+
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows EventLog';
61+
Unregister-IcingaEventLog;
62+
}
5863
Write-IcingaConsoleNotice 'Uninstalling Icinga for Windows service';
5964
Uninstall-IcingaForWindowsService | Out-Null;
6065

6166
$HasErrors = $FALSE;
6267

6368
foreach ($module in $ModuleList.Name) {
64-
[string]$ModuleName = $module.Replace('icinga-powershell-', '');
69+
[string]$ModuleName = $module.Replace('icinga-powershell-', '').ToLower();
70+
71+
if ($ModuleName -eq 'framework' -And $ComponentsOnly) {
72+
continue;
73+
}
6574

6675
if ((Uninstall-IcingaFrameworkComponent -Name $ModuleName)) {
6776
continue;
@@ -70,7 +79,9 @@ function Uninstall-IcingaForWindows()
7079
$HasErrors = $TRUE;
7180
}
7281

73-
Remove-Module 'icinga-powershell-framework' -Force -ErrorAction SilentlyContinue;
82+
if ($ComponentsOnly -eq $FALSE) {
83+
Remove-Module 'icinga-powershell-framework' -Force -ErrorAction SilentlyContinue;
84+
}
7485

7586
if ($HasErrors) {
7687
Write-Host 'Not all components could be removed. Please ensure no other PowerShell/Application is currently open and accessing Icinga for Windows files';

0 commit comments

Comments
 (0)