MonAliveLib

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoGet

func DoGet(url string) (string, bool)

func StatusOf

func StatusOf(itemName string, allStat []ItemStatus) (rv string)

Types

type ConfigItem

type ConfigItem struct {
	Name               string   `json:"Name"`               // Extended name for this item
	TTL                uint64   `json:"TTL"`                // How long before should have received PING on item
	RequiresPing       bool     `json:"RequiresPing"`       // To determine if it is alive requires a "ping" -- Maybe keep track of delta-t on last ping and only so often
	PingUrl            string   `json:"PingUrl"`            // URL to do "get" on to ping item -- http://localhost:16040/api/status for example
	Group              []string `json:"Group"`              // Set of groups that this belongs to "host":"virtual-host", "host":"goftl-server"
	CdTo               string   `json:"CdTo"`               // Direcotry to chagne to before run
	CmdToRun           string   `json:"CmdToRun"`           // Command to run when notification is needed.
	NotifThreshold     int      `json:"NotifThreshold"`     // new: Number of misssed events before Notification. Say 4.
	RemediateThreshold int      `json:"RemediateThreshold"` // new: Number of misseed before remediation is run. Say 3.
	RemediateCdTo      string   `json:"RemediateCdTo"`      // new: Direcotry to chagne to before run
	RemediateCmdToRun  string   `json:"RemediateCmdToRun"`  // new: Command to run when remediateion is needed.

	Extra map[string]interface{} // Other Config Items...
	// contains filtered or unexported fields
}

type ConfigMonitor

type ConfigMonitor struct {
	Item     map[string]ConfigItem //
	MinTTL   int                   // Defaults to 30 seconds - shortest time that can be set in seconds
	TrxIdTTL int                   // 0 for forever, else length in seconds for Trx:Id tracing to last on an Trx:Id
}

type Countries

type Countries []ItemStatus

func (Countries) Len

func (slice Countries) Len() int

func (Countries) Less

func (slice Countries) Less(i, j int) bool

func (Countries) Swap

func (slice Countries) Swap(i, j int)

type ItemStatus

type ItemStatus struct {
	Name     string
	Status   string
	Data     string
	LongName string
}

type MonIt

type MonIt struct {
	GetConn  func() (conn *redis.Client)
	FreeConn func(conn *redis.Client)
	// contains filtered or unexported fields
}

func NewMonIt

func NewMonIt(GetConn func() (conn *redis.Client), FreeConn func(conn *redis.Client), logFile *os.File) (rv *MonIt)

func (*MonIt) AddNewItem

func (mon *MonIt) AddNewItem(itemName string, ttl uint64)

add an item to the set of items that is monitored URL: /api/mon/add-new-item?itemName= ttl= ...

func (*MonIt) ChangeConfigOnItem

func (mon *MonIt) ChangeConfigOnItem(itemName string, newConfig map[string]interface{})

URL: /api/mon/upd-config-item?itemName=, ...

func (*MonIt) GetAllItem

func (mon *MonIt) GetAllItem() (rv []string)

return the set of all the named items that are being monitored URL: /api/mon/get-all-item

func (*MonIt) GetConfig

func (mon *MonIt) GetConfig() (s string)

func (*MonIt) GetItemStatus

func (mon *MonIt) GetItemStatus() (rv []ItemStatus)

GetItemStatus - up/down - all items monitored. URL: /api/mon/item-status

func (*MonIt) GetListOfPotentialItem

func (mon *MonIt) GetListOfPotentialItem() (rv []string)

get to set of "could-be-monitored-items" URL: /api/mon/list-potential

func (*MonIt) GetNotifyItem

func (mon *MonIt) GetNotifyItem() (rv []string)

GetNotifyItem returns the set of items that is NOT running that should be running Eventually - check via circuit checs for items that require ping URL: /api/mon/get-notify-item

func (*MonIt) GetStatusOfItemVerbose

func (mon *MonIt) GetStatusOfItemVerbose(extra bool) (rv []ItemStatus, hasChanged bool)

GetStatusOfItemVerbose returns the set of items that is NOT running that should be running Eventually - check via circuit checs for items that require ping URL: /api/mon/get-notify-item This will return a sorted by name array and true iff the name/status in the array has changed since last time.

func (*MonIt) IsMonitoredItem

func (mon *MonIt) IsMonitoredItem(itemKey string) bool

New: Sun Jul 16 06:15:11 MDT 2017

func (*MonIt) RemoveItem

func (mon *MonIt) RemoveItem(itemName string)

URL: /api/mon/rem-item?itemName=

func (*MonIt) SendIAmAlive

func (mon *MonIt) SendIAmAlive(itemName string, myStatus map[string]interface{})

Note that a particualr resources is up and sending "alive" pings.

func (*MonIt) SendIAmShutdown

func (mon *MonIt) SendIAmShutdown(itemName string)

shutdown op -- intentionally shutdown - means no notificaiton

func (*MonIt) SendIFailed

func (mon *MonIt) SendIFailed(itemName string)

shutdown op -- I know that I have failed - I should be up but I have AbEnded

func (*MonIt) SendPeriodicIAmAlive

func (mon *MonIt) SendPeriodicIAmAlive(itemName string)

Create a timed I Am Alive message

func (*MonIt) SendTrxState

func (mon *MonIt) SendTrxState(state, trxId string)

/api/mon/trx?state=on|off trx:state (on|off)

Turn tracking on/off for this Trx-ID -  if via SIO - then sends message via Pub/Sub to all servers to turn this ID on.  If via /api/mon/trx then
if via /api/mon/trx - then sends Pub/Sub to tracer - to tell tracter to send message to pass on.

func (*MonIt) SetConfig

func (mon *MonIt) SetConfig(s string)

Set a new config in Redis. 's' is the JSON of rv.Item...

func (*MonIt) SetConfigFromFile

func (mon *MonIt) SetConfigFromFile(fn string)

set config from file URL: /api/mon/reload-config?fn=

func (*MonIt) SetDebugFlags added in v0.5.5

func (mon *MonIt) SetDebugFlags(db map[string]bool)

func (*MonIt) SetupStatus

func (mon *MonIt) SetupStatus(listenAt string, fxStatus func() string, fxTest func() bool)

HTTP server that handles /api/status with an I AM ALIVE message.

func (*MonIt) SortByNameStatus

func (mon *MonIt) SortByNameStatus(st Countries)

cc.mon.SortByNameStatus(&st)

func (*MonIt) UpdateConfig

func (mon *MonIt) UpdateConfig() (rv ConfigMonitor)

Pull current configuraiton from Redis - Allows for changes in config to take place after program starts running.

Jump to

Keyboard shortcuts

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