|
| 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