Пример #1
0
func Metric() {
	metric.SetGlobalSetting(
		g.Docker, time.Duration(common.STATS_TIMEOUT),
		time.Duration(common.STATS_FORCE_DONE),
		common.VLAN_PREFIX, common.DEFAULT_BR,
	)
	logs.Info("Metrics initiated")
}
Пример #2
0
func main() {
	var dockerAddr string
	var transferAddr string
	var certDir string
	flag.BoolVar(&logs.Mode, "DEBUG", false, "enable debug")
	flag.StringVar(&dockerAddr, "d", "tcp://192.168.99.100:2376", "docker daemon addr")
	flag.StringVar(&transferAddr, "t", "10.200.8.37:8433", "transfer addr")
	flag.StringVar(&certDir, "c", "/root/.docker", "cert files dir")
	flag.Parse()
	if flag.NArg() < 1 {
		fmt.Println("need at least one container id")
		return
	}

	cert := fmt.Sprintf("%s/cert.pem", certDir)
	key := fmt.Sprintf("%s/key.pem", certDir)
	ca := fmt.Sprintf("%s/ca.pem", certDir)
	dockerclient, err := docker.NewTLSClient(dockerAddr, cert, key, ca)
	if err != nil {
		fmt.Println(err)
		return
	}

	metric.SetGlobalSetting(dockerclient, 2, 3, "vnbe", "eth0")
	client := falcon.CreateFalconClient(transferAddr, 5*time.Millisecond)

	for i := 0; i < flag.NArg(); i++ {
		if c, err := dockerclient.InspectContainer(flag.Arg(i)); err != nil {
			fmt.Println(flag.Arg(i), err)
			continue
		} else {
			go start_watcher(client, c.ID, c.State.Pid)
		}
	}
	for {
	}
}