internal

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2016 License: MIT Imports: 16 Imported by: 0

README

* package internal

#+BEGIN_SRC sh :results raw
fst=../vendor/github.com/influxdata/telegraf/internal
snd=.

(diff --unified --ignore-all-space --recursive \
 "$fst"/../agent \
 "$snd"/agent;
 diff --unified --ignore-all-space --recursive \
 "$fst" \
 "$snd") |
awk '{ if ($1 == "---" || $1 == "+++") { $_ = $1 FS $2; }; print }'
#+END_SRC

#+BEGIN_SRC diff
#+RESULTS:
diff --unified --ignore-all-space --recursive ../vendor/github.com/influxdata/telegraf/internal/../agent/accumulator.go ./agent/accumulator.go
--- ../vendor/github.com/influxdata/telegraf/internal/../agent/accumulator.go
+++ ./agent/accumulator.go
@@ -8,7 +8,8 @@
 	"time"
 
 	"github.com/influxdata/telegraf"
-	"github.com/influxdata/telegraf/internal/models"
+
+	"github.com/ostrost/ostent/internal/models"
 )
 
 func NewAccumulator(
Only in ../vendor/github.com/influxdata/telegraf/internal/../agent: accumulator_test.go
diff --unified --ignore-all-space --recursive ../vendor/github.com/influxdata/telegraf/internal/../agent/agent.go ./agent/agent.go
--- ../vendor/github.com/influxdata/telegraf/internal/../agent/agent.go
+++ ./agent/agent.go
@@ -9,9 +9,10 @@
 	"time"
 
 	"github.com/influxdata/telegraf"
-	"github.com/influxdata/telegraf/internal"
-	"github.com/influxdata/telegraf/internal/config"
-	"github.com/influxdata/telegraf/internal/models"
+
+	"github.com/ostrost/ostent/internal"
+	"github.com/ostrost/ostent/internal/config"
+	"github.com/ostrost/ostent/internal/models"
 )
 
 // Agent runs telegraf and collects data based on the given config
@@ -268,7 +269,6 @@
 			a.flush()
 			return nil
 		case <-ticker.C:
-			internal.RandomSleep(a.Config.Agent.FlushJitter.Duration, shutdown)
 			a.flush()
 		case m := <-metricC:
 			for i, o := range a.Config.Outputs {
Only in ../vendor/github.com/influxdata/telegraf/internal/../agent: agent_test.go
Only in .: README.org
Only in .: agent
Only in ../vendor/github.com/influxdata/telegraf/internal/buffer: buffer_test.go
Only in ../vendor/github.com/influxdata/telegraf/internal/config: aws
diff --unified --ignore-all-space --recursive ../vendor/github.com/influxdata/telegraf/internal/config/config.go ./config/config.go
--- ../vendor/github.com/influxdata/telegraf/internal/config/config.go
+++ ./config/config.go
@@ -15,18 +15,22 @@
 	"time"
 
 	"github.com/influxdata/telegraf"
-	"github.com/influxdata/telegraf/internal"
-	"github.com/influxdata/telegraf/internal/models"
 	"github.com/influxdata/telegraf/plugins/inputs"
 	"github.com/influxdata/telegraf/plugins/outputs"
 	"github.com/influxdata/telegraf/plugins/parsers"
 	"github.com/influxdata/telegraf/plugins/serializers"
 
-	"github.com/influxdata/config"
 	"github.com/influxdata/toml"
 	"github.com/influxdata/toml/ast"
+
+	"github.com/ostrost/ostent/internal"
+	"github.com/ostrost/ostent/internal/models"
 )
 
+var config = struct {
+	UnmarshalTable func(*ast.Table, interface{}) error
+}{UnmarshalTable: toml.UnmarshalTable}
+
 var (
 	// Default input plugins
 	inputDefaults = []string{"cpu", "mem", "swap", "system", "kernel",
@@ -71,6 +75,11 @@
 }
 
 type AgentConfig struct {
+	// Bind is server bind address
+	Bind string
+	// BindPort is server bind port
+	BindPort int
+
 	// Interval at which to gather information
 	Interval internal.Duration
 
@@ -461,6 +470,12 @@
 		return fmt.Errorf("Error parsing %s, %s", path, err)
 	}
 
+	return c.LoadTable(path, tbl)
+}
+
+func (c *Config) LoadTable(path string, tbl *ast.Table) error {
+	var err error
+
 	// Parse tags tables first:
 	for _, tableName := range []string{"tags", "global_tags"} {
 		if val, ok := tbl.Fields[tableName]; ok {
@@ -558,6 +573,10 @@
 	if err != nil {
 		return nil, err
 	}
+	return ParseContents(contents)
+}
+
+func ParseContents(contents []byte) (*ast.Table, error) {
 	// ugh windows why
 	contents = trimBOM(contents)
 
@@ -590,6 +609,9 @@
 		if err != nil {
 			return err
 		}
+		if serializer == nil {
+			return fmt.Errorf("Serializer is nil")
+		}
 		t.SetSerializer(serializer)
 	}
 
Only in ../vendor/github.com/influxdata/telegraf/internal/config: config_test.go
Only in ../vendor/github.com/influxdata/telegraf/internal/config: testdata
Only in ../vendor/github.com/influxdata/telegraf/internal: errchan
Only in ../vendor/github.com/influxdata/telegraf/internal: globpath
diff --unified --ignore-all-space --recursive ../vendor/github.com/influxdata/telegraf/internal/internal.go ./internal.go
--- ../vendor/github.com/influxdata/telegraf/internal/internal.go
+++ ./internal.go
@@ -32,6 +32,11 @@
 	Duration time.Duration
 }
 
+// MarshalTOML is for toml.Marshaler interface.
+func (d Duration) MarshalTOML() ([]byte, error) {
+	return []byte(fmt.Sprintf("%q", d.Duration)), nil
+}
+
 // UnmarshalTOML parses the duration from the TOML config file
 func (d *Duration) UnmarshalTOML(b []byte) error {
 	var err error
Only in ../vendor/github.com/influxdata/telegraf/internal: internal_test.go
Only in ../vendor/github.com/influxdata/telegraf/internal: limiter
Only in ../vendor/github.com/influxdata/telegraf/internal/models: filter_test.go
diff --unified --ignore-all-space --recursive ../vendor/github.com/influxdata/telegraf/internal/models/running_output.go ./models/running_output.go
--- ../vendor/github.com/influxdata/telegraf/internal/models/running_output.go
+++ ./models/running_output.go
@@ -5,7 +5,8 @@
 	"time"
 
 	"github.com/influxdata/telegraf"
-	"github.com/influxdata/telegraf/internal/buffer"
+
+	"github.com/ostrost/ostent/internal/buffer"
 )
 
 const (
Only in ../vendor/github.com/influxdata/telegraf/internal/models: running_output_test.go
Only in .: plugins
#+END_SRC

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeoutErr = errors.New("Command timed out.")

	NotImplementedError = errors.New("not implemented yet")
)

Functions

func CombinedOutputTimeout added in v0.7.0

func CombinedOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error)

CombinedOutputTimeout runs the given command with the given timeout and returns the combined output of stdout and stderr. If the command times out, it attempts to kill the process.

func GetTLSConfig added in v0.7.0

func GetTLSConfig(
	SSLCert, SSLKey, SSLCA string,
	InsecureSkipVerify bool,
) (*tls.Config, error)

GetTLSConfig gets a tls.Config object from the given certs, key, and CA files. you must give the full path to the files. If all files are blank and InsecureSkipVerify=false, returns a nil pointer.

func RandomSleep added in v0.7.0

func RandomSleep(max time.Duration, shutdown chan struct{})

RandomSleep will sleep for a random amount of time up to max. If the shutdown channel is closed, it will return before it has finished sleeping.

func RandomString added in v0.7.0

func RandomString(n int) string

RandomString returns a random string of alpha-numeric characters

func ReadLines added in v0.7.0

func ReadLines(filename string) ([]string, error)

ReadLines reads contents from a file and splits them by new lines. A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).

func ReadLinesOffsetN added in v0.7.0

func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error)

ReadLines reads contents from file and splits them by new line. The offset tells at which line number to start. The count determines the number of lines to read (starting from offset):

n >= 0: at most n lines
n < 0: whole file

func RunTimeout added in v0.7.0

func RunTimeout(c *exec.Cmd, timeout time.Duration) error

RunTimeout runs the given command with the given timeout. If the command times out, it attempts to kill the process.

func SnakeCase added in v0.7.0

func SnakeCase(in string) string

SnakeCase converts the given string to snake case following the Golang format: acronyms are converted to lower-case and preceded by an underscore.

func WaitTimeout added in v0.7.0

func WaitTimeout(c *exec.Cmd, timeout time.Duration) error

WaitTimeout waits for the given command to finish with a timeout. It assumes the command has already been started. If the command times out, it attempts to kill the process.

Types

type Duration

type Duration struct {
	Duration time.Duration
}

Duration just wraps time.Duration

func (Duration) MarshalTOML added in v0.7.0

func (d Duration) MarshalTOML() ([]byte, error)

MarshalTOML is for toml.Marshaler interface.

func (*Duration) UnmarshalTOML

func (d *Duration) UnmarshalTOML(b []byte) error

UnmarshalTOML parses the duration from the TOML config file

Directories

Path Synopsis
plugins

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL