-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (39 loc) · 901 Bytes
/
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
package main
import (
"bufio"
"flag"
"fmt"
"os"
"time"
. "github.com/blacked/go-zabbix"
"github.com/jimlawless/cfg"
)
var (
configFile string
parameter string
parameterValue string
stdin *bufio.Reader
)
const (
defaultPort = 10051
)
func init() {
stdin = bufio.NewReader(os.Stdin)
flag.StringVar(&configFile, "c", "/etc/zabbix/zabbix_agentd.conf", "Zabbix config file")
flag.StringVar(¶meter, "p", "test", "Parameter")
flag.StringVar(¶meterValue, "v", "0", "Parameter value")
}
func main() {
flag.Parse()
zbxCfg := make(map[string]string)
err := cfg.Load(configFile, zbxCfg)
if err != nil {
panic(err)
}
var metrics []*Metric
metrics = append(metrics, NewMetric(zbxCfg["hostname"], parameter, parameterValue, time.Now().Unix()))
packet := NewPacket(metrics)
z := NewSender(zbxCfg["server"], defaultPort)
z.Send(packet)
fmt.Println("OK")
}