-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
70 lines (50 loc) · 1.97 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"fmt"
"os"
"time"
"github.com/NETWAYS/go-check"
)
const readme = `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 from the Icinga Powershell Framework.
This will avoid the requirement of installing an Icinga 2 agent on every Windows system.
The plugin will require WinRM to be preconfigured for access with a HTTPs or HTTP connection.
Supported authentication methods:
* Basic with local users
* NTLM with local or AD accounts
* TLS client certificate
https://github.com/Icinga/check_by_powershell
https://github.com/Icinga/icinga-powershell-framework
https://github.com/Icinga/icinga-powershell-plugins
Copyright (c) 2020 Icinga GmbH <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see https://www.gnu.org/licenses/.`
func main() {
defer check.CatchPanic()
plugin := check.NewConfig()
plugin.Name = "check_by_powershell"
plugin.Readme = readme
plugin.Version = buildVersion()
plugin.Timeout = 10
config := BuildConfigFlags(plugin.FlagSet)
plugin.ParseArguments()
err := config.Validate()
if err != nil {
check.ExitRaw(check.Unknown, "could not validate parameters: "+err.Error())
}
err, rc, output := config.Run(time.Duration(plugin.Timeout) * time.Second)
if err != nil {
check.ExitRaw(check.Unknown, "execution failed: "+err.Error())
}
fmt.Print(output)
os.Exit(rc)
}