Documentation ¶
Index ¶
- Constants
- Variables
- func AlignDuration(tm time.Time, interval time.Duration) time.Duration
- func AlignTime(tm time.Time, interval time.Duration) time.Time
- func AuthHandler(username, password, realm string, onError BasicAuthErrorFunc) func(h http.Handler) http.Handler
- func CloseIdleConnections(c *http.Client)
- func CombinedOutputTimeout(c *exec.Cmd, timeout time.Duration) ([]byte, error)
- func CompressWithGzip(data io.Reader) (io.ReadCloser, error)
- func ExitStatus(err error) (int, bool)
- func IPRangeHandler(network []*net.IPNet, onError ErrorFunc) func(h http.Handler) http.Handler
- func ParseTimestamp(format string, timestamp interface{}, location string) (time.Time, error)
- func ProductToken() string
- func RandomDuration(max time.Duration) time.Duration
- func RandomSleep(max time.Duration, shutdown chan struct{})
- func RandomString(n int) string
- func ReadLines(filename string) ([]string, error)
- func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error)
- func RunTimeout(c *exec.Cmd, timeout time.Duration) error
- func SetVersion(v string) error
- func SleepContext(ctx context.Context, duration time.Duration) error
- func SnakeCase(in string) string
- func Version() string
- func WaitTimeout(c *exec.Cmd, timeout time.Duration) error
- type BasicAuthErrorFunc
- type ContentDecoder
- type ContentEncoder
- type Duration
- type ErrorFunc
- type GzipDecoder
- type GzipEncoder
- type IdentityDecoder
- type IdentityEncoder
- type Number
- type ReadWaitCloser
- type Size
Constants ¶
const KillGrace = 5 * time.Second
KillGrace is the amount of time we allow a process to shutdown before sending a SIGKILL.
const Usage = `` /* 2757-byte string literal not displayed */
Variables ¶
Functions ¶
func AlignDuration ¶ added in v1.14.0
AlignDuration returns the duration until next aligned interval. If the current time is aligned a 0 duration is returned.
func AlignTime ¶ added in v1.14.0
AlignTime returns the time of the next aligned interval. If the current time is aligned the current time is returned.
func AuthHandler ¶ added in v1.14.0
func AuthHandler(username, password, realm string, onError BasicAuthErrorFunc) func(h http.Handler) http.Handler
AuthHandler returns a http handler that requires HTTP basic auth credentials to match the given username and password.
func CloseIdleConnections ¶ added in v1.14.0
func CombinedOutputTimeout ¶ added in v1.14.0
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 CompressWithGzip ¶ added in v1.14.0
func CompressWithGzip(data io.Reader) (io.ReadCloser, error)
CompressWithGzip takes an io.Reader as input and pipes it through a gzip.Writer returning an io.Reader containing the gzipped data. An error is returned if passing data to the gzip.Writer fails
func ExitStatus ¶ added in v1.14.0
Exit status takes the error from exec.Command and returns the exit status and true if error is not exit status, will return 0 and false
func IPRangeHandler ¶ added in v1.14.0
IPRangeHandler returns a http handler that requires the remote address to be in the specified network.
func ParseTimestamp ¶ added in v1.14.0
ParseTimestamp parses a Time according to the standard Telegraf options. These are generally displayed in the toml similar to:
json_time_key= "timestamp" json_time_format = "2006-01-02T15:04:05Z07:00" json_timezone = "America/Los_Angeles"
The format can be one of "unix", "unix_ms", "unix_us", "unix_ns", or a Go time layout suitable for time.Parse.
When using the "unix" format, a optional fractional component is allowed. Specific unix time precisions cannot have a fractional component.
Unix times may be an int64, float64, or string. When using a Go format string the timestamp must be a string.
The location is a location string suitable for time.LoadLocation. Unix times do not use the location string, a unix time is always return in the UTC location.
func ProductToken ¶ added in v1.14.0
func ProductToken() string
ProductToken returns a tag for Telegraf that can be used in user agents.
func RandomDuration ¶ added in v1.14.0
RandomDuration returns a random duration between 0 and max.
func RandomSleep ¶ added in v1.14.0
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 v1.14.0
RandomString returns a random string of alpha-numeric characters
func ReadLines ¶
ReadLines reads contents from a file and splits them by new lines. A convenience wrapper to ReadLinesOffsetN(filename, 0, -1).
func ReadLinesOffsetN ¶
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 v1.14.0
RunTimeout runs the given command with the given timeout. If the command times out, it attempts to kill the process.
func SetVersion ¶ added in v1.14.0
SetVersion sets the telegraf agent version
func SleepContext ¶ added in v1.14.0
SleepContext sleeps until the context is closed or the duration is reached.
Types ¶
type BasicAuthErrorFunc ¶ added in v1.14.0
type BasicAuthErrorFunc func(rw http.ResponseWriter)
type ContentDecoder ¶ added in v1.14.0
ContentDecoder removes a wrapper encoding from byte buffers.
func NewContentDecoder ¶ added in v1.14.0
func NewContentDecoder(encoding string) (ContentDecoder, error)
NewContentDecoder returns a ContentDecoder for the encoding type.
type ContentEncoder ¶ added in v1.14.0
ContentEncoder applies a wrapper encoding to byte buffers.
func NewContentEncoder ¶ added in v1.14.0
func NewContentEncoder(encoding string) (ContentEncoder, error)
NewContentEncoder returns a ContentEncoder for the encoding type.
type Duration ¶
Duration just wraps time.Duration
func (*Duration) UnmarshalTOML ¶
UnmarshalTOML parses the duration from the TOML config file
type ErrorFunc ¶ added in v1.14.0
type ErrorFunc func(rw http.ResponseWriter, code int)
ErrorFunc is a callback for writing an error response.
type GzipDecoder ¶ added in v1.14.0
type GzipDecoder struct {
// contains filtered or unexported fields
}
GzipDecoder decompresses buffers with gzip compression.
func NewGzipDecoder ¶ added in v1.14.0
func NewGzipDecoder() (*GzipDecoder, error)
type GzipEncoder ¶ added in v1.14.0
type GzipEncoder struct {
// contains filtered or unexported fields
}
GzipEncoder compresses the buffer using gzip at the default level.
func NewGzipEncoder ¶ added in v1.14.0
func NewGzipEncoder() (*GzipEncoder, error)
type IdentityDecoder ¶ added in v1.14.0
type IdentityDecoder struct{}
IdentityDecoder is a null decoder that returns the input.
func NewIdentityDecoder ¶ added in v1.14.0
func NewIdentityDecoder() *IdentityDecoder
type IdentityEncoder ¶ added in v1.14.0
type IdentityEncoder struct{}
IdentityEncoder is a null encoder that applies no transformation.
func NewIdentityEncoder ¶ added in v1.14.0
func NewIdentityEncoder() *IdentityEncoder
type Number ¶ added in v1.14.0
type Number struct {
Value float64
}
func (*Number) UnmarshalTOML ¶ added in v1.14.0
type ReadWaitCloser ¶ added in v1.14.0
type ReadWaitCloser struct {
// contains filtered or unexported fields
}
func (*ReadWaitCloser) Close ¶ added in v1.14.0
func (r *ReadWaitCloser) Close() error
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package choice provides basic functions for working with plugin options that must be one of several values.
|
Package choice provides basic functions for working with plugin options that must be one of several values. |