wigo

package
v0.73.30 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: MIT Imports: 40 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ADDDIRECTORY    = 1
	REMOVEDIRECTORY = 2

	NEWPROBERESULT    = 3
	DELETEPROBERESULT = 4

	NEWREMOTERESULT = 5
	NEWCONNECTION   = 6

	SENDRESULTS      = 7
	SENDNOTIFICATION = 8
)
View Source
const (
	DEBUG     = 1
	NOTICE    = 2
	INFO      = 3
	ERROR     = 4
	WARNING   = 5
	CRITICAL  = 6
	EMERGENCY = 7
)

Log levels

Variables

View Source
var Version = "##VERSION##"

Functions

func CallbackHttp

func CallbackHttp(json string) (e error)

func Dump

func Dump(data interface{})

Misc

func HttpAuthorityAllowHandler

func HttpAuthorityAllowHandler(params martini.Params) (int, string)

func HttpAuthorityListHandler

func HttpAuthorityListHandler(params martini.Params) (int, string)

func HttpAuthorityRevokeHandler

func HttpAuthorityRevokeHandler(params martini.Params) (int, string)

func HttpGroupsHandler

func HttpGroupsHandler(params martini.Params) (int, string)

func HttpLogsHandler

func HttpLogsHandler(params martini.Params, r *http.Request) (int, string)

func HttpLogsIndexesHandler

func HttpLogsIndexesHandler(params martini.Params) (int, string)

func HttpRemotesHandler

func HttpRemotesHandler(params martini.Params) (int, string)

func HttpRemotesProbesHandler

func HttpRemotesProbesHandler(params martini.Params) (int, string)

func HttpRemotesProbesStatusHandler

func HttpRemotesProbesStatusHandler(params martini.Params) (int, string)

func HttpRemotesStatusHandler

func HttpRemotesStatusHandler(params martini.Params) (int, string)

func InitChannels

func InitChannels()

func InitWigo

func InitWigo() (err error)

func IsStringInArray

func IsStringInArray(str string, l []string) bool

func ListProbesDirectories

func ListProbesDirectories() ([]string, error)

List probes directories

func ListProbesInDirectory

func ListProbesInDirectory(directory string) (probesList *list.List, error error)

List probes in directory

func NewConcurrentMapProbes added in v0.73.21

func NewConcurrentMapProbes() *concurrentMapProbes

func NewConcurrentMapWigos added in v0.73.21

func NewConcurrentMapWigos() *concurrentMapWigos

func SendMail

func SendMail(summary string, message string)

func SendNotification

func SendNotification(notification INotification)

func StatusToString

func StatusToString(status int) string

func ToJson

func ToJson(data interface{}) string

Types

type AdvancedRemoteWigoConfig

type AdvancedRemoteWigoConfig struct {
	Hostname          string
	Port              int
	CheckRemotesDepth int
	CheckInterval     int
	SslEnabled        bool
	Login             string
	Password          string
}

type Authority

type Authority struct {
	Waiting map[string]string
	Allowed map[string]string
	Tokens  map[string]string
	// contains filtered or unexported fields
}

The Authority is responsible to handle the security of the push system. The server certificate is used to allow the clients to verify the server identity and the private key is used to sign the clients uuid to allow the server to verify the clients identities.

Allowed client are stored in an allowed list persisted on the file system, so one can easily revoke clients.

func NewAuthority

func NewAuthority(config *PushServerConfig) (this *Authority)

func (*Authority) AddClientToWaitingList

func (this *Authority) AddClientToWaitingList(uuid string, hostname string) (err error)

Add a client to the waiting list

func (*Authority) AllowClient

func (this *Authority) AllowClient(uuid string) (err error)

Add a client to the allowed list. The client have to be in the waiting list. // TODO remove this limitation

func (*Authority) GetServerCertificate

func (this *Authority) GetServerCertificate() []byte

Return the server certificate

func (*Authority) GetToken

func (this *Authority) GetToken(clientUuid string) (token string, err error)

Generate a token to use as a proof of identity for all subsequent requests

func (*Authority) GetUuidSignature

func (this *Authority) GetUuidSignature(uuid string, hostname string) (uuidSignature []byte, err error)

Sign a client's uuid with the server's private key

func (*Authority) IsAllowed

func (this *Authority) IsAllowed(uuid string) bool

Check is a given uuid is in the allowed list

func (*Authority) IsWaiting

func (this *Authority) IsWaiting(uuid string) bool

Check is a given uuid is in the waiting list

func (*Authority) LoadAllowedList

func (this *Authority) LoadAllowedList() (err error)

Load the allowed clients list from the file system The file format is one "uuid hostname" per line, every non matching line will be ignored

func (*Authority) RevokeClient

func (this *Authority) RevokeClient(uuid string) (err error)

Remove a client from the allowed list, revoke tokens if any and remove client data. TODO The dedup data in gopentsdb are leaked.

func (*Authority) RevokeToken

func (this *Authority) RevokeToken(uuid string, token string) (err error)

Revoke a token

func (*Authority) SaveAllowedList

func (this *Authority) SaveAllowedList() (err error)

Persist the allowed clients list on the file system The file format is one "uuid hostname" per line, every non matching line will be ignored

func (*Authority) VerifyToken

func (this *Authority) VerifyToken(uuid string, token string) (err error)

Verify the validity of a token

func (*Authority) VerifyUuidSignature

func (this *Authority) VerifyUuidSignature(uuid string, uuidSignature []byte) (err error)

Verify the validity of an uuid signature

type Chans

type Chans struct {
	ChanWatch     chan Event
	ChanChecks    chan Event
	ChanCallbacks chan INotification
	ChanSignals   chan os.Signal
}
var Channels *Chans

type Config

type Config struct {

	// General params
	Global *GeneralConfig

	// Http params
	Http *HttpConfig

	// PushServer params
	PushServer *PushServerConfig

	// PushClient params
	PushClient *PushClientConfig

	// Remmote wigos params
	RemoteWigos  *RemoteWigoConfig
	AdvancedList []AdvancedRemoteWigoConfig

	// Noticications
	Notifications *NotificationConfig

	// OpenTSDB params
	OpenTSDB *OpenTSDBConfig
}

func NewConfig

func NewConfig(configFile string) (this *Config)

type Event

type Event struct {
	Type  int
	Value interface{}
}

type GeneralConfig

type GeneralConfig struct {
	Hostname              string
	ListenAddress         string
	ProbesDirectory       string
	ProbesConfigDirectory string
	UuidFile              string
	LogFile               string
	Debug                 bool
	Trace                 bool
	ConfigFile            string
	Group                 string
	Database              string
	AliveTimeout          int
}

type HelloRequest

type HelloRequest struct {
	Hostname      string
	Uuid          string
	UuidSignature []byte
}

Hello request for the first request

func NewHelloRequest

func NewHelloRequest(uuidSignature []byte) (this *HelloRequest)

type Host

type Host struct {
	Name   string
	Group  string
	Status int
	Probes *concurrentMapProbes
	// contains filtered or unexported fields
}

func NewHost

func NewHost() (this *Host)

func (*Host) AddOrUpdateProbe

func (this *Host) AddOrUpdateProbe(probe *ProbeResult)

func (*Host) DeleteProbeByName

func (this *Host) DeleteProbeByName(probeName string)

func (*Host) GetErrorsProbesList

func (this *Host) GetErrorsProbesList() (list []string)

func (*Host) GetParentWigo

func (this *Host) GetParentWigo() *Wigo

func (*Host) GetSummary

func (this *Host) GetSummary() (hs *HostSummary)

func (*Host) RecomputeStatus

func (this *Host) RecomputeStatus()

func (*Host) SetParentWigo

func (this *Host) SetParentWigo(w *Wigo)

type HostSummary

type HostSummary struct {
	Name    string
	Message string
	Status  int
	IsAlive bool
	Probes  []map[string]interface{}
}

type HttpConfig

type HttpConfig struct {
	Enabled    bool
	Address    string
	Port       int
	SslEnabled bool
	SslCert    string
	SslKey     string
	Login      string
	Password   string
	Gzip       bool
}

type INotification

type INotification interface {
	ToJson() ([]byte, error)
	GetMessage() string
	GetSummary() string
}

type Log

type Log struct {
	Date      string
	Timestamp int64
	Level     uint8
	Message   string
	Host      string
	Probe     string
	Group     string
}

func NewLog

func NewLog(level uint8, message string) (this *Log)

func (*Log) Persist

func (this *Log) Persist()

Persist on disk

func (*Log) SetGroup

func (this *Log) SetGroup(group string)

func (*Log) SetHost

func (this *Log) SetHost(hostname string)

Setters

func (*Log) SetProbe

func (this *Log) SetProbe(probename string)

type Notification

type Notification struct {
	Type     string
	Hostname string
	Message  string
	Date     string
	Summary  string
}

func NewNotification

func NewNotification() (this *Notification)

Constructors

func NewNotificationFromMessage

func NewNotificationFromMessage(message string) (this *Notification)

func (*Notification) GetMessage

func (this *Notification) GetMessage() string

func (*Notification) GetSummary

func (this *Notification) GetSummary() (s string)

func (*Notification) ToJson

func (this *Notification) ToJson() (ba []byte, e error)

Getters

type NotificationConfig

type NotificationConfig struct {
	// Noticications
	MinLevelToSend int

	OnHostChange  bool
	OnProbeChange bool

	HttpEnabled int
	HttpUrl     string

	EmailEnabled     int
	EmailSmtpServer  string
	EmailRecipients  []string
	EmailFromName    string
	EmailFromAddress string
}

type NotificationProbe

type NotificationProbe struct {
	*Notification
	OldProbe          *ProbeResult
	NewProbe          *ProbeResult
	HostProbesInError []string
}

func NewNotificationProbe

func NewNotificationProbe(oldProbe *ProbeResult, newProbe *ProbeResult) (this *NotificationProbe)

func (*NotificationProbe) GetSummary

func (this *NotificationProbe) GetSummary() (s string)

func (*NotificationProbe) ToJson

func (this *NotificationProbe) ToJson() (ba []byte, e error)

type NotificationWigo

type NotificationWigo struct {
	*Notification
	OldWigo *Wigo
	NewWigo *Wigo
}

func (*NotificationWigo) GetSummary

func (this *NotificationWigo) GetSummary() (s string)

func (*NotificationWigo) ToJson

func (this *NotificationWigo) ToJson() (ba []byte, e error)

type OpenTSDBConfig

type OpenTSDBConfig struct {
	Enabled       bool
	Address       []string
	SslEnabled    bool
	MetricPrefix  string
	Deduplication int
	BufferSize    int
	Tags          map[string]string
}

type ProbeResult

type ProbeResult struct {
	Name      string
	Version   string
	Value     interface{}
	Message   string
	ProbeDate string
	Timestamp int64

	Metrics interface{}
	Detail  interface{}

	Status   int
	ExitCode int
	// contains filtered or unexported fields
}

func NewProbeResult

func NewProbeResult(name string, status int, exitCode int, message string, detail string) (this *ProbeResult)

func NewProbeResultFromJson

func NewProbeResultFromJson(name string, ba []byte) (this *ProbeResult)

func (*ProbeResult) GetHost

func (this *ProbeResult) GetHost() *Host

Getters

func (*ProbeResult) GraphMetrics

func (this *ProbeResult) GraphMetrics()

func (*ProbeResult) SetHost

func (this *ProbeResult) SetHost(h *Host)

Setters

func (*ProbeResult) Summary

func (this *ProbeResult) Summary() string

type PushClient

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

Push client connect to the push server to update client's data over RPCs. Data is transferred using binary gob serialisation over tcp connection. Secure TLS connection is available and highly recommended.

If an error occurs during the push process the connection should

func NewPushClient

func NewPushClient(config *PushClientConfig) (this *PushClient, err error)

func (*PushClient) CallWithTimeout

func (this *PushClient) CallWithTimeout(serviceMethod string, args interface{}, reply interface{}, timeout time.Duration) error

func (*PushClient) Close

func (this *PushClient) Close() (err error)

Disconnect the client

func (*PushClient) GetServerCertificate

func (this *PushClient) GetServerCertificate() (err error)

Download the server certificate from the server thus the client can ensure the server's identity. To avoid the small window of MITM vulnerability you might copy the certificate by yourself.

func (*PushClient) Goodbye

func (this *PushClient) Goodbye() (err error)

Disconnect the client gracefully

func (*PushClient) Hello

func (this *PushClient) Hello() (err error)

Hello is the first request of every connection. It sends the client's uuid and signature to the server as an identity proof. It returns a token that will be used to authenticate every subsequent requests at a lower cost.

func (*PushClient) SignUuid

func (this *PushClient) SignUuid() (err error)

Ask the server to sign the client's uuid, this way the server is able to verify the client identity. The uuid signature is persisted on the file system.

func (*PushClient) Update

func (this *PushClient) Update() (err error)

Send the local data to the server

type PushClientConfig

type PushClientConfig struct {
	Enabled      bool
	Address      string
	Port         int
	SslEnabled   bool
	SslCert      string
	UuidSig      string
	PushInterval int
}

type PushServer

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

Push server expose method to update client's data over RPCs. Data is transferred using binary gob serialisation over tcp connection. Secure TLS connection is available and highly recommended.

func NewPushServer

func NewPushServer(config *PushServerConfig) (this *PushServer)

func (*PushServer) GetServerCertificate

func (this *PushServer) GetServerCertificate(req HelloRequest, cert *[]byte) (err error)

Send the server CA certificate to the client so it can verify the identity of the server. To avoid the small window of MITM vulnerability you might copy the certificate by yourself.

func (*PushServer) GetUuidSignature

func (this *PushServer) GetUuidSignature(req HelloRequest, sig *[]byte) (err error)

Sign the client uuid with the server's private key. The client will have to provide this as a proof of his identity at every new connection.

func (*PushServer) Goodbye

func (this *PushServer) Goodbye(req Request, reply *bool) (err error)

Disconnect the client gracefully

func (*PushServer) Hello

func (this *PushServer) Hello(req HelloRequest, token *string) (err error)

Verify the validity of the client's uuid signature. This is done once for every connection then a token then a token is used.

func (*PushServer) Register

func (this *PushServer) Register(req HelloRequest, reply *bool) (err error)

Register a new client. It will first be added to a waiting list, then an admin action will be required to grant the client to the allowed list. You may accept new clients automatically with the AutoAcceptClient setting.

func (*PushServer) Update

func (this *PushServer) Update(req UpdateRequest, reply *bool) (err error)

Update a client's data

type PushServerConfig

type PushServerConfig struct {
	Enabled            bool
	Address            string
	Port               int
	SslEnabled         bool
	SslCert            string
	SslKey             string
	AllowedClientsFile string
	AutoAcceptClients  bool
	MaxWaitingClients  int
}

type Put

type Put struct {
	Value float64
	Tags  map[string]string
}

OpenTSDB

type RemoteWigoConfig

type RemoteWigoConfig struct {
	CheckInterval int

	SslEnabled bool
	Login      string
	Password   string

	List         []string
	AdvancedList []AdvancedRemoteWigoConfig
}

type Request

type Request struct {
	Uuid  string
	Token string
}

Base request for every subsequent requests

func NewRequest

func NewRequest(uuid string, token string) (this *Request)

type UpdateRequest

type UpdateRequest struct {
	*Request
	WigoJson     string
	WigoHostname string
}

Request the server to update the client's data

func NewUpdateRequest

func NewUpdateRequest(wigo *Wigo, token string) (this *UpdateRequest)

type Wigo

type Wigo struct {
	Uuid    string
	Version string
	IsAlive bool

	GlobalStatus  int
	GlobalMessage string

	LocalHost   *Host
	RemoteWigos *concurrentMapWigos

	Hostname string

	LastUpdate int64
	// contains filtered or unexported fields
}
var LocalWigo *Wigo

Static global object

func GetLocalWigo

func GetLocalWigo() *Wigo

func NewWigo

func NewWigo(config *Config) (this *Wigo, err error)

func NewWigoFromJson

func NewWigoFromJson(ba []byte, checkRemotesDepth int) (this *Wigo, e error)

func (*Wigo) AddLog

func (this *Wigo) AddLog(ressource interface{}, level uint8, message string) (err error)

Logs

func (*Wigo) AddOrUpdateRemoteWigo

func (this *Wigo) AddOrUpdateRemoteWigo(remoteWigo *Wigo)

func (*Wigo) CompareTwoWigosAndRaiseNotifications

func (this *Wigo) CompareTwoWigosAndRaiseNotifications(oldWigo *Wigo, newWigo *Wigo)

func (*Wigo) Deduplicate

func (this *Wigo) Deduplicate(remoteWigo *Wigo) (err error)

func (*Wigo) DisableProbe

func (this *Wigo) DisableProbe(probeName string)

func (*Wigo) Down

func (this *Wigo) Down()

Status setters

func (*Wigo) EraseRemoteWigos

func (this *Wigo) EraseRemoteWigos(depth int) *Wigo

func (*Wigo) FindRemoteWigoByHostname

func (this *Wigo) FindRemoteWigoByHostname(hostname string) *Wigo

func (*Wigo) FindRemoteWigoByUuid

func (this *Wigo) FindRemoteWigoByUuid(uuid string) (*Wigo, bool)

func (*Wigo) GenerateRemoteWigosSummary

func (this *Wigo) GenerateRemoteWigosSummary(level int, showOnlyErrors bool, version string) (summary string)

func (*Wigo) GenerateSummary

func (this *Wigo) GenerateSummary(showOnlyErrors bool) (summary string)

func (*Wigo) GetConfig

func (this *Wigo) GetConfig() *Config

func (*Wigo) GetDisabledProbes

func (this *Wigo) GetDisabledProbes() *list.List

Disabled probes

func (*Wigo) GetHostname

func (this *Wigo) GetHostname() string

func (*Wigo) GetLocalHost

func (this *Wigo) GetLocalHost() *Host

Getters

func (*Wigo) GetOpenTsdb

func (this *Wigo) GetOpenTsdb() *gopentsdb.OpenTsdb

func (*Wigo) GroupSummary

func (this *Wigo) GroupSummary(groupName string) (hs []*HostSummary, status int)

func (*Wigo) InitOrReloadLogger

func (this *Wigo) InitOrReloadLogger() (err error)

func (*Wigo) IsProbeDisabled

func (this *Wigo) IsProbeDisabled(probeName string) bool

func (*Wigo) ListGroupsNames

func (this *Wigo) ListGroupsNames() []string

func (*Wigo) ListProbes

func (this *Wigo) ListProbes() []string

func (*Wigo) ListRemoteWigosNames

func (this *Wigo) ListRemoteWigosNames() []string

func (*Wigo) Lock

func (this *Wigo) Lock()

Locks

func (*Wigo) RecomputeGlobalStatus

func (this *Wigo) RecomputeGlobalStatus()

Recompute statuses

func (*Wigo) SearchLogs

func (this *Wigo) SearchLogs(probe string, hostname string, group string, limit uint64, offset uint64) []*Log

func (*Wigo) SetParentHostsInProbes

func (this *Wigo) SetParentHostsInProbes()

func (*Wigo) ToJsonString

func (this *Wigo) ToJsonString() (string, error)

Serialize

func (*Wigo) Unlock

func (this *Wigo) Unlock()

func (*Wigo) Up

func (this *Wigo) Up()

Jump to

Keyboard shortcuts

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