func (a *Agent) Test() error {
	shutdown := make(chan struct{})
	defer close(shutdown)
	metricC := make(chan telegraf.Metric)

	// dummy receiver for the point channel
	go func() {
		for {
			select {
			case <-metricC:
				// do nothing
			case <-shutdown:
				return
			}
		}
	}()

	for _, input := range a.Config.Inputs {
		if _, ok := input.Input.(telegraf.ServiceInput); ok {
			fmt.Printf("\nWARNING: skipping plugin [[%s]]: service inputs not supported in --test mode\n",
				input.Name())
			continue
		}

		acc := NewAccumulator(input, metricC)
		acc.SetPrecision(a.Config.Agent.Precision.Duration,
			a.Config.Agent.Interval.Duration)
		input.SetTrace(true)
		input.SetDefaultTags(a.Config.Tags)

		fmt.Printf("* Plugin: %s, Collection 1\n", input.Name())
		if input.Config.Interval != 0 {
			fmt.Printf("* Internal: %s\n", input.Config.Interval)
		}

		if err := input.Input.Gather(acc); err != nil {
			return err
		}

		// Special instructions for some inputs. cpu, for example, needs to be
		// run twice in order to return cpu usage percentages.
		switch input.Name() {
		case "inputs.cpu", "inputs.mongodb", "inputs.procstat":
			time.Sleep(500 * time.Millisecond)
			fmt.Printf("* Plugin: %s, Collection 2\n", input.Name())
			if err := input.Input.Gather(acc); err != nil {
				return err
			}
		}

	}
	return nil
}
// Test verifies that we can 'Gather' from all inputs with their configured
// Config struct
Test verifies that we can 'Gather' from all inputs with their configured
Config struct
// Test verifies that we can ' Gather ' from all inputs with their configured // Config struct
func (a *Agent) Test() error {
	shutdown := make(chan struct{})
	defer close(shutdown)
	metricC := make(chan telegraf.Metric)
	go func() {
		for {
			select {
			case <-metricC:
			case <-shutdown:
				return
			}
		}
	}()
	for _, input := range a.Config.Inputs {
		if _, ok := input.Input.(telegraf.ServiceInput); ok {
			fmt.Printf("\nWARNING: skipping plugin [[%s]]: service inputs not supported in --test mode\n",
				input.Name())
			continue
		}
		acc := NewAccumulator(input, metricC)
		acc.SetPrecision(a.Config.Agent.Precision.Duration,
			a.Config.Agent.Interval.Duration)
		input.SetTrace(true)
		input.SetDefaultTags(a.Config.Tags)
		fmt.Printf("* Plugin: %s, Collection 1\n", input.Name())
		if input.Config.Interval != 0 {
			fmt.Printf("* Internal: %s\n", input.Config.Interval)
		}
		if err := input.Input.Gather(acc); err != nil {
			return err
		}
		switch input.Name() {
		case "inputs.cpu", "inputs.mongodb", "inputs.procstat":
			time.Sleep(500 * time.Millisecond)
			fmt.Printf("* Plugin: %s, Collection 2\n", input.Name())
			if err := input.Input.Gather(acc); err != nil {
				return err
			}
		}
	}
	return nil
}
func ( a * Agent ) Test ( ) error { shutdown := make ( chan struct { } ) defer close ( shutdown ) metricC := make ( chan telegraf . Metric ) go func ( ) { for { select { case <- metricC : case <- shutdown : return } } } ( ) for _ , input := range a . Config . Inputs { if _ , ok := input . Input . ( telegraf . ServiceInput ) ; ok { fmt . Printf ( " \n \n " , input . Name ( ) ) continue } acc := NewAccumulator ( input , metricC ) acc . SetPrecision ( a . Config . Agent . Precision . Duration , a . Config . Agent . Interval . Duration ) input . SetTrace ( true ) input . SetDefaultTags ( a . Config . Tags ) fmt . Printf ( " \n " , input . Name ( ) ) if input . Config . Interval != 0 { fmt . Printf ( " \n " , input . Config . Interval ) } if err := input . Input . Gather ( acc ) ; err != nil { return err } switch input . Name ( ) { case " " , " " , " " : time . Sleep ( 500 * time . Millisecond ) fmt . Printf ( " \n " , input . Name ( ) ) if err := input . Input . Gather ( acc ) ; err != nil { return err } } } return nil }
Test verifies that we can 'Gather' from all inputs with their configured
Config struct
Test verifies that we can ' Gather ' from all inputs with their configured Config struct
// dummy receiver for the point channel // do nothing // Special instructions for some inputs. cpu, for example, needs to be // run twice in order to return cpu usage percentages.