func (a *Agent) Connect() error {
	for _, o := range a.Config.Outputs {
		switch ot := o.Output.(type) {
		case telegraf.ServiceOutput:
			if err := ot.Start(); err != nil {
				log.Printf("E! Service for output %s failed to start, exiting\n%s\n",
					o.Name, err.Error())
				return err
			}
		}

		log.Printf("D! Attempting connection to output: %s\n", o.Name)
		err := o.Output.Connect()
		if err != nil {
			log.Printf("E! Failed to connect to output %s, retrying in 15s, "+
				"error was '%s' \n", o.Name, err)
			time.Sleep(15 * time.Second)
			err = o.Output.Connect()
			if err != nil {
				return err
			}
		}
		log.Printf("D! Successfully connected to output: %s\n", o.Name)
	}
	return nil
}
// Connect connects to all configured outputs
Connect connects to all configured outputs
// Connect connects to all configured outputs
func (a *Agent) Connect() error {
	for _, o := range a.Config.Outputs {
		switch ot := o.Output.(type) {
		case telegraf.ServiceOutput:
			if err := ot.Start(); err != nil {
				log.Printf("E! Service for output %s failed to start, exiting\n%s\n",
					o.Name, err.Error())
				return err
			}
		}
		log.Printf("D! Attempting connection to output: %s\n", o.Name)
		err := o.Output.Connect()
		if err != nil {
			log.Printf("E! Failed to connect to output %s, retrying in 15s, "+
				"error was '%s' \n", o.Name, err)
			time.Sleep(15 * time.Second)
			err = o.Output.Connect()
			if err != nil {
				return err
			}
		}
		log.Printf("D! Successfully connected to output: %s\n", o.Name)
	}
	return nil
}
func ( a * Agent ) Connect ( ) error { for _ , o := range a . Config . Outputs { switch ot := o . Output . ( type ) { case telegraf . ServiceOutput : if err := ot . Start ( ) ; err != nil { log . Printf ( " \n \n " , o . Name , err . Error ( ) ) return err } } log . Printf ( " \n " , o . Name ) err := o . Output . Connect ( ) if err != nil { log . Printf ( " " + " \n " , o . Name , err ) time . Sleep ( 15 * time . Second ) err = o . Output . Connect ( ) if err != nil { return err } } log . Printf ( " \n " , o . Name ) } return nil }
Connect connects to all configured outputs
Connect connects to all configured outputs