Skip to content

Commit 8d9cf07

Browse files
committed
Merge branch 'master' into support/1.0
2 parents ef5a8f4 + 96314bf commit 8d9cf07

32 files changed

+1014
-211
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Exclude files related to git when generating an archive
2+
.git* export-ignore
3+
4+
# Include version information on `git archive'
5+
VERSION export-subst

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ Please take a look at the following content to get to know the possibilities of
1313

1414
* [Introduction](doc/01-Introduction.md)
1515
* [Installation Guide](doc/02-Installation.md)
16-
* [Icinga Integration](doc/05-IcingaIntegration.md)
16+
* [Icinga Integration](doc/05-Icinga-Integration.md)
17+
* [PowerShell as Service](doc/service/01-Install-Service.md)
1718

1819
Developer Guide
1920
------------
2021

21-
If you wish to extend the Framework by yourself or write custom plugins for your environment, please have a look at the [Developer Guide](doc/04-DeveloperGuide.md) for detailed explanations of functions and code examples.
22+
If you wish to extend the Framework by yourself or write custom plugins for your environment, please have a look at the [Developer Guide](doc/04-Developer-Guide.md) for detailed explanations of functions and code examples.
2223

2324
Contributing
2425
------------

doc/02-Installation.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,10 @@ Use-Icinga
2121
This command will initialise the entire module and load all available Cmdlets.
2222

2323
Whenever you intend to use specific Cmdlets of the framework for Icinga Plugins, Testing or configuration you will require to run this command for each new PowerShell instance to initialise the framework.
24+
25+
Service Installation
26+
---
27+
28+
You can install a service which will allow you to run the PowerShell Framework as background daemon. This will add the possibility to register functions to run frequently for collecting data or execute different tasks on the system.
29+
30+
To install the service you can either follow the `IcingaAgentInstallWizard` or do it [manually](service/01-Install-Service.md)

doc/04-Developer-Guide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ A detailed overview of functions can be found below
1212

1313
* [New-IcingaCheck](developerguide/01-New-IcingaCheck.md)
1414
* [New-IcingaCheckPackage](developerguide/02-New-IcingaCheckPackage.md)
15+
* [Custom Daemons](developerguide/10-Custom-Daemons.md)

doc/developerguide/01-New-IcingaCheck.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ For performance metrics you can provide a `Unit` to ensure your graphing is disp
4242
| ms | Milliseconds | The input is indicated as time in milliseconds |
4343
| us | Microseconds | The input is indicated as time in microseconds |
4444
| B | Bytes | The input is indicated as quantity in bytes |
45-
| KB | Kilobytes | The input is indicated as quantity in kilobytes |
46-
| MB | Megabytes | The input is indicated as quantity in megabytes |
47-
| GB | Gigabytes | The input is indicated as quantity in gigabytes |
48-
| TB | Terabytes | The input is indicated as quantity in terabytes |
45+
| KB | Kilobytes | The input is indicated as quantity in Kilobytes |
46+
| MB | Megabytes | The input is indicated as quantity in Megabytes |
47+
| GB | Gigabytes | The input is indicated as quantity in Gigabytes |
48+
| TB | Terabytes | The input is indicated as quantity in Terabytes |
4949
| c | Counter | A continues counter increasing values over time |
5050

5151
## Object Functions

doc/developerguide/10-Custom-Daemons.md

Lines changed: 451 additions & 0 deletions
Large diffs are not rendered by default.

doc/installation/01-Kickstart-Script.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Install the framework with the Kickstart Script
22
===
33

4-
The easiest way to install the framework is by using the Kickstart Script provided from [this repository](https://github.com/Icinga/icinga-framework-kickstart).
4+
The easiest way to install the framework is by using the Kickstart Script provided from [this repository](https://github.com/Icinga/icinga-powershell-kickstart).
55

66
The code provided there will ask questions on where to install the framework and where the framework files are provided from. The code below is a straight copy of the initial required code-block. Simply open a PowerShell instance as administrator and copy the following code block into it:
77

doc/10-Install-Service.md renamed to doc/service/01-Install-Service.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Run the PowerShell Module as Windows Service
1+
Run the PowerShell Framework as Windows Service
22
===
33

44
Requirements
@@ -8,6 +8,11 @@ As PowerShell Scripts / Modules can not be installed directly as Windows Service
88

99
In order to make this work, you will require the Icinga Windows Service which can be downloaded directly from the [GitHub Repository](https://github.com/Icinga/icinga-powershell-service).
1010

11+
Benefits
12+
---
13+
14+
Running the PowerShell Framework as background service will add the possibility to register certain functions which are executed depending on their configuration / coding. One example would be to frequently collect monitoring metrics from the installed plugins, allowing you to receice an average of time for the CPU load for example.
15+
1116
Install the Service
1217
---
1318

@@ -36,3 +41,13 @@ Install-IcingaFrameworkService -Path 'C:\Program Files\Icinga-Framework-Service\
3641
You can validate if the service has been installed properly by using the Get Service Cmdlet:
3742

3843
Each enabled background daemon component is afterwards being started and executed.
44+
45+
Register Functions
46+
---
47+
48+
As the service is now installed we can start to [register daemons](02-Register-Daemons.md) which are executed within an own thread within a PowerShell session. Depending on the registered function/module, additional configuration may be required.
49+
50+
Background Service Check
51+
---
52+
53+
Once you registered the Daemon `Start-IcingaServiceCheckDaemon` with the [register functions](02-Register-Daemons.md) feature you will be able to [register service checks](10-Register-Service-Checks.md) which are frequently executed to collect metrics from plugins.

doc/service/02-Register-Daemons.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
Register Background Daemons
2+
===
3+
4+
One huge advantage of the entire PowerShell Framework for Icinga is to run the PowerShell environment as background service. Once you [installed the service](01-Install-Service.md) you can simply register functions which are executed.
5+
6+
Register Daemon
7+
---
8+
9+
To register daemons which are executed on the backkground daemon, you can use the build in command `Register-IcingaBackgroundDaemon`. An example would be to enable the frequent service check daemon which ships with this framework
10+
11+
```powershell
12+
Register-IcingaBackgroundDaemon -Command 'Start-IcingaServiceCheckDaemon';
13+
```
14+
15+
The `Start-IcingaServiceCheckDaemon` is a directly integrated PowerShell function which will itself start an own thread for executing regular service checks which have been registered.
16+
17+
Once you made changes, please remember to restart the PowerShell Service
18+
19+
```powershell
20+
Restart-IcingaService 'icingapowershell';
21+
```
22+
23+
List Enabled Daemons
24+
---
25+
26+
To list all registered background daemons you can use a build-in command for this
27+
28+
```powershell
29+
Get-IcingaBackgroundDaemons;
30+
```
31+
32+
Once executed you will receive a list of all daemons which are started
33+
34+
```powershell
35+
Name Value
36+
---- -----
37+
Start-IcingaServiceCheckDaemon {}
38+
```
39+
40+
Remove Daemons
41+
---
42+
43+
Besides adding and displaying registered background daemons you can also use the unregister command to remove them
44+
45+
```powershell
46+
Unregister-IcingaBackgroundDaemon -BackgroundDaemon 'Start-IcingaServiceCheckDaemon';
47+
```
48+
49+
Once you restart the PowerShell service the pending changes are applied
50+
51+
```powershell
52+
Restart-IcingaService 'icingapowershell';
53+
```
54+
55+
Write Custom Daemons
56+
---
57+
58+
In addition you are free to write your own extensions you can register within the framework. Every PowerShell daemon which is available within a single PowerShell session - even from different modules - can be used.
59+
60+
Best practice would be to create an own custom PowerShell Module which will create a new thread and executing certain tasks. Once this module is available in your PowerShell session, you can simply register and use it.
61+
62+
For a detailed guide you should check out the [daemon developer guide](../developerguide/10-Custom-Daemons.md).
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
Register Background Service Checks
2+
===
3+
4+
Once the PowerShell Framework is [installed as service](01-Install-Service.md) and you enabled the `Start-IcingaServiceCheckDaemon` daemon by [registering it](02-Register-Daemons.md), you are free to configure service checks which are frequently executed on a custom time period.
5+
6+
Register Service Checks
7+
---
8+
9+
Registering a service check will execute them frequently on a custom defined time. To do so you will have to register the check plugin you wish you collect metrics over time and add a execution time intervall including time indexes for which averages should be calculcated for.
10+
11+
As example we want to frequently collect our `CPU load` values with an `check interval of 30 seconds` and calculate `averages for 1m, 3m, 5m, and 15m`.
12+
13+
```powershell
14+
Register-IcingaServiceCheck -CheckCommand 'Invoke-IcingaCheckCPU' -Interval 30 -TimeIndexes 1, 3, 5, 15;
15+
```
16+
17+
Once you registered a service check, you will have to restart the PowerShell service
18+
19+
```powershell
20+
Restart-IcingaService 'icingapowershell';
21+
```
22+
23+
As collected metrics are written to disk as well, a restart will not flush previous data but load it again. A quick service restart will not cause missing data points.
24+
25+
Once the service check is executed from the background daemon, it will add additional output to your regular check execution from Icinga 2. If we execute our `Invoke-IcingaCheckCPU` now again, we will see additional metrics based on our configuration
26+
27+
```powershell
28+
[OK] Check package "CPU Load"
29+
| 'core_0_15'=1.17%;;;0;100 'core_0_3'=1.12%;;;0;100 'core_0_5'=1.65%;;;0;100 'core_0_1'=1.36%;;;0;100 'core_0'=0.19%;;;0;100 'core_1_1'=0.86%;;;0;100 'core_1_15'=4.59%;;;0;100 'core_1_5'=5.28%;;;0;100 'core_1_3'=1.15%;;;0;100 'core_total_5'=5.2%;;;0;100 'core_total_15'=4.32%;;;0;100 'core_total_1'=3.41%;;;0;100 'core_total_3'=3.79%;;;0;100 'core_total'=1.85%;;;0;100
30+
```
31+
32+
As you can see, each time index we added for the `TimeIndexes` argument is added as separat metric to our performance output. The calculation is done by all collected values over the execution period.
33+
34+
List Service Checks
35+
---
36+
37+
To list all registered service checks you can simply use
38+
39+
```powershell
40+
Show-IcingaRegisteredServiceChecks;
41+
```
42+
43+
This will print a detailed list of all checks and their configuration
44+
45+
```powershell
46+
Service Id: 5275219864641021224811420224776891459631192206
47+
48+
Name Value
49+
---- -----
50+
CheckCommand Invoke-IcingaCheckCPU
51+
Interval 30
52+
Arguments
53+
Id 5275219864641021224811420224776891459631192206
54+
TimeIndexes {1, 3, 5, 15}
55+
```
56+
57+
Modify Service Checks
58+
---
59+
60+
To modify service checks you can simply use the `Register-IcingaServiceCheck` command again with the identical check command, but overwritting interval and time indexes for example
61+
62+
```powershell
63+
Register-IcingaServiceCheck -CheckCommand 'Invoke-IcingaCheckCPU' -Interval 60 -TimeIndexes 1, 3, 5, 15, 20;
64+
```
65+
66+
Once you modified a service check, you will have to restart the PowerShell service
67+
68+
```powershell
69+
Restart-IcingaService 'icingapowershell';
70+
```
71+
72+
Unregister Service Checks
73+
---
74+
75+
If you wish to remove a service check from the daemon, you can simply unregister it with the `id` displayed on the `Show-IcingaRegisteredServiceChecks` Cmdlet
76+
77+
```powershell
78+
Unregister-IcingaServiceCheck -ServiceId 5275219864641021224811420224776891459631192206;
79+
```
80+
81+
Once you removed a service check, you will have to restart the PowerShell service
82+
83+
```powershell
84+
Restart-IcingaService 'icingapowershell';
85+
```

0 commit comments

Comments
 (0)