agent

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOpts = ConnectionOpts{
	Endpoint:     "localhost:8080",
	CertPath:     ".certs/procjonagent.pem",
	KeyCertPath:  ".certs/procjonagent.key",
	RootCertPath: ".certs/ca.pem",
}

Functions

func NewConnection

func NewConnection(opts *ConnectionOpts) (*grpc.ClientConn, error)

NewConnection initializes connection to given endpoint. Certificates in ConnectionOpts must be provided. Connection must be closed. This is done in (*Service) Run function.

Types

type ConnectionOpts

type ConnectionOpts struct {
	Endpoint     string
	RootCertPath string
	CertPath     string
	KeyCertPath  string
}

type Elasticsearch

type Elasticsearch struct {
	Host   string
	Client httpClient
}

Elasticsearch monitors Elsaticsearch cluster. It consumes cluster health API: https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html. When error eccurs using API, status "unknown" is returned.

func (*Elasticsearch) GetCurrentStatus

func (e *Elasticsearch) GetCurrentStatus() uint32

GetCurrentStatus fetches Elasticsearch /_cluster/health APT to get status.

func (*Elasticsearch) GetStatuses

func (e *Elasticsearch) GetStatuses() []string

GetStatuses just returns al posiible statuses for Elasticsearch.

type Ping

type Ping struct {
}

Ping is simplest agenter. It can be used to monitor host. When host loses connection with procjon, procjon will send availability update to Slack.

func (*Ping) GetCurrentStatus

func (p *Ping) GetCurrentStatus() uint32

GetCurrentStatus returns always 0.

func (*Ping) GetStatuses

func (p *Ping) GetStatuses() []string

GetStatuses return only "ok" status.

type Service

type Service struct {
	Indentifier     string
	TimeoutSec      uint32
	UpdatePeriodSec uint32
}

func (*Service) Run

func (a *Service) Run(servicer Servicer, conn *grpc.ClientConn) error

Run registers service in running procjon server and periodically send statusCode to procjon server. Provide as argument any agent that implements Servicer interface.

type Servicer

type Servicer interface {
	GetCurrentStatus() uint32
	GetStatuses() []string
}

Servicer is implemented by all of procjonagents.

type SystemdUnit

type SystemdUnit struct {
	Name       string
	Connection listUnits
}

SystemdUnit monitors any systemd unit. Please refer to https://www.freedesktop.org/software/systemd/man/org.freedesktop.systemd1.html#Properties1 for list of possible unit statuses.

func (*SystemdUnit) GetCurrentStatus

func (m *SystemdUnit) GetCurrentStatus() uint32

GetCurrentStatus of SystemdUnit.Name from dbus.

func (*SystemdUnit) GetStatuses

func (m *SystemdUnit) GetStatuses() []string

GetStatuses returns possible statuses defined for SystemdUnit.

Jump to

Keyboard shortcuts

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