-
Notifications
You must be signed in to change notification settings - Fork 0
/
g2z.go
41 lines (33 loc) · 930 Bytes
/
g2z.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
package main
/*
#include "g2z.h"
*/
import "C"
import (
"zabbix.com/pkg/plugin"
webcertificate "zabbix.com/plugins/web/certificate"
)
var impl webcertificate.Plugin
//export sheep_set_timeout
func sheep_set_timeout(timeout C.int) {
var options plugin.GlobalOptions
options.Timeout = int(timeout)
impl.Configure(&options, nil)
}
//export sheep_check_item
func sheep_check_item(request *C.AGENT_REQUEST, result *C.AGENT_RESULT) C.int {
var params = make([]string, C.sheep_get_rparams_num(request))
for i := 0; i < len(params); i++ {
params[i] = C.GoString(C.sheep_get_rparam(request, C.int(i)))
}
if text, err := impl.Export("web.certificate.get", params, nil); err != nil {
C.sheep_SET_MSG_RESULT(result, C.CString(err.Error()))
return C.SYSINFO_RET_FAIL
} else {
C.sheep_SET_TEXT_RESULT(result, C.CString(text.(string)))
return C.SYSINFO_RET_OK
}
}
func main() {
panic("This should never happen.")
}