-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into support/1.0
- Loading branch information
Showing
32 changed files
with
1,014 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Exclude files related to git when generating an archive | ||
.git* export-ignore | ||
|
||
# Include version information on `git archive' | ||
VERSION export-subst |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Register Background Daemons | ||
=== | ||
|
||
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. | ||
|
||
Register Daemon | ||
--- | ||
|
||
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 | ||
|
||
```powershell | ||
Register-IcingaBackgroundDaemon -Command 'Start-IcingaServiceCheckDaemon'; | ||
``` | ||
|
||
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. | ||
|
||
Once you made changes, please remember to restart the PowerShell Service | ||
|
||
```powershell | ||
Restart-IcingaService 'icingapowershell'; | ||
``` | ||
|
||
List Enabled Daemons | ||
--- | ||
|
||
To list all registered background daemons you can use a build-in command for this | ||
|
||
```powershell | ||
Get-IcingaBackgroundDaemons; | ||
``` | ||
|
||
Once executed you will receive a list of all daemons which are started | ||
|
||
```powershell | ||
Name Value | ||
---- ----- | ||
Start-IcingaServiceCheckDaemon {} | ||
``` | ||
|
||
Remove Daemons | ||
--- | ||
|
||
Besides adding and displaying registered background daemons you can also use the unregister command to remove them | ||
|
||
```powershell | ||
Unregister-IcingaBackgroundDaemon -BackgroundDaemon 'Start-IcingaServiceCheckDaemon'; | ||
``` | ||
|
||
Once you restart the PowerShell service the pending changes are applied | ||
|
||
```powershell | ||
Restart-IcingaService 'icingapowershell'; | ||
``` | ||
|
||
Write Custom Daemons | ||
--- | ||
|
||
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. | ||
|
||
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. | ||
|
||
For a detailed guide you should check out the [daemon developer guide](../developerguide/10-Custom-Daemons.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
Register Background Service Checks | ||
=== | ||
|
||
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. | ||
|
||
Register Service Checks | ||
--- | ||
|
||
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. | ||
|
||
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`. | ||
|
||
```powershell | ||
Register-IcingaServiceCheck -CheckCommand 'Invoke-IcingaCheckCPU' -Interval 30 -TimeIndexes 1, 3, 5, 15; | ||
``` | ||
|
||
Once you registered a service check, you will have to restart the PowerShell service | ||
|
||
```powershell | ||
Restart-IcingaService 'icingapowershell'; | ||
``` | ||
|
||
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. | ||
|
||
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 | ||
|
||
```powershell | ||
[OK] Check package "CPU Load" | ||
| '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 | ||
``` | ||
|
||
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. | ||
|
||
List Service Checks | ||
--- | ||
|
||
To list all registered service checks you can simply use | ||
|
||
```powershell | ||
Show-IcingaRegisteredServiceChecks; | ||
``` | ||
|
||
This will print a detailed list of all checks and their configuration | ||
|
||
```powershell | ||
Service Id: 5275219864641021224811420224776891459631192206 | ||
Name Value | ||
---- ----- | ||
CheckCommand Invoke-IcingaCheckCPU | ||
Interval 30 | ||
Arguments | ||
Id 5275219864641021224811420224776891459631192206 | ||
TimeIndexes {1, 3, 5, 15} | ||
``` | ||
|
||
Modify Service Checks | ||
--- | ||
|
||
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 | ||
|
||
```powershell | ||
Register-IcingaServiceCheck -CheckCommand 'Invoke-IcingaCheckCPU' -Interval 60 -TimeIndexes 1, 3, 5, 15, 20; | ||
``` | ||
|
||
Once you modified a service check, you will have to restart the PowerShell service | ||
|
||
```powershell | ||
Restart-IcingaService 'icingapowershell'; | ||
``` | ||
|
||
Unregister Service Checks | ||
--- | ||
|
||
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 | ||
|
||
```powershell | ||
Unregister-IcingaServiceCheck -ServiceId 5275219864641021224811420224776891459631192206; | ||
``` | ||
|
||
Once you removed a service check, you will have to restart the PowerShell service | ||
|
||
```powershell | ||
Restart-IcingaService 'icingapowershell'; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
function Find-IcingaAgentObjects() | ||
{ | ||
param( | ||
$Find = @(), | ||
$OutFile = $null | ||
); | ||
|
||
if ($Find.Length -eq 0) { | ||
throw 'Please specify content you want to look for'; | ||
} | ||
|
||
[array]$ObjectList = (Get-IcingaAgentObjectList).Split("`r`n"); | ||
[int]$lineIndex = 0; | ||
[array]$Result = @(); | ||
|
||
foreach ($line in $ObjectList) { | ||
if ([string]::IsNullOrEmpty($line)) { | ||
continue; | ||
} | ||
|
||
foreach ($entry in $Find) { | ||
if ($line -like $entry) { | ||
[string]$ResultLine = [string]::Format( | ||
'Line #{0} => "{1}"', | ||
$lineIndex, | ||
$line | ||
); | ||
$Result += $ResultLine; | ||
} | ||
} | ||
|
||
$lineIndex += 1; | ||
} | ||
|
||
if ([string]::IsNullOrEmpty($OutFile)) { | ||
Write-Output $Result; | ||
} else { | ||
Set-Content -Path $OutFile -Value $Result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function Get-IcingaAgentObjectList() | ||
{ | ||
$Binary = Get-IcingaAgentBinary; | ||
$ObjectList = Start-IcingaProcess -Executable $Binary -Arguments 'object list'; | ||
|
||
return $ObjectList.Message; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
lib/core/icingaagent/writers/Write-IcingaAgentObjectList.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function Write-IcingaAgentObjectList() | ||
{ | ||
param( | ||
[string]$Path | ||
); | ||
|
||
if ([string]::IsNullOrEmpty($Path)) { | ||
throw 'Please specify a path to write the Icinga objects to'; | ||
} | ||
|
||
$ObjectList = Get-IcingaAgentObjectList; | ||
|
||
Set-Content -Path $Path -Value $ObjectList; | ||
} |
Oops, something went wrong.