go-livestatus: github.com/vbatoufflet/go-livestatus Index | Files | Directories

package livestatus

import "github.com/vbatoufflet/go-livestatus"

Index

Package Files

client.go command.go error.go query.go record.go request.go response.go

Variables

var (
    // ErrInvalidQuery represents an invalid query error.
    ErrInvalidQuery = errors.New("invalid query")
    // ErrInvalidType represents an invalid type error.
    ErrInvalidType = errors.New("invalid type")
    // ErrUnknownColumn represents an unknown column error.
    ErrUnknownColumn = errors.New("unknown column")
)

type Client Uses

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

Client represents a Livestatus client instance.

func NewClient Uses

func NewClient(network, address string) *Client

NewClient creates a new Livestatus client instance.

func NewClientWithDialer Uses

func NewClientWithDialer(network, address string, dialer *net.Dialer) *Client

NewClientWithDialer creates a new Livestatus client instance using a provided network dialer.

func (*Client) Close Uses

func (c *Client) Close()

Close closes any remaining connection.

func (*Client) Exec Uses

func (c *Client) Exec(r Request) (*Response, error)

Exec executes a given Livestatus query.

type Command Uses

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

Command represents a Livestatus command instance.

func NewCommand Uses

func NewCommand(name string, args ...string) *Command

NewCommand creates a new Livestatus command instance.

func (*Command) Arg Uses

func (c *Command) Arg(v interface{}) *Command

Arg appends a new argument to the command.

func (Command) String Uses

func (c Command) String() string

String returns a string representation of the Livestatus command.

func (*Command) WriteTimeout Uses

func (c *Command) WriteTimeout(timeout time.Duration) *Command

WriteTimeout sets the connection timeout for write operations. A value of 0 disables the timeout.

type ParseError Uses

type ParseError struct {
    Message    string
    FailedData []byte
    Buffer     []byte
}

ParseError embeded an error with some states to help debugging

func (ParseError) Error Uses

func (pe ParseError) Error() string

type Query Uses

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

Query represents a Livestatus query instance.

func NewQuery Uses

func NewQuery(table string) *Query

NewQuery creates a new Livestatus query instance.

func (*Query) And Uses

func (q *Query) And(n int) *Query

And combines the n last filters into a new filter using a `And` operation.

func (*Query) Columns Uses

func (q *Query) Columns(names ...string) *Query

Columns selects which columns to retrieve.

func (*Query) Filter Uses

func (q *Query) Filter(rule string) *Query

Filter appends a new filter to the query.

func (*Query) KeepAlive Uses

func (q *Query) KeepAlive() *Query

KeepAlive keeps the connection open to reuse for additional requests.

func (*Query) Limit Uses

func (q *Query) Limit(n int) *Query

Limit sets the limit of datasets to retrieve.

func (*Query) Negate Uses

func (q *Query) Negate() *Query

Negate negates the most recent filter.

func (*Query) Or Uses

func (q *Query) Or(n int) *Query

Or combines the n last filters into a new filter using a `Or` operation.

func (*Query) ReadTimeout Uses

func (q *Query) ReadTimeout(timeout time.Duration) *Query

ReadTimeout sets the connection timeout for read operations. Be careful when using a read timeout in conjunction with wait conditions. A value of 0 disables the timeout.

func (Query) String Uses

func (q Query) String() string

String returns a string representation of the Livestatus query.

func (*Query) WaitCondition Uses

func (q *Query) WaitCondition(rule string) *Query

WaitCondition appends a new wait condition to the query.

func (*Query) WaitConditionAnd Uses

func (q *Query) WaitConditionAnd(n int) *Query

WaitConditionAnd combines the n last wait conditions into a new wait condition using a `And` operation.

func (*Query) WaitConditionNegate Uses

func (q *Query) WaitConditionNegate() *Query

WaitConditionNegate negates the most recent wait condition.

func (*Query) WaitConditionOr Uses

func (q *Query) WaitConditionOr(n int) *Query

WaitConditionOr combines the n last wait conditions into a new wait condition using a `Or` operation.

func (*Query) WaitObject Uses

func (q *Query) WaitObject(name string) *Query

WaitObject specifies an object from the table to wait on.

For `hosts`, `hostgroups`, `servicegroups`, `contacts` and `contactgroups` tables this is simply the name of the object. For the `services` table it is the `hostname` and the service `description` separated by a space.

func (*Query) WaitTimeout Uses

func (q *Query) WaitTimeout(d time.Duration) *Query

WaitTimeout sets the upper limit on the time to wait before executing the query.

func (*Query) WaitTrigger Uses

func (q *Query) WaitTrigger(event string) *Query

WaitTrigger appends a new wait trigger to the query, waiting for a specific event broker message to recheck condition.

func (*Query) WriteTimeout Uses

func (q *Query) WriteTimeout(timeout time.Duration) *Query

WriteTimeout sets the connection timeout for write operations. A value of 0 disables the timeout.

type Record Uses

type Record map[string]interface{}

Record represents a Livestatus response entry.

func (Record) Columns Uses

func (r Record) Columns() []string

Columns returns the list of the record columns.

func (Record) Get Uses

func (r Record) Get(column string) (interface{}, error)

Get returns an interface value for a specific column.

func (Record) GetBool Uses

func (r Record) GetBool(column string) (bool, error)

GetBool returns a boolean value for a specific column.

func (Record) GetFloat Uses

func (r Record) GetFloat(column string) (float64, error)

GetFloat returns a float value for a specific column.

func (Record) GetInt Uses

func (r Record) GetInt(column string) (int64, error)

GetInt returns an integer value for a specific column.

func (Record) GetSlice Uses

func (r Record) GetSlice(column string) ([]interface{}, error)

GetSlice returns a slice of interface value for a specific column.

func (Record) GetString Uses

func (r Record) GetString(column string) (string, error)

GetString returns a string value for a specific column.

func (Record) GetTime Uses

func (r Record) GetTime(column string) (time.Time, error)

GetTime returns a time struct value for a specific column.

func (Record) Len Uses

func (r Record) Len() int

Len returns the number of columns present in the record.

type Request Uses

type Request interface {
    String() string
    // contains filtered or unexported methods
}

Request represents Livestatus request interface.

type Response Uses

type Response struct {
    Status  int
    Message string
    Records []Record
}

Response represents a Livestatus query response.

func (Response) Len Uses

func (r Response) Len() int

Len returns the number of records present in the response.

Directories

PathSynopsis
nagios

Package livestatus imports 11 packages (graph) and is imported by 3 packages. Updated 2019-04-07. Refresh now. Tools for package owners.