From 294b24e56777d23900f6f84e554ba672fdfa2910 Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Fri, 11 Sep 2020 16:33:41 +0200 Subject: [PATCH] Names are sound and smoke Let's use check_by_powershell fixes #4 --- .github/workflows/go.yml | 2 +- Makefile | 2 +- README.md | 13 +++++++------ go.mod | 2 +- icinga2/command.conf | 32 ++++++++++++++++---------------- main.go | 6 +++--- 6 files changed, 29 insertions(+), 28 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a18e1a8..004e04a 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -35,5 +35,5 @@ jobs: - name: Upload artifact uses: actions/upload-artifact@v1.0.0 with: - name: check_by_winrm-go${{ matrix.go }} + name: check_by_powershell-go${{ matrix.go }} path: build diff --git a/Makefile b/Makefile index c83f4bf..7a087a4 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ GIT_COMMIT := $(shell git rev-list -1 HEAD) GO_BUILD := go build -v -ldflags "-X main.GitCommit=$(GIT_COMMIT)" -NAME = check_by_winrm +NAME = check_by_powershell .PHONY: all clean build test diff --git a/README.md b/README.md index ec5d959..23ca00d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ -# check_by_winrm +# check_by_powershell -Icinga check plugin to run checks and other commands directly on any Windows system using WinRM (Windows Remote Management). +Icinga check plugin to run checks and other commands directly on any Windows system using +WinRM (Windows Remote Management) and Powershell. Main use case would be to call one of the [plugins](https://github.com/Icinga/icinga-powershell-plugins) from the [Icinga Powershell Framework](https://github.com/Icinga/icinga-powershell-framework). This will avoid the @@ -50,7 +51,7 @@ Also, see the Icinga 2 examples in the [icinga2/ directory](icinga2/). Calling a PowerShell plugin from the framework is easy: - ./check_by_winrm -H example.local.de --user 'ad\user' --password '!secret!pw' \ + ./check_by_powershell -H example.local.de --user 'ad\user' --password '!secret!pw' \ --icingacmd 'Invoke-IcingaCheckCPU -Warning 80 -Critical 90' [OK] Check package "CPU Load" @@ -63,7 +64,7 @@ Notes: Executing any other Windows program or script, could be another Icinga plugin: - ./check_by_winrm -H 192.168.172.217 \ + ./check_by_powershell -H 192.168.172.217 \ --user 'windowsuser' --password 'secret!pw' \ --cmd "cscript.exe /T:30 /NoLogo C:\Windows\system32\check_time.vbs 1.de.pool.ntp.org 20 240" @@ -156,8 +157,8 @@ The plugin is written in Golang and can easily be compiled from source, see the for further details. ``` -GOOS=linux GOARCH=amd64 go build -o check_by_winrm . -GOOS=windows GOARCH=amd64 go build -o check_by_winrm.exe . +GOOS=linux GOARCH=amd64 go build -o check_by_powershell . +GOOS=windows GOARCH=amd64 go build -o check_by_powershell.exe . ``` ## Acknowledgements diff --git a/go.mod b/go.mod index b2f2361..31322f4 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Icinga/check_by_winrm +module github.com/Icinga/check_by_powershell go 1.14 diff --git a/icinga2/command.conf b/icinga2/command.conf index 3014b32..6b17a3a 100644 --- a/icinga2/command.conf +++ b/icinga2/command.conf @@ -1,5 +1,5 @@ object CheckCommand "winrm" { - command = [ PluginDir + "/check_by_winrm" ] + command = [ PluginDir + "/check_by_powershell" ] arguments = { "-H" = { @@ -7,40 +7,40 @@ object CheckCommand "winrm" { description = "Host name, IP Address of the remote host" } "-p" = { - value = "$winrm_port$" + value = "$powershell_port$" description = "Port number WinRM" } "--user" = { - value = "$winrm_user$" + value = "$powershell_user$" description = "Username of the remote host" } "--password" = { - value = "$winrm_password$" + value = "$powershell_password$" description = "Password of the user" } "--no-tls" = { - value = "$winrm_no_tls$" + value = "$powershell_no_tls$" description = "Don't use a TLS connection" } "--insecure" = { - value = "$winrm_insecure$" + value = "$powershell_insecure$" description = "Verify the hostname on the returned certificate" } "--ca" = { - value = "$winrm_ca$" + value = "$powershell_ca$" description = "CA certificate" } "--cert" = { - value = "$winrm_cert$" + value = "$powershell_cert$" description = "Client certificate" } "--key" = { - value = "$winrm_key$" + value = "$powershell_key$" description = "Client key" } "--icingacmd" = {{ - var command = macro("$by_winrm_command$") - var arguments = macro("$by_winrm_arguments$") + var command = macro("$by_powershell_command$") + var arguments = macro("$by_powershell_arguments$") if (typeof(command) == String && !arguments) { return command } @@ -53,23 +53,23 @@ object CheckCommand "winrm" { description = "Executes commands of Icinga PowerShell Framework" }} "--cmd" = { - value = "$winrm_cmd$" + value = "$powershell_cmd$" description = "Command to execute on the remote machine" } "--auth" = { - value = "$winrm_auth$" + value = "$powershell_auth$" description = "Authentication mechanism - NTLM | SSH" } "--sshhost" = { - value = "$winrm_sshhost$" + value = "$powershell_sshhost$" description = "SSH Host" } "--sshuser" = { - value = "$winrm_sshuser$" + value = "$powershell_sshuser$" description = "SSH Username" } "--sshpassword" = { - value = "$winrm_sshpassword$" + value = "$powershell_sshpassword$" description = "SSH Password" } } diff --git a/main.go b/main.go index 44aa210..a1e282b 100644 --- a/main.go +++ b/main.go @@ -8,7 +8,7 @@ import ( ) const readme = `Icinga check plugin to run checks and other commands directly on -any Windows system using WinRM (Windows Remote Management) +any Windows system using WinRM (Windows Remote Management) and Powershell Main use case would be to call one of the plugins from the Icinga Powershell Framework. This will avoid the requirement of installing an Icinga 2 agent on every Windows system. @@ -21,7 +21,7 @@ Supported authentication methods: * NTLM with local or AD accounts * TLS client certificate -https://github.com/Icinga/check_by_winrm +https://github.com/Icinga/check_by_powershell https://github.com/Icinga/icinga-powershell-framework https://github.com/Icinga/icinga-powershell-plugins @@ -46,7 +46,7 @@ func main() { plugin := check.NewConfig() - plugin.Name = "check_by_winrm" + plugin.Name = "check_by_powershell" plugin.Readme = readme plugin.Version = buildVersion() plugin.Timeout = 10