models

package
v0.0.0-...-a950f81 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2018 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateCheck

func CreateCheck(conn *nats.Conn, check *models.Check) error

func FindAllClients

func FindAllClients(conn *nats.Conn) ([]models.Client, error)

func FindAllCommands

func FindAllCommands(conn *nats.Conn) ([]models.Command, error)

func FindAllGroups

func FindAllGroups(conn *nats.Conn) ([]models.Group, error)

func FindCheck

func FindCheck(conn *nats.Conn, filter utils.Filter) ([]models.Check, error)

func FindCheckID

func FindCheckID(conn *nats.Conn, checkID bson.ObjectId) (*models.Check, error)

func FindWithClientAndCommand

func FindWithClientAndCommand(conn *nats.Conn, clientID, commandID bson.ObjectId) (*models.Check, error)

func UpdateCheck

func UpdateCheck(conn *nats.Conn, checkID bson.ObjectId) (bool, error)

Types

type Alert

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

Alert - is the virtual alert struct

func NewAlert

func NewAlert(ao models.AlertOption) *Alert

NewAlert - will create a new virtual alert based on AlertOptions

func (Alert) Alert

func (a Alert) Alert() providers.AlertProvider

Alert - Will return the AlertProvider

func (*Alert) Check

func (a *Alert) Check(resp string, conn *nats.Conn)

Check - Will check if an alert should be made or not

func (Alert) ClientID

func (a Alert) ClientID() bson.ObjectId

ClientID - Will return the client id on the alert

func (Alert) Delay

func (a Alert) Delay() int

Delay - Will return the delay between alerts

func (Alert) ID

func (a Alert) ID() bson.ObjectId

ID - Will return the alert ID

func (Alert) IterServices

func (a Alert) IterServices() <-chan services.Service

IterServices - Will return a channel and loop through all the services in a safe way and pass it to the channel

func (Alert) PreviousAlert

func (a Alert) PreviousAlert() time.Time

PreviousAlert - Will return when the previous alert was made

func (Alert) Services

func (a Alert) Services() []services.Service

Services - Will return all of the services associated with the alert

func (Alert) ServicesLength

func (a Alert) ServicesLength() int

ServicesLength - Will return the amount of services associated with the alert

func (*Alert) SetAlert

func (a *Alert) SetAlert(alert providers.AlertProvider)

SetAlert - Will modify the AlertProvider associated with the alert

func (*Alert) SetClientID

func (a *Alert) SetClientID(clientID bson.ObjectId)

SetClientID Will modify the virtual Client ID

func (*Alert) SetDelay

func (a *Alert) SetDelay(delay int)

SetDelay - Will modify the virtual delay

func (*Alert) SetID

func (a *Alert) SetID(id bson.ObjectId)

SetID - Will modify the virtual ID

func (*Alert) SetPreviousAlert

func (a *Alert) SetPreviousAlert(previous time.Time)

SetPreviousAlert - Will modify when the previous alert was made

func (*Alert) SetServices

func (a *Alert) SetServices(s []services.Service)

SetServices - Will modify all of the services associated with the alert

func (*Alert) Update

func (a *Alert) Update(alert models.AlertOption) bool

Update - will update the virtual alert data based on AlertOptions

type Check

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

Check - Virtual check struct

func NewCheck

func NewCheck(ch *models.Check, command *Command) *Check

NewCheck - Creates a new virtual check

func (*Check) AddAlert

func (c *Check) AddAlert(alert *Alert)

AddAlert will add a new alert to the check

func (*Check) Alerts

func (c *Check) Alerts() []*Alert

Alerts returns all of the alerts associated with this check

func (Check) AlertsLength

func (c Check) AlertsLength() int

AlertsLength will return the amount of alerts associated with this check

func (*Check) Checked

func (c *Check) Checked() (checked bool)

Checked returns whether or not the check has been checked.

func (*Check) Command

func (c *Check) Command() (cmd *Command)

Command returns the command

func (*Check) Error

func (c *Check) Error() (err bool)

Error returns whether or not the check got an error

func (*Check) Finished

func (c *Check) Finished() (finished bool)

Finished returns whether or not the check is finished

func (*Check) Group

func (c *Check) Group() (g *Group)

Group returns the group that this check belongs to

func (*Check) ID

func (c *Check) ID() (id bson.ObjectId)

ID returns the checks ID that this check belongs to

func (Check) IterAlerts

func (c Check) IterAlerts() <-chan *Alert

IterServices - Will return a channel and loop through all the alerts in a safe way and pass it to the channel

func (*Check) RemoveAlertByID

func (c *Check) RemoveAlertByID(id bson.ObjectId)

RemoveAlertByID will remove an alert from the check

func (*Check) SetChecked

func (c *Check) SetChecked(checked bool)

SetChecked modifies whether the check has been checked or not

func (*Check) SetError

func (c *Check) SetError(err bool)

SetError modifies whether the check got an error or not

func (*Check) SetFinished

func (c *Check) SetFinished(finished bool)

SetFinished modifies whether the check is finished or not

func (*Check) SetGroup

func (c *Check) SetGroup(g *Group)

SetGroup modifies the group that this check belongs to

func (*Check) SetID

func (c *Check) SetID(id bson.ObjectId)

SetID modifies the check id

func (*Check) SetTimestamp

func (c *Check) SetTimestamp(t time.Time)

SetTimestamp modifies the checks timestamp

func (*Check) Timestamp

func (c *Check) Timestamp() (timestamp time.Time)

Timestamp returns the checks timestamp

type Client

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

func NewClient

func NewClient(cl *models.Client) *Client

NewClient - Creates a new virtual client

func (*Client) AddCheck

func (c *Client) AddCheck(check *Check)

AddCheck will add a check to the client

func (*Client) AddGroup

func (c *Client) AddGroup(group *Group)

AddGroup will add a group to the client

func (Client) Check

func (c Client) Check(i int) (check *Check)

Check returns the specific check that belongs to the client, the index is based on the array index

func (Client) CheckByPastID

func (c Client) CheckByPastID(id bson.ObjectId) (check *Check)

CheckByPastID returns a specific check that belongs to the client based on the check ID

func (Client) Checks

func (c Client) Checks() (checks []*Check)

Checks returns all checks that belongs to the client

func (Client) ChecksByCommandID

func (c Client) ChecksByCommandID(id bson.ObjectId) []*Check

ChecksByCommandID returns a specific check that belongs to the client based on the command ID

func (Client) ChecksLength

func (c Client) ChecksLength() (count int)

ChecksLength will return the amount of checks that belongs to the client

func (Client) Conn

func (c Client) Conn() (conn net.Conn)

ID returns the clients database ID

func (Client) Group

func (c Client) Group(i int) (group *Group)

Group returns a specific group that the client belongs to, the index is based on the array index

func (Client) GroupByCommand

func (c Client) GroupByCommand(commandID bson.ObjectId) (groups []*Group)

GroupByCommand will return all groups with a specific command ID

func (Client) GroupByName

func (c Client) GroupByName(name string) (group *Group)

GroupByName returns the group with a specific name if the client belongs to it

func (Client) Groups

func (c Client) Groups() (groups []*Group)

Groups returns all virtual groups that the client belongs to

func (Client) GroupsLength

func (c Client) GroupsLength() (count int)

GroupsLength will return the amount of groups that the client belongs to

func (Client) HasGroupByName

func (c Client) HasGroupByName(name string) bool

HasGroupByName returns if the client belongs to a group with a specific name

func (Client) ID

func (c Client) ID() (id bson.ObjectId)

ID returns the clients database ID

func (Client) IP

func (c Client) IP() (ip string)

IP returns the clients IP

func (Client) IterChecks

func (c Client) IterChecks() <-chan *Check

IterChecks will return a channel and loop through all the checks in a safe way and pass it to the channel

func (Client) IterGroups

func (c Client) IterGroups() <-chan *Group

IterGroups will return a channel and loop through all the groups in a safe way and pass it to the channel

func (Client) Ping

func (c Client) Ping(port string) ([]PingResult, error)

Port will check if a port is open on a server

func (*Client) RemoveCheck

func (c *Client) RemoveCheck(i int) (ok bool)

RemoveCheck will remove a specific check from the client, the index is based on the array in memory

func (*Client) RemoveCheckByGroupID

func (c *Client) RemoveCheckByGroupID(id bson.ObjectId) (ok bool)

RemoveCheckByGroupID will remove a specific check from the client based on the group id

func (*Client) RemoveCheckByID

func (c *Client) RemoveCheckByID(id bson.ObjectId) (ok bool)

RemoveCheckByID will remove a specific check from the client based on the check ID

func (*Client) RemoveGroup

func (c *Client) RemoveGroup(i int) (ok bool)

RemoveGroup will remove a group from the client, the index is based on the array in memory

func (*Client) RemoveGroupsByCommand

func (c *Client) RemoveGroupsByCommand(commandID bson.ObjectId) (ok bool)

RemoveGroupsByCommand will remove a group from the client based on the command id

func (*Client) RemoveGroupsByName

func (c *Client) RemoveGroupsByName(name string) (ok bool)

RemoveGroupsByName will remove a group from the client based on the groups name

func (*Client) ResetCheck

func (c *Client) ResetCheck(name string)

ResetCheck will set error and checked to false on all checks with a specific name for the client

func (*Client) SaveCheck

func (c *Client) SaveCheck(conn *nats.Conn, check *Check, resp string)

SaveCheck will save a check to the database

func (*Client) SendCheck

func (c *Client) SendCheck(conn *nats.Conn, check *Check) string

SendCheck will send a check to the client and then save the check to the database

func (Client) SendMessage

func (c Client) SendMessage(message string) (resp string, err error)

SendMessage will create a TCP connection to the client then send a message to it and return the reply or error

func (*Client) SetConn

func (c *Client) SetConn(conn net.Conn)

SetIP modifies the client IP

func (*Client) SetIP

func (c *Client) SetIP(ip string)

SetIP modifies the client IP

func (*Client) StartCheck

func (c *Client) StartCheck(conn *nats.Conn)

StartCheck loop through all clients check and check if it's time to do any checks.

type Command

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

Command is the structure for virtual commands

func ConvertCommands

func ConvertCommands(cmds []models.Command) []*Command

func NewCommand

func NewCommand(command string, commandID bson.ObjectId, interval int, failonerror bool) *Command

NewCommand creates a new command from parameters

func (*Command) Clone

func (c *Command) Clone() *Command

Clone copies all the values of a command and returns a new command in a safe way

func (Command) Command

func (c Command) Command() (cmd string)

Command returns the command in a safe way

func (Command) FailOnError

func (c Command) FailOnError() (stop bool)

FailOnError returns the stop error value in a safe way

func (Command) GroupID

func (c Command) GroupID() bson.ObjectId

GroupID returns the group ID in a safe way

func (Command) ID

func (c Command) ID() bson.ObjectId

ID returns the commands ID In a safe way

func (Command) Interval

func (c Command) Interval() (next int)

Interval returns the next check value in a safe way

func (*Command) SetCommand

func (c *Command) SetCommand(command string)

SetCommand modifies the command in a safe way

func (*Command) SetFailOnError

func (c *Command) SetFailOnError(stop bool)

SetFailOnError modifies if the check should stop on an error or not in a safe way

func (*Command) SetGroupID

func (c *Command) SetGroupID(id bson.ObjectId)

SetGroupID modifies the group ID in a safe way

func (*Command) SetInterval

func (c *Command) SetInterval(next int)

SetInterval modifies the time between checks in a safe way

type Group

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

Group is the structure of a virtual group

func ConvertGroups

func ConvertGroups(groups []models.Group, cmds []*Command) []*Group

func NewGroup

func NewGroup(name string) *Group

NewGroup creates a new virtual group

func (*Group) AddCommand

func (g *Group) AddCommand(cmd *Command)

AddCommand add a new command in memory

func (Group) Command

func (g Group) Command(i int) (cmd *Command)

Command tries to find a command in memory in a safe way, the index is based on the in memory array

func (Group) CommandByID

func (g Group) CommandByID(id bson.ObjectId) (cmd *Command)

CommandByID tries to find a command in memory in a safe way, based on the command ID

func (Group) Commands

func (g Group) Commands() (cmds []*Command)

Commands returns all of the commands in a safe way

func (Group) HasCommand

func (g Group) HasCommand(id bson.ObjectId) (ok bool)

HasCommand will return if the command ID exists or not in memory

func (Group) ID

func (g Group) ID() bson.ObjectId

ID returns the name of the group in a safe way

func (Group) IterCommands

func (g Group) IterCommands() <-chan *Command

IterCommands - Will return a channel and loop through all the commands in a safe way and pass it to the channel

func (Group) Length

func (g Group) Length() (count int)

Length returns the amount of commands that exists in memory

func (Group) Name

func (g Group) Name() (name string)

Name returns the name of the group in a safe way

func (*Group) RemoveCommand

func (g *Group) RemoveCommand(i int) (ok bool)

RemoveCommand removes a command from memory, the index is based on the in memory array

func (*Group) RemoveCommandByID

func (g *Group) RemoveCommandByID(id bson.ObjectId) (ok bool)

RemoveByID removes a command from memory based on the command id

func (*Group) SetName

func (g *Group) SetName(name string)

SetName modifies the group name

type Manager

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

Manager struct, contains all the virtual clients

func NewManager

func NewManager(conn *nats.Conn) (*Manager, error)

NewManager - Will read from database and create new virtual clients

func (*Manager) AddClient

func (c *Manager) AddClient(client *Client)

AddClient - Add a new client to in memory array

func (Manager) Client

func (c Manager) Client(i int) (cl *Client)

Client - Return a specific client, the index is based on in memory array

func (Manager) ClientByID

func (c Manager) ClientByID(id bson.ObjectId) (cl *Client)

ClientByID - Check for a specifci client based on the client ID

func (Manager) Clients

func (c Manager) Clients() (cls []*Client)

Clients - Return all the clients

func (Manager) IterClients

func (c Manager) IterClients() <-chan *Client

IterClients - Will return a channel and loop through all the clients in a safe way and pass it to the channel

func (Manager) Length

func (c Manager) Length() (count int)

Length - Will return the amount of clients in memory

func (*Manager) RemoveClient

func (c *Manager) RemoveClient(i int) (ok bool)

RemoveClient - Remove a client from memory, the index is based on in memory array

func (*Manager) RemoveClientByID

func (c *Manager) RemoveClientByID(id bson.ObjectId) (ok bool)

RemoveClientByID - Remove a client from memory based on the id

type PingResult

type PingResult struct {
	Port   uint16
	Result bool
}

PingResult is the struct that will hold the result of a ping check

Jump to

Keyboard shortcuts

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