Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config/director/Invoke-IcingaCheckHttpJsonResponse.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/director/Invoke-IcingaCheckTimeSync.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion config/director/Plugins_Bundle.json

Large diffs are not rendered by default.

480 changes: 240 additions & 240 deletions config/icinga/Invoke-IcingaCheckHttpJsonResponse.conf

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions config/icinga/Invoke-IcingaCheckTimeSync.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ object CheckCommand "Invoke-IcingaCheckTimeSync" {
value = "$IcingaCheckTimeSync_Int32_Port$"
order = 7
}
"-IgnoreService" = {
set_if = "$IcingaCheckTimeSync_Switchparameter_IgnoreService$"
order = 99
}
"-NoPerfData" = {
set_if = "$IcingaCheckTimeSync_Switchparameter_NoPerfData$"
order = 99
Expand Down Expand Up @@ -83,4 +87,5 @@ object CheckCommand "Invoke-IcingaCheckTimeSync" {
}
vars.IcingaCheckTimeSync_Switchparameter_NoPerfData = false
vars.IcingaCheckTimeSync_Switchparameter_IPV4 = false
vars.IcingaCheckTimeSync_Switchparameter_IgnoreService = false
}
19 changes: 12 additions & 7 deletions config/icinga/Plugins_Bundle.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2804,12 +2804,12 @@ object CheckCommand "Invoke-IcingaCheckUNCPath" {
order = 8
}
"-CriticalTotal" = {
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"
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"
value = "$IcingaCheckUNCPath_Object_CriticalTotal$"
order = 7
}
"-WarningTotal" = {
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"
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"
value = "$IcingaCheckUNCPath_Object_WarningTotal$"
order = 6
}
Expand Down Expand Up @@ -3717,7 +3717,7 @@ object CheckCommand "Invoke-IcingaCheckUpdates" {

arguments += {
"-WarningRollups" = {
description = "The warning threshold for the total pending update count on the Windows machine"
description = "The warning threshold for the rollup update count on the Windows machine"
value = "$IcingaCheckUpdates_Object_WarningRollups$"
order = 7
}
Expand All @@ -3735,7 +3735,7 @@ object CheckCommand "Invoke-IcingaCheckUpdates" {
order = 99
}
"-CriticalOther" = {
description = "The critical threshold for all other updates on the Windows machine"
description = "The critical threshold for the total pending update count on the Windows machine"
value = "$IcingaCheckUpdates_Object_CriticalOther$"
order = 12
}
Expand All @@ -3744,7 +3744,7 @@ object CheckCommand "Invoke-IcingaCheckUpdates" {
order = 0
}
"-WarningDefender" = {
description = "The warning threshold for the total pending update count on the Windows machine"
description = "The warning threshold for the Microsoft Defender update count on the Windows machine"
value = "$IcingaCheckUpdates_Object_WarningDefender$"
order = 9
}
Expand Down Expand Up @@ -3782,7 +3782,7 @@ object CheckCommand "Invoke-IcingaCheckUpdates" {
order = 10
}
"-CriticalRollups" = {
description = "The critical threshold for the rollup update count on the Windows machine"
description = "The critical threshold for the total pending update count on the Windows machine"
value = "$IcingaCheckUpdates_Object_CriticalRollups$"
order = 8
}
Expand Down Expand Up @@ -3824,7 +3824,7 @@ object CheckCommand "Invoke-IcingaCheckUpdates" {
order = 5
}
"-CriticalSecurity" = {
description = "The critical threshold for the security update count on the Windows machine"
description = "The critical threshold for the total pending update count on the Windows machine"
value = "$IcingaCheckUpdates_Object_CriticalSecurity$"
order = 6
}
Expand Down Expand Up @@ -3934,6 +3934,10 @@ object CheckCommand "Invoke-IcingaCheckTimeSync" {
value = "$IcingaCheckTimeSync_Int32_Port$"
order = 7
}
"-IgnoreService" = {
set_if = "$IcingaCheckTimeSync_Switchparameter_IgnoreService$"
order = 99
}
"-NoPerfData" = {
set_if = "$IcingaCheckTimeSync_Switchparameter_NoPerfData$"
order = 99
Expand Down Expand Up @@ -3991,6 +3995,7 @@ object CheckCommand "Invoke-IcingaCheckTimeSync" {
}
vars.IcingaCheckTimeSync_Switchparameter_NoPerfData = false
vars.IcingaCheckTimeSync_Switchparameter_IPV4 = false
vars.IcingaCheckTimeSync_Switchparameter_IgnoreService = false
}


6 changes: 6 additions & 0 deletions doc/31-Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ documentation before upgrading to a new release.

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

## 1.10.1 (2022-12-20)

### Enhancements

* [#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

## 1.10.0 (2022-08-30)

[Issue and PRs](https://github.com/Icinga/icinga-powershell-plugins/milestone/13?closed=1)
Expand Down
1 change: 1 addition & 0 deletions doc/plugins/18-Invoke-IcingaCheckTimeSync.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ No special permissions required.
| Timeout | Int32 | false | 10 | Seconds before connection times out (default: 10) |
| IPV4 | SwitchParameter | false | False | Use IPV4 connection. Default $FALSE |
| Port | Int32 | false | 123 | Port number (default: 123) |
| 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 |
| NoPerfData | SwitchParameter | false | False | |
| 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]) |
| 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. |
Expand Down
140 changes: 70 additions & 70 deletions doc/plugins/28-Invoke-IcingaCheckHttpJsonResponse.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@

# Invoke-IcingaCheckHttpJsonResponse

## Description

Retrieves a JSON-Object via Request and performs desired checks

Invoke-IcingaCheckHttpJsonResponse returns 'OK', 'WARNING' or 'CRITICAL', depending on the parameters Warning and Critical
More Information on https://github.com/Icinga/icinga-powershell-plugins

## Permissions

No special permissions required.

## Arguments

| Argument | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| ServerUri | String | false | | Base URI of the server, example "https://example.comm" |
| ServerPath | String | false | | Path for the request, example "/v1/my_endpoint" |
| QueryParameter | String | false | | Query parameter for the request without ?, example "command=example" |
| Username | String | false | | Credentials to use for basic auth |
| Password | SecureString | false | | Credentials to use for basic auth |
| Timeout | Int32 | false | 30 | Timeout in seconds before the http request is aborted. Defaults to 30 |
| 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'" |
| ValueTypes | Array | false | @() | Value types of each parameter. Supported Types: Numeric, Boolean, DateTime, String Example: "myAlias01:Numeric","myAlias02:DateTime" |
| Warning | Array | false | @() | Warning thresholds using icinga-powershell syntax. Example: "myNumericAlias01:~:2","myDateTimeAlias:-10d", "myBooleanAlias:True" |
| Critical | Array | false | @() | Critical thresholds using icinga-powershell syntax. Example: "myNumericAlias01:~:2","myDateTimeAlias:-10d", "myBooleanAlias:True" |
| IgnoreSSL | SwitchParameter | false | False | Disables SSL verification and allows the connection to endpoints with self-signed certificates as example |
| 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 |
| 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 |
| 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]) |
| NoPerfData | SwitchParameter | false | False | |
| 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. |

## Examples

### Example Command 1

```powershell
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"
```

### Example Output 1

```powershell
[CRITICAL] HTTP JSON Response Monitor [CRITICAL] Check returned value for oldestTime (2022/01/27 06:54:18)
\_ [OK] All requested parameters are available in JSON response: 2
\_ [OK] Check returned value for myNumberOfItems: 2
\_ [CRITICAL] Check returned value for oldestTime: 2022/01/27 06:54:18 is lower than 2022/03/07 10:01:31 (-4d)
\_ [OK] Parameters evaluated: 0
\_ [OK] Response received: False
```

### Example Command 2

```powershell
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"
```

### Example Output 2

```powershell
[WARNING] HTTP JSON Response Monitor [WARNING] Check returned value for myNumberOfItems (2), Check returned value for oldestTime (2022/01/27 06:54:18)
\_ [OK] All requested parameters are available in JSON response: 2
\_ [WARNING] Check returned value for myNumberOfItems: 2 is greater than threshold 1
\_ [WARNING] Check returned value for oldestTime: 2022/01/27 06:54:18 is lower than 2022/03/07 10:23:58 (-2d)
\_ [OK] Parameters evaluated: 0
\_ [OK] Response received: False
```
# Invoke-IcingaCheckHttpJsonResponse
## Description
Retrieves a JSON-Object via Request and performs desired checks
Invoke-IcingaCheckHttpJsonResponse returns 'OK', 'WARNING' or 'CRITICAL', depending on the parameters Warning and Critical
More Information on https://github.com/Icinga/icinga-powershell-plugins
## Permissions
No special permissions required.
## Arguments
| Argument | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| ServerUri | String | false | | Base URI of the server, example "https://example.comm" |
| ServerPath | String | false | | Path for the request, example "/v1/my_endpoint" |
| QueryParameter | String | false | | Query parameter for the request without ?, example "command=example" |
| Username | String | false | | Credentials to use for basic auth |
| Password | SecureString | false | | Credentials to use for basic auth |
| Timeout | Int32 | false | 30 | Timeout in seconds before the http request is aborted. Defaults to 30 |
| 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'" |
| ValueTypes | Array | false | @() | Value types of each parameter. Supported Types: Numeric, Boolean, DateTime, String Example: "myAlias01:Numeric","myAlias02:DateTime" |
| Warning | Array | false | @() | Warning thresholds using icinga-powershell syntax. Example: "myNumericAlias01:~:2","myDateTimeAlias:-10d", "myBooleanAlias:True" |
| Critical | Array | false | @() | Critical thresholds using icinga-powershell syntax. Example: "myNumericAlias01:~:2","myDateTimeAlias:-10d", "myBooleanAlias:True" |
| IgnoreSSL | SwitchParameter | false | False | Disables SSL verification and allows the connection to endpoints with self-signed certificates as example |
| 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 |
| 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 |
| 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]) |
| NoPerfData | SwitchParameter | false | False | |
| 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. |
## Examples
### Example Command 1
```powershell
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"
```
### Example Output 1
```powershell
[CRITICAL] HTTP JSON Response Monitor [CRITICAL] Check returned value for oldestTime (2022/01/27 06:54:18)
\_ [OK] All requested parameters are available in JSON response: 2
\_ [OK] Check returned value for myNumberOfItems: 2
\_ [CRITICAL] Check returned value for oldestTime: 2022/01/27 06:54:18 is lower than 2022/03/07 10:01:31 (-4d)
\_ [OK] Parameters evaluated: 0
\_ [OK] Response received: False
```
### Example Command 2
```powershell
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"
```
### Example Output 2
```powershell
[WARNING] HTTP JSON Response Monitor [WARNING] Check returned value for myNumberOfItems (2), Check returned value for oldestTime (2022/01/27 06:54:18)
\_ [OK] All requested parameters are available in JSON response: 2
\_ [WARNING] Check returned value for myNumberOfItems: 2 is greater than threshold 1
\_ [WARNING] Check returned value for oldestTime: 2022/01/27 06:54:18 is lower than 2022/03/07 10:23:58 (-2d)
\_ [OK] Parameters evaluated: 0
\_ [OK] Response received: False
```
23 changes: 14 additions & 9 deletions plugins/Invoke-IcingaCheckTimeSync.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
Seconds before connection times out (default: 10)
.PARAMETER IPV4
Use IPV4 connection. Default $FALSE
.PARAMETER IgnoreService
Ignores the W32Time service during check execution and will not throw warning or critical in case the service is not running
.PARAMETER Verbosity
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
Expand Down Expand Up @@ -53,15 +55,16 @@ function Invoke-IcingaCheckTimeSync()
{
param(
[string]$Server,
$TimeOffset = 0,
$Warning = $null,
$Critical = $null,
[int]$Timeout = 10,
[switch]$IPV4 = $FALSE,
[int]$Port = 123,
[switch]$NoPerfData = $FALSE,
$TimeOffset = 0,
$Warning = $null,
$Critical = $null,
[int]$Timeout = 10,
[switch]$IPV4 = $FALSE,
[int]$Port = 123,
[switch]$IgnoreService = $FALSE,
[switch]$NoPerfData = $FALSE,
[ValidateSet(0, 1, 2, 3)]
[int]$Verbosity = 0
[int]$Verbosity = 0
);

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

$TimeCheck.CritIfNotMatch($ProviderEnums.ServiceStatus.Running) | Out-Null;
if ($IgnoreService -eq $FALSE) {
$TimeCheck.CritIfNotMatch($ProviderEnums.ServiceStatus.Running) | Out-Null;
}

$SyncStatus = New-IcingaCheck `
-Name 'Sync Status' `
Expand Down