You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Fix --severity-timeout: detect connection errors (no stdout + stderr)
and apply configurable severity instead of always exiting UNKNOWN
- Fix --severity-stderr: remove cu() early exit so stderr flows to the
analysis section where --severity-stderr is applied
- Improve help texts: clarify --command accepts PowerShell pipelines,
explain --winrm-domain usage, note Kerberos optionality for credentials
- Add README prerequisites section with transport comparison table,
Windows/Linux setup, and --winrm-domain explanation
- Add README examples: pipeline, regex matching, JEA endpoint, error output
- Fix README States section to match actual behavior
@@ -21,6 +21,43 @@ This makes the plugin ideal for retrieving Windows-specific metrics, running cus
21
21
| 3rd Party Python modules |`pypsrp` (supports JEA). Alternative without JEA: `pywinrm`, `pywinrm[kerberos]`, `pywinrm[credssp]`|
22
22
23
23
24
+
## Prerequisites
25
+
26
+
### Windows (Remote Host)
27
+
28
+
Enable WinRM on the target Windows host:
29
+
30
+
```powershell
31
+
Enable-PSRemoting -Force
32
+
```
33
+
34
+
By default, WinRM listens on port **5985** (HTTP) and **5986** (HTTPS). Ensure the corresponding firewall port is open.
35
+
36
+
Depending on the chosen transport, additional configuration may be required:
37
+
38
+
| Transport | When to use | Extra Setup on Windows |
39
+
|----|----|----|
40
+
|`ntlm` (default) | Domain and workgroup environments. Works out of the box. | None - works with `Enable-PSRemoting`. |
41
+
|`kerberos`| Active Directory environments. Most secure; supports SSO via `kinit` on the monitoring host (no password needed). | Requires AD domain membership. |
42
+
|`basic`| Testing or HTTPS-only setups. Credentials are base64-encoded (not encrypted). |`winrm set winrm/config/service/auth @{Basic="true"}`. Use HTTPS in production. |
43
+
|`credssp`| Multi-hop scenarios where credentials must be delegated to a third system. |`Enable-WSManCredSSP -Role Server` on the target host. |
44
+
|`plaintext`| Same as `basic` but explicitly over HTTP. | Same as `basic`. Insecure - avoid in production. |
45
+
46
+
### Linux (Monitoring Host)
47
+
48
+
For **Kerberos** transport, configure `/etc/krb5.conf` for your Active Directory domain and obtain a ticket before running the plugin:
49
+
50
+
```bash
51
+
kinit user@EXAMPLE.COM
52
+
```
53
+
54
+
When Kerberos credentials are present in the cache, `--winrm-username` and `--winrm-password` can be omitted.
55
+
56
+
### `--winrm-domain`
57
+
58
+
When set, the username is sent as `user@DOMAIN` for NTLM authentication. Use the Active Directory domain name (e.g. `EXAMPLE.COM`). Not needed for Kerberos (the domain is part of the Kerberos principal) or local accounts.
Check if the Windows Update service is running - alert with CRIT if it is stopped (uses a pipeline and pattern matching):
196
+
197
+
```bash
198
+
./by-winrm \
199
+
--winrm-hostname=winsrv.example.com \
200
+
--winrm-username=Administrator \
201
+
--winrm-password=linuxfabrik \
202
+
--winrm-domain=EXAMPLE.COM \
203
+
--command='(Get-Service -Name wuauserv).Status' \
204
+
--critical-pattern='Stopped'
205
+
```
206
+
207
+
Output if the service is stopped:
208
+
209
+
```text
210
+
Stopped [CRITICAL]
211
+
```
212
+
213
+
Use regex matching - alert with WARNING if any of the last 50 system event log messages contain "disk", or CRIT if they contain "error" or "fail":
214
+
215
+
```bash
216
+
./by-winrm \
217
+
--winrm-hostname=winsrv.example.com \
218
+
--winrm-username=Administrator \
219
+
--winrm-password=linuxfabrik \
220
+
--winrm-domain=EXAMPLE.COM \
221
+
--command='Get-EventLog -LogName System -Newest 50 | Select-Object -ExpandProperty Message' \
222
+
--warning-pattern='disk' \
223
+
--critical-regex='error|fail'
224
+
```
225
+
226
+
Use Kerberos authentication (no password needed when a valid ticket exists):
155
227
156
228
```bash
157
229
kinit -V linus@EXAMPLE.COM
@@ -163,6 +235,37 @@ klist
163
235
--command='Get-CpuPercent'
164
236
```
165
237
238
+
Use a JEA (Just Enough Administration) endpoint - requires `pypsrp`:
239
+
240
+
```bash
241
+
./by-winrm \
242
+
--winrm-hostname=winsrv.example.com \
243
+
--winrm-username=jea-operator \
244
+
--winrm-password=linuxfabrik \
245
+
--winrm-domain=EXAMPLE.COM \
246
+
--winrm-configuration-name=MyJEAEndpoint \
247
+
--command='Get-DiskSpace'
248
+
```
249
+
250
+
The `--winrm-configuration-name` specifies the PowerShell session configuration (JEA endpoint) on the target host. Only the cmdlets allowed by the JEA role capability will be available.
251
+
252
+
What error output looks like - for example when authentication fails:
253
+
254
+
```bash
255
+
./by-winrm \
256
+
--winrm-hostname=winsrv.example.com \
257
+
--winrm-username=Administrator \
258
+
--winrm-password=wrong-password \
259
+
--winrm-domain=EXAMPLE.COM \
260
+
--command='Get-Service'
261
+
```
262
+
263
+
Output:
264
+
265
+
```text
266
+
the server did not respond with one of the following authentication methods - Negotiate [UNKNOWN]
267
+
```
268
+
166
269
167
270
## States
168
271
@@ -182,7 +285,7 @@ Output on STDERR?
182
285
183
286
Return code != 0?
184
287
185
-
* Depending on the given `--severity-timeout`, returns OK, WARN, CRIT or UNKNOWN (default) if SSH can't connect.
288
+
* Depending on the given `--severity-timeout`, returns OK, WARN, CRIT or UNKNOWN (default) if WinRM can't connect (no command output but error present).
186
289
* Depending on the given `--severity-retc`, returns OK, WARN (default), CRIT or UNKNOWN if there is a return code != 0.
Copy file name to clipboardExpand all lines: check-plugins/by-winrm/icingaweb2-module-director/by-winrm.json
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -220,7 +220,7 @@
220
220
"tpl-service-generic"
221
221
],
222
222
"max_check_attempts": 5,
223
-
"notes": "This plugin executes commands on remote Windows hosts by WinRM, supporting JEA. It returns standard output (STDOUT) and, in case of failure, standard error (STDERR) along with the command's exit code. By evaluating these results - through threshold checks or pattern matching on STDOUT - the plugin can generate alerts with configurable severity levels. ",
223
+
"notes": "This plugin executes PowerShell commands or scripts on remote Windows hosts via WinRM, supporting JEA. It returns standard output (STDOUT) and, in case of failure, standard error (STDERR) along with the command's exit code. By evaluating these results - through threshold checks or pattern matching on STDOUT - the plugin can generate alerts with configurable severity levels. ",
0 commit comments