Skip to content

Commit a9c4b90

Browse files
committed
Adds flag to ignore service for time plugin
1 parent 5bf1d17 commit a9c4b90

10 files changed

+351
-329
lines changed

config/director/Invoke-IcingaCheckHttpJsonResponse.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

config/director/Invoke-IcingaCheckTimeSync.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

config/director/Plugins_Bundle.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

config/icinga/Invoke-IcingaCheckHttpJsonResponse.conf

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

config/icinga/Invoke-IcingaCheckTimeSync.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ object CheckCommand "Invoke-IcingaCheckTimeSync" {
2626
value = "$IcingaCheckTimeSync_Int32_Port$"
2727
order = 7
2828
}
29+
"-IgnoreService" = {
30+
set_if = "$IcingaCheckTimeSync_Switchparameter_IgnoreService$"
31+
order = 99
32+
}
2933
"-NoPerfData" = {
3034
set_if = "$IcingaCheckTimeSync_Switchparameter_NoPerfData$"
3135
order = 99
@@ -83,4 +87,5 @@ object CheckCommand "Invoke-IcingaCheckTimeSync" {
8387
}
8488
vars.IcingaCheckTimeSync_Switchparameter_NoPerfData = false
8589
vars.IcingaCheckTimeSync_Switchparameter_IPV4 = false
90+
vars.IcingaCheckTimeSync_Switchparameter_IgnoreService = false
8691
}

config/icinga/Plugins_Bundle.conf

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2804,12 +2804,12 @@ object CheckCommand "Invoke-IcingaCheckUNCPath" {
28042804
order = 8
28052805
}
28062806
"-CriticalTotal" = {
2807-
description = "A warning threshold for the shares total free space in byte units, like '50GB:' Please note that this value is decreasing over time, therefor you will have to use the plugin handler and add ':' at the end of your input to check for 'current value < threshold' like in the previous example Allowed units: B, KB, MB, GB, TB, PB, KiB, MiB, GiB, TiB, PiB"
2807+
description = "A critical threshold for the shares free space in either % or byte units, like '20%:' or '50GB:' Please note that this value is decreasing over time, therefor you will have to use the plugin handler and add ':' at the end of your input to check for 'current value < threshold' like in the previous example Allowed units: %, B, KB, MB, GB, TB, PB, KiB, MiB, GiB, TiB, PiB"
28082808
value = "$IcingaCheckUNCPath_Object_CriticalTotal$"
28092809
order = 7
28102810
}
28112811
"-WarningTotal" = {
2812-
description = "A warning threshold for the shares free space in either % or byte units, like '20%:' or '50GB:' Please note that this value is decreasing over time, therefor you will have to use the plugin handler and add ':' at the end of your input to check for 'current value < threshold' like in the previous example Allowed units: %, B, KB, MB, GB, TB, PB, KiB, MiB, GiB, TiB, PiB"
2812+
description = "A warning threshold for the shares total free space in byte units, like '50GB:' Please note that this value is decreasing over time, therefor you will have to use the plugin handler and add ':' at the end of your input to check for 'current value < threshold' like in the previous example Allowed units: B, KB, MB, GB, TB, PB, KiB, MiB, GiB, TiB, PiB"
28132813
value = "$IcingaCheckUNCPath_Object_WarningTotal$"
28142814
order = 6
28152815
}
@@ -3717,7 +3717,7 @@ object CheckCommand "Invoke-IcingaCheckUpdates" {
37173717

37183718
arguments += {
37193719
"-WarningRollups" = {
3720-
description = "The warning threshold for the total pending update count on the Windows machine"
3720+
description = "The warning threshold for the rollup update count on the Windows machine"
37213721
value = "$IcingaCheckUpdates_Object_WarningRollups$"
37223722
order = 7
37233723
}
@@ -3735,7 +3735,7 @@ object CheckCommand "Invoke-IcingaCheckUpdates" {
37353735
order = 99
37363736
}
37373737
"-CriticalOther" = {
3738-
description = "The critical threshold for all other updates on the Windows machine"
3738+
description = "The critical threshold for the total pending update count on the Windows machine"
37393739
value = "$IcingaCheckUpdates_Object_CriticalOther$"
37403740
order = 12
37413741
}
@@ -3744,7 +3744,7 @@ object CheckCommand "Invoke-IcingaCheckUpdates" {
37443744
order = 0
37453745
}
37463746
"-WarningDefender" = {
3747-
description = "The warning threshold for the total pending update count on the Windows machine"
3747+
description = "The warning threshold for the Microsoft Defender update count on the Windows machine"
37483748
value = "$IcingaCheckUpdates_Object_WarningDefender$"
37493749
order = 9
37503750
}
@@ -3782,7 +3782,7 @@ object CheckCommand "Invoke-IcingaCheckUpdates" {
37823782
order = 10
37833783
}
37843784
"-CriticalRollups" = {
3785-
description = "The critical threshold for the rollup update count on the Windows machine"
3785+
description = "The critical threshold for the total pending update count on the Windows machine"
37863786
value = "$IcingaCheckUpdates_Object_CriticalRollups$"
37873787
order = 8
37883788
}
@@ -3824,7 +3824,7 @@ object CheckCommand "Invoke-IcingaCheckUpdates" {
38243824
order = 5
38253825
}
38263826
"-CriticalSecurity" = {
3827-
description = "The critical threshold for the security update count on the Windows machine"
3827+
description = "The critical threshold for the total pending update count on the Windows machine"
38283828
value = "$IcingaCheckUpdates_Object_CriticalSecurity$"
38293829
order = 6
38303830
}
@@ -3934,6 +3934,10 @@ object CheckCommand "Invoke-IcingaCheckTimeSync" {
39343934
value = "$IcingaCheckTimeSync_Int32_Port$"
39353935
order = 7
39363936
}
3937+
"-IgnoreService" = {
3938+
set_if = "$IcingaCheckTimeSync_Switchparameter_IgnoreService$"
3939+
order = 99
3940+
}
39373941
"-NoPerfData" = {
39383942
set_if = "$IcingaCheckTimeSync_Switchparameter_NoPerfData$"
39393943
order = 99
@@ -3991,6 +3995,7 @@ object CheckCommand "Invoke-IcingaCheckTimeSync" {
39913995
}
39923996
vars.IcingaCheckTimeSync_Switchparameter_NoPerfData = false
39933997
vars.IcingaCheckTimeSync_Switchparameter_IPV4 = false
3998+
vars.IcingaCheckTimeSync_Switchparameter_IgnoreService = false
39943999
}
39954000

39964001

doc/31-Changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ documentation before upgrading to a new release.
77

88
Released closed milestones can be found on [GitHub](https://github.com/Icinga/icinga-powershell-plugins/milestones?state=closed).
99

10+
## 1.10.1 (2022-12-20)
11+
12+
### Enhancements
13+
14+
* [#322](https://github.com/Icinga/icinga-powershell-plugins/issues/322) Adds flag `-IgnoreService` for plugin `Invoke-IcingaCheckTimeSync` to ignore the time service being evaluated during check runtime
15+
1016
## 1.10.0 (2022-08-30)
1117

1218
[Issue and PRs](https://github.com/Icinga/icinga-powershell-plugins/milestone/13?closed=1)

doc/plugins/18-Invoke-IcingaCheckTimeSync.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ No special permissions required.
2323
| Timeout | Int32 | false | 10 | Seconds before connection times out (default: 10) |
2424
| IPV4 | SwitchParameter | false | False | Use IPV4 connection. Default $FALSE |
2525
| Port | Int32 | false | 123 | Port number (default: 123) |
26+
| IgnoreService | SwitchParameter | false | False | Ignores the W32Time service during check execution and will not throw warning or critical in case the service is not running |
2627
| NoPerfData | SwitchParameter | false | False | |
2728
| Verbosity | Int32 | false | 0 | Changes the behavior of the plugin output which check states are printed: 0 (default): Only service checks/packages with state not OK will be printed 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 2: Everything will be printed regardless of the check state 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) |
2829
| ThresholdInterval | String | | | Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described [here](https://icinga.com/docs/icinga-for-windows/latest/doc/service/10-Register-Service-Checks/). An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring. |
Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,70 @@
1-
2-
# Invoke-IcingaCheckHttpJsonResponse
3-
4-
## Description
5-
6-
Retrieves a JSON-Object via Request and performs desired checks
7-
8-
Invoke-IcingaCheckHttpJsonResponse returns 'OK', 'WARNING' or 'CRITICAL', depending on the parameters Warning and Critical
9-
More Information on https://github.com/Icinga/icinga-powershell-plugins
10-
11-
## Permissions
12-
13-
No special permissions required.
14-
15-
## Arguments
16-
17-
| Argument | Type | Required | Default | Description |
18-
| --- | --- | --- | --- | --- |
19-
| ServerUri | String | false | | Base URI of the server, example "https://example.comm" |
20-
| ServerPath | String | false | | Path for the request, example "/v1/my_endpoint" |
21-
| QueryParameter | String | false | | Query parameter for the request without ?, example "command=example" |
22-
| Username | String | false | | Credentials to use for basic auth |
23-
| Password | SecureString | false | | Credentials to use for basic auth |
24-
| Timeout | Int32 | false | 30 | Timeout in seconds before the http request is aborted. Defaults to 30 |
25-
| ValuePaths | Array | false | @() | paths to look for values in the JSON object that is checked, including an alias for each parameter. Example: "myAlias01:value01","myAlias02:nested.object.value02", "myAlias03:'object'.'my.Par.With.Dots'" |
26-
| ValueTypes | Array | false | @() | Value types of each parameter. Supported Types: Numeric, Boolean, DateTime, String Example: "myAlias01:Numeric","myAlias02:DateTime" |
27-
| Warning | Array | false | @() | Warning thresholds using icinga-powershell syntax. Example: "myNumericAlias01:~:2","myDateTimeAlias:-10d", "myBooleanAlias:True" |
28-
| Critical | Array | false | @() | Critical thresholds using icinga-powershell syntax. Example: "myNumericAlias01:~:2","myDateTimeAlias:-10d", "myBooleanAlias:True" |
29-
| IgnoreSSL | SwitchParameter | false | False | Disables SSL verification and allows the connection to endpoints with self-signed certificates as example |
30-
| StatusOnRequestError | String | false | Unknown | Status to set when the webservice cannot be reached or an error (e.g. 500) is returned - default is Unknown See https://icinga.com/docs/icinga-for-windows/latest/plugins/doc/10-Icinga-Plugins/ for description of threshold values |
31-
| NegateStringResults | SwitchParameter | false | False | Negate the conditions set for string parameters. When this is set to true, WarnIfLike/CritIfLike is used instead of WarnIfNotLike/CritIfNotLike for Strings |
32-
| Verbosity | Int32 | false | 0 | Changes the behavior of the plugin output which check states are printed: 0 (default): Only service checks/packages with state not OK will be printed 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 2: Everything will be printed regardless of the check state 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) |
33-
| NoPerfData | SwitchParameter | false | False | |
34-
| ThresholdInterval | String | | | Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described [here](https://icinga.com/docs/icinga-for-windows/latest/doc/service/10-Register-Service-Checks/). An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring. |
35-
36-
## Examples
37-
38-
### Example Command 1
39-
40-
```powershell
41-
Invoke-IcingaCheckHttpJsonResponse -NoPerfData -ServerUri "https://my-server.local:8443" -ServerPath "my/path" -QueryParameter "myPar=1" -Username "superuser" -Pass (ConvertTo-SecureString -String "secretPassword" -AsPlainText -Force) -Verbosity 2 -ValuePaths "myNumberOfItems:numberOfItems","oldestTime:oldestItemTimestamp" -ValueTypes "myNumberOfItems:Numeric","oldestTime:DateTime" -Warning "myNumberOfItems:~:2","oldestTime:-2d" -Critical "myNumberOfItems:~:2","oldestTime:-4d"
42-
```
43-
44-
### Example Output 1
45-
46-
```powershell
47-
[CRITICAL] HTTP JSON Response Monitor [CRITICAL] Check returned value for oldestTime (2022/01/27 06:54:18)
48-
\_ [OK] All requested parameters are available in JSON response: 2
49-
\_ [OK] Check returned value for myNumberOfItems: 2
50-
\_ [CRITICAL] Check returned value for oldestTime: 2022/01/27 06:54:18 is lower than 2022/03/07 10:01:31 (-4d)
51-
\_ [OK] Parameters evaluated: 0
52-
\_ [OK] Response received: False
53-
```
54-
55-
### Example Command 2
56-
57-
```powershell
58-
Invoke-IcingaCheckHttpJsonResponse -NoPerfData -ServerUri "https://my-server.local:8443" -ServerPath "my/path" -QueryParameter "myPar=1" -Username "superuser" -Pass (ConvertTo-SecureString -String "secretPassword" -AsPlainText -Force) -Verbosity 2 -ValuePaths "myNumberOfItems:numberOfItems","oldestTime:oldestItemTimestamp" -ValueTypes "myNumberOfItems:Numeric","oldestTime:DateTime" -Warning "myNumberOfItems:~:1","oldestTime:-2d" -Critical "myNumberOfItems:~:2","oldestTime:-40d"
59-
```
60-
61-
### Example Output 2
62-
63-
```powershell
64-
[WARNING] HTTP JSON Response Monitor [WARNING] Check returned value for myNumberOfItems (2), Check returned value for oldestTime (2022/01/27 06:54:18)
65-
\_ [OK] All requested parameters are available in JSON response: 2
66-
\_ [WARNING] Check returned value for myNumberOfItems: 2 is greater than threshold 1
67-
\_ [WARNING] Check returned value for oldestTime: 2022/01/27 06:54:18 is lower than 2022/03/07 10:23:58 (-2d)
68-
\_ [OK] Parameters evaluated: 0
69-
\_ [OK] Response received: False
70-
```
1+
2+
# Invoke-IcingaCheckHttpJsonResponse
3+
4+
## Description
5+
6+
Retrieves a JSON-Object via Request and performs desired checks
7+
8+
Invoke-IcingaCheckHttpJsonResponse returns 'OK', 'WARNING' or 'CRITICAL', depending on the parameters Warning and Critical
9+
More Information on https://github.com/Icinga/icinga-powershell-plugins
10+
11+
## Permissions
12+
13+
No special permissions required.
14+
15+
## Arguments
16+
17+
| Argument | Type | Required | Default | Description |
18+
| --- | --- | --- | --- | --- |
19+
| ServerUri | String | false | | Base URI of the server, example "https://example.comm" |
20+
| ServerPath | String | false | | Path for the request, example "/v1/my_endpoint" |
21+
| QueryParameter | String | false | | Query parameter for the request without ?, example "command=example" |
22+
| Username | String | false | | Credentials to use for basic auth |
23+
| Password | SecureString | false | | Credentials to use for basic auth |
24+
| Timeout | Int32 | false | 30 | Timeout in seconds before the http request is aborted. Defaults to 30 |
25+
| ValuePaths | Array | false | @() | paths to look for values in the JSON object that is checked, including an alias for each parameter. Example: "myAlias01:value01","myAlias02:nested.object.value02", "myAlias03:'object'.'my.Par.With.Dots'" |
26+
| ValueTypes | Array | false | @() | Value types of each parameter. Supported Types: Numeric, Boolean, DateTime, String Example: "myAlias01:Numeric","myAlias02:DateTime" |
27+
| Warning | Array | false | @() | Warning thresholds using icinga-powershell syntax. Example: "myNumericAlias01:~:2","myDateTimeAlias:-10d", "myBooleanAlias:True" |
28+
| Critical | Array | false | @() | Critical thresholds using icinga-powershell syntax. Example: "myNumericAlias01:~:2","myDateTimeAlias:-10d", "myBooleanAlias:True" |
29+
| IgnoreSSL | SwitchParameter | false | False | Disables SSL verification and allows the connection to endpoints with self-signed certificates as example |
30+
| StatusOnRequestError | String | false | Unknown | Status to set when the webservice cannot be reached or an error (e.g. 500) is returned - default is Unknown See https://icinga.com/docs/icinga-for-windows/latest/plugins/doc/10-Icinga-Plugins/ for description of threshold values |
31+
| NegateStringResults | SwitchParameter | false | False | Negate the conditions set for string parameters. When this is set to true, WarnIfLike/CritIfLike is used instead of WarnIfNotLike/CritIfNotLike for Strings |
32+
| Verbosity | Int32 | false | 0 | Changes the behavior of the plugin output which check states are printed: 0 (default): Only service checks/packages with state not OK will be printed 1: Only services with not OK will be printed including OK checks of affected check packages including Package config 2: Everything will be printed regardless of the check state 3: Identical to Verbose 2, but prints in addition the check package configuration e.g (All must be [OK]) |
33+
| NoPerfData | SwitchParameter | false | False | |
34+
| ThresholdInterval | String | | | Change the value your defined threshold checks against from the current value to a collected time threshold of the Icinga for Windows daemon, as described [here](https://icinga.com/docs/icinga-for-windows/latest/doc/service/10-Register-Service-Checks/). An example for this argument would be 1m or 15m which will use the average of 1m or 15m for monitoring. |
35+
36+
## Examples
37+
38+
### Example Command 1
39+
40+
```powershell
41+
Invoke-IcingaCheckHttpJsonResponse -NoPerfData -ServerUri "https://my-server.local:8443" -ServerPath "my/path" -QueryParameter "myPar=1" -Username "superuser" -Pass (ConvertTo-SecureString -String "secretPassword" -AsPlainText -Force) -Verbosity 2 -ValuePaths "myNumberOfItems:numberOfItems","oldestTime:oldestItemTimestamp" -ValueTypes "myNumberOfItems:Numeric","oldestTime:DateTime" -Warning "myNumberOfItems:~:2","oldestTime:-2d" -Critical "myNumberOfItems:~:2","oldestTime:-4d"
42+
```
43+
44+
### Example Output 1
45+
46+
```powershell
47+
[CRITICAL] HTTP JSON Response Monitor [CRITICAL] Check returned value for oldestTime (2022/01/27 06:54:18)
48+
\_ [OK] All requested parameters are available in JSON response: 2
49+
\_ [OK] Check returned value for myNumberOfItems: 2
50+
\_ [CRITICAL] Check returned value for oldestTime: 2022/01/27 06:54:18 is lower than 2022/03/07 10:01:31 (-4d)
51+
\_ [OK] Parameters evaluated: 0
52+
\_ [OK] Response received: False
53+
```
54+
55+
### Example Command 2
56+
57+
```powershell
58+
Invoke-IcingaCheckHttpJsonResponse -NoPerfData -ServerUri "https://my-server.local:8443" -ServerPath "my/path" -QueryParameter "myPar=1" -Username "superuser" -Pass (ConvertTo-SecureString -String "secretPassword" -AsPlainText -Force) -Verbosity 2 -ValuePaths "myNumberOfItems:numberOfItems","oldestTime:oldestItemTimestamp" -ValueTypes "myNumberOfItems:Numeric","oldestTime:DateTime" -Warning "myNumberOfItems:~:1","oldestTime:-2d" -Critical "myNumberOfItems:~:2","oldestTime:-40d"
59+
```
60+
61+
### Example Output 2
62+
63+
```powershell
64+
[WARNING] HTTP JSON Response Monitor [WARNING] Check returned value for myNumberOfItems (2), Check returned value for oldestTime (2022/01/27 06:54:18)
65+
\_ [OK] All requested parameters are available in JSON response: 2
66+
\_ [WARNING] Check returned value for myNumberOfItems: 2 is greater than threshold 1
67+
\_ [WARNING] Check returned value for oldestTime: 2022/01/27 06:54:18 is lower than 2022/03/07 10:23:58 (-2d)
68+
\_ [OK] Parameters evaluated: 0
69+
\_ [OK] Response received: False
70+
```

plugins/Invoke-IcingaCheckTimeSync.psm1

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
Seconds before connection times out (default: 10)
2222
.PARAMETER IPV4
2323
Use IPV4 connection. Default $FALSE
24+
.PARAMETER IgnoreService
25+
Ignores the W32Time service during check execution and will not throw warning or critical in case the service is not running
2426
.PARAMETER Verbosity
2527
Changes the behavior of the plugin output which check states are printed:
2628
0 (default): Only service checks/packages with state not OK will be printed
@@ -53,15 +55,16 @@ function Invoke-IcingaCheckTimeSync()
5355
{
5456
param(
5557
[string]$Server,
56-
$TimeOffset = 0,
57-
$Warning = $null,
58-
$Critical = $null,
59-
[int]$Timeout = 10,
60-
[switch]$IPV4 = $FALSE,
61-
[int]$Port = 123,
62-
[switch]$NoPerfData = $FALSE,
58+
$TimeOffset = 0,
59+
$Warning = $null,
60+
$Critical = $null,
61+
[int]$Timeout = 10,
62+
[switch]$IPV4 = $FALSE,
63+
[int]$Port = 123,
64+
[switch]$IgnoreService = $FALSE,
65+
[switch]$NoPerfData = $FALSE,
6366
[ValidateSet(0, 1, 2, 3)]
64-
[int]$Verbosity = 0
67+
[int]$Verbosity = 0
6568
);
6669

6770
$TimeData = Get-IcingaNtpData -Server $Server -Port $Port -TimeOffset $TimeOffset -Timeout $Timeout -IPV4:$IPV4;
@@ -86,7 +89,9 @@ function Invoke-IcingaCheckTimeSync()
8689
-MetricIndex $Server `
8790
-MetricName 'service';
8891

89-
$TimeCheck.CritIfNotMatch($ProviderEnums.ServiceStatus.Running) | Out-Null;
92+
if ($IgnoreService -eq $FALSE) {
93+
$TimeCheck.CritIfNotMatch($ProviderEnums.ServiceStatus.Running) | Out-Null;
94+
}
9095

9196
$SyncStatus = New-IcingaCheck `
9297
-Name 'Sync Status' `

0 commit comments

Comments
 (0)