NVIDIA GPU loadable plugin
Source
1
+
/*
2
+
** Copyright (C) 2001-2024 Zabbix SIA
3
+
**
4
+
** Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
5
+
** documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
6
+
** rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7
+
** permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
+
**
9
+
** The above copyright notice and this permission notice shall be included in all copies or substantial portions
10
+
** of the Software.
11
+
**
12
+
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
13
+
** WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+
** COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
15
+
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16
+
** SOFTWARE.
17
+
**/
18
+
19
+
package main
20
+
21
+
import (
22
+
"errors"
23
+
"fmt"
24
+
"os"
25
+
26
+
"golang.zabbix.com/plugin/nvidia/plugin"
27
+
"golang.zabbix.com/sdk/plugin/flag"
28
+
"golang.zabbix.com/sdk/zbxerr"
29
+
)
30
+
31
+
const copyrightMessage = //
32
+
`Copyright 2001-%d Zabbix SIA
33
+
34
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
35
+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
36
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
37
+
permit persons to whom the Software is furnished to do so, subject to the following conditions:
38
+
39
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions
40
+
of the Software.
41
+
42
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
43
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
44
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
45
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
46
+
SOFTWARE.
47
+
`
48
+
49
+
//nolint:gochecknoglobals,revive // required ALL_CAPS by build scripts
50
+
var (
51
+
PLUGIN_VERSION_MAJOR = 7
52
+
PLUGIN_VERSION_MINOR = 2
53
+
PLUGIN_VERSION_PATCH = 0
54
+
PLUGIN_VERSION_RC = "alpha1"
55
+
PLUGIN_LICENSE_YEAR = 2024
56
+
)
57
+
58
+
func main() {
59
+
err := flag.HandleFlags(
60
+
plugin.Name,
61
+
os.Args[0],
62
+
fmt.Sprintf(copyrightMessage, PLUGIN_LICENSE_YEAR),
63
+
PLUGIN_VERSION_RC,
64
+
PLUGIN_VERSION_MAJOR,
65
+
PLUGIN_VERSION_MINOR,
66
+
PLUGIN_VERSION_PATCH,
67
+
)
68
+
if err != nil {
69
+
if errors.Is(err, zbxerr.ErrorOSExitZero) {
70
+
return
71
+
}
72
+
73
+
panic(err)
74
+
}
75
+
76
+
err = plugin.Launch()
77
+
if err != nil {
78
+
panic(err)
79
+
}
80
+
}