Ejemplo n.º 1
0
func rpcTransferUpdate() {
	ag.ParseConfig(agentConfig)
	ag.InitRpcClients()

	now := time.Now().Unix()
	value := now % 100
	metrics := []*model.MetricValue{}
	mv := &model.MetricValue{"fake-agent", "cpu.idle", value, step, "GAUGE", "module=transfer-fake", now}
	metrics = append(metrics, mv)

	fmt.Printf("[REQ .] <Total=%d> %v\n", len(metrics), metrics[0])

	var resp model.TransferResponse
	err := ag.TransferClient.Call("Transfer.Update", metrics, &resp)
	if err != nil {
		fmt.Println("[ERROR] Transfer.Update:", err)
	}

	fmt.Println("[RESP.]", &resp)
}
Ejemplo n.º 2
0
func main() {

	cfg := flag.String("c", "cfg.json", "configuration file")
	version := flag.Bool("v", false, "show version")
	check := flag.Bool("check", false, "check collector")

	flag.Parse()

	if *version {
		fmt.Println(g.VERSION)
		os.Exit(0)
	}

	if *check {
		funcs.CheckCollector()
		os.Exit(0)
	}

	g.ParseConfig(*cfg)

	g.GetHostnameFromAws()

	g.InitRootDir()
	g.InitLocalIps()
	g.InitRpcClients()

	funcs.BuildMappers()

	go cron.InitDataHistory()

	cron.ReportAgentStatus()
	cron.SyncMinePlugins()
	cron.SyncBuiltinMetrics()
	cron.SyncTrustableIps()
	cron.Collect()

	go http.Start()

	select {}

}