Back to godoc.org
github.com/otoolep/syslog-gollector/input

package input

v0.0.0 (1665615)
Latest Go to latest
Published: Jun 12, 2018 | License: MIT | Module: github.com/otoolep/syslog-gollector

Index

Constants

const (
	SYSLOG_DELIMITER = `<[0-9]{1,3}>[0-9]\s`
)

type Delimiter

type Delimiter struct {
	// contains filtered or unexported fields
}

A Delimiter detects when Syslog lines start.

func NewDelimiter

func NewDelimiter(maxSize int) *Delimiter

NewDelimiter returns an initialized Delimiter.

func (*Delimiter) Push

func (d *Delimiter) Push(b byte) (string, bool)

Push a byte into the Delimiter. If the byte results in a a new Syslog message, it'll be flagged via the bool.

func (*Delimiter) Stream

func (d *Delimiter) Stream(reader Reader) chan string

Stream returns a channel, on which the delimited Syslog messages are emitted.

func (*Delimiter) Vestige

func (d *Delimiter) Vestige() (string, bool)

Vestige returns the bytes which have been pushed to Delimiter, since the last Syslog message was returned, but only if the buffer appears to be a valid syslog message.

type ParsedMessage

type ParsedMessage struct {
	Priority  int    `json:"priority"`
	Version   int    `json:"version"`
	Timestamp string `json:"timestamp"`
	Host      string `json:"host"`
	App       string `json:"app"`
	Pid       int    `json:"pid"`
	MsgId     string `json:"msgid"`
	Message   string `json:"message"`
}

ParsedMessage represents a fully parsed Syslog message.

type Reader

type Reader interface {
	ReadByte() (byte, error)
}

Reader is the interface objects passed to the Delimiter must support.

type Rfc5424Parser

type Rfc5424Parser struct {
	// contains filtered or unexported fields
}

A Rfc5424Parser parses Syslog messages.

func NewRfc5424Parser

func NewRfc5424Parser() *Rfc5424Parser

NewRfc5424Parser Returns an initialized Rfc5424Parser.

func (*Rfc5424Parser) Parse

func (p *Rfc5424Parser) Parse(raw string) *ParsedMessage

Parse takes a raw message and returns a parsed message. If no match, nil is returned.

func (*Rfc5424Parser) Statistics

func (p *Rfc5424Parser) Statistics() (metrics.Registry, error)

Statistics returns an object storing statistics, which supports JSON marshalling.

func (*Rfc5424Parser) StreamingParse

func (p *Rfc5424Parser) StreamingParse(in chan string) (chan string, error)

StreamingParse emits parsed Syslog messages on the returned channel. If there are any parsing errors, the message is dropped.

type TcpServer

type TcpServer struct {
	// contains filtered or unexported fields
}

A TcpServer binds to the supplied interface and receives Syslog messages.

func NewTcpServer

func NewTcpServer(iface string) *TcpServer

NewTcpServer returns a TCP server.

func (*TcpServer) Start

func (s *TcpServer) Start(f func() chan<- string) error

Start instructs the TcpServer to bind to the interface and accept connections.

func (*TcpServer) Statistics

func (s *TcpServer) Statistics() (metrics.Registry, error)

Statistics returns an object storing statistics, which supports JSON marshalling.

type UdpServer

type UdpServer struct {
	// contains filtered or unexported fields
}

A UdpServer listens to the supplied interface and receives Syslog messages.

func NewUdpServer

func NewUdpServer(iface string) *UdpServer

NewUdpServer returns a UDP server.

func (*UdpServer) Start

func (s *UdpServer) Start(f func() chan<- string) error

Start instructs the UdpServer to start reading packets from the interface.

func (*UdpServer) Statistics

func (s *UdpServer) Statistics() (metrics.Registry, error)

Statistics returns an object storing statistics, which supports JSON marshalling.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier