net_response

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 12 Imported by: 17

README

Network Response Input Plugin

The input plugin test UDP/TCP connections response time and can optional verify text in the response.

Global configuration options

In addition to the plugin-specific configuration settings, plugins support additional global and plugin configuration settings. These settings are used to modify metrics, tags, and field or create aliases and configure ordering, etc. See the CONFIGURATION.md for more details.

Configuration

# Collect response time of a TCP or UDP connection
[[inputs.net_response]]
  ## Protocol, must be "tcp" or "udp"
  ## NOTE: because the "udp" protocol does not respond to requests, it requires
  ## a send/expect string pair (see below).
  protocol = "tcp"
  ## Server address (default localhost)
  address = "localhost:80"

  ## Set timeout
  # timeout = "1s"

  ## Set read timeout (only used if expecting a response)
  # read_timeout = "1s"

  ## The following options are required for UDP checks. For TCP, they are
  ## optional. The plugin will send the given string to the server and then
  ## expect to receive the given 'expect' string back.
  ## string sent to the server
  # send = "ssh"
  ## expected string in answer
  # expect = "ssh"

  ## Uncomment to remove deprecated fields; recommended for new deploys
  # fielddrop = ["result_type", "string_found"]

Metrics

  • net_response
    • tags:
      • server
      • port
      • protocol
      • result
    • fields:
      • response_time (float, seconds)
      • result_code (int, success = 0, timeout = 1, connection_failed = 2, read_failed = 3, string_mismatch = 4)
      • result_type (string) DEPRECATED in 1.7; use result tag
      • string_found (boolean) DEPRECATED in 1.4; use result tag

Example Output

net_response,port=8086,protocol=tcp,result=success,server=localhost response_time=0.000092948,result_code=0i,result_type="success" 1525820185000000000
net_response,port=8080,protocol=tcp,result=connection_failed,server=localhost result_code=2i,result_type="connection_failed" 1525820088000000000
net_response,port=8080,protocol=udp,result=read_failed,server=localhost result_code=3i,result_type="read_failed",string_found=false 1525820088000000000

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NetResponse

type NetResponse struct {
	Address     string
	Timeout     config.Duration
	ReadTimeout config.Duration
	Send        string
	Expect      string
	Protocol    string
}

NetResponse struct

func (*NetResponse) Gather

func (n *NetResponse) Gather(acc telegraf.Accumulator) error

Gather is called by telegraf when the plugin is executed on its interval. It will call either UDPGather or TCPGather based on the configuration and also fill an Accumulator that is supplied.

func (*NetResponse) Init added in v1.25.3

func (n *NetResponse) Init() error

Init performs one time setup of the plugin and returns an error if the configuration is invalid.

func (*NetResponse) SampleConfig

func (*NetResponse) SampleConfig() string

func (*NetResponse) TCPGather

func (n *NetResponse) TCPGather() (map[string]string, map[string]interface{}, error)

TCPGather will execute if there are TCP tests defined in the configuration. It will return a map[string]interface{} for fields and a map[string]string for tags

func (*NetResponse) UDPGather

func (n *NetResponse) UDPGather() (map[string]string, map[string]interface{}, error)

UDPGather will execute if there are UDP tests defined in the configuration. It will return a map[string]interface{} for fields and a map[string]string for tags

type ResultType

type ResultType uint64
const (
	Success          ResultType = 0
	Timeout          ResultType = 1
	ConnectionFailed ResultType = 2
	ReadFailed       ResultType = 3
	StringMismatch   ResultType = 4
)

Jump to

Keyboard shortcuts

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