Ejemplo n.º 1
0
func newCoreosSources(options map[string][]string) ([]api.Source, error) {
	fleetEndpoints := defaultFleetEndpoints
	if len(options["fleetEndpoint"]) > 0 {
		fleetEndpoints = options["fleetEndpoint"]
	}

	nodesApi, err := nodes.NewCoreOSNodes(fleetEndpoints)
	if err != nil {
		return nil, err
	}

	cadvisorPort := defaultCadvisorPort
	if len(options["cadvisorPort"]) > 0 {
		cadvisorPort, err = strconv.Atoi(options["cadvisorPort"][0])
		if err != nil {
			return nil, err
		}
	}

	return []api.Source{
		&cadvisorSource{
			cadvisorApi:  datasource.NewCadvisor(),
			nodesApi:     nodesApi,
			cadvisorPort: cadvisorPort,
		},
	}, nil
}
Ejemplo n.º 2
0
func newCoreOSCadvisorSource(pollDuration time.Duration) (Source, error) {
	if *argCadvisorPort <= 0 {
		return nil, fmt.Errorf("invalid cadvisor port - %d", *argCadvisorPort)
	}
	nodesApi, err := nodes.NewCoreOSNodes()
	if err != nil {
		return nil, err
	}
	return &cadvisorSource{
		pollDuration: pollDuration,
		cadvisorApi:  datasource.NewCadvisor(),
		nodesApi:     nodesApi,
		cadvisorPort: strconv.Itoa(*argCadvisorPort),
		lastQuery:    time.Now(),
	}, nil
}