app

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2022 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// TODO: make this mapping dynamic
	DefaultMonitoringChannel = "CSJK7P7C3" // #monitoring-unms
	NNToSlackChannel         = map[int]string{

		5712: "C02HZLLH85R",
	}
)
View Source
var (
	MinLogQueryPeriod = float64(time.Hour.Milliseconds())
	MaxLogQueryPeriod = float64((24 * 365 * time.Hour).Milliseconds())
)

Functions

func ByteCountIEC added in v0.2.1

func ByteCountIEC(b int64) string

func ByteCountSI added in v0.2.1

func ByteCountSI(b int64) string

func GetNNFromDeviceName added in v0.4.0

func GetNNFromDeviceName(name string) (int, error)

TODO: write unit tests for this function TODO: make this use other device fields (model?) to help identify

func GetNNFromSiteName added in v0.4.0

func GetNNFromSiteName(name string) (int, error)

typically the UISP name for our sites follows a convention like "Prospect Heights - 3461"

func GetNNFromUISPDevice added in v0.4.0

func GetNNFromUISPDevice(d *models.DeviceStatusOverview) (int, error)

func VersionString added in v0.3.0

func VersionString() string

Types

type App

type App struct {
	*client.UISPAPI

	Slack *slack.Client

	MeshAPIClient *meshapi.Client
	// contains filtered or unexported fields
}

func New

func New(cmd *cobra.Command, args []string) (*App, error)

func (*App) ConsoleWriteObject

func (a *App) ConsoleWriteObject(obj string) error

func (*App) GetFullOutageMap added in v0.5.0

func (a *App) GetFullOutageMap(ctx context.Context) (OutageMap, error)

func (*App) MeshAPIDevices added in v0.2.2

func (a *App) MeshAPIDevices(ids ...string) (map[int]*meshapi.Device, error)

func (*App) MeshAPIKML added in v0.3.2

func (a *App) MeshAPIKML() ([]byte, error)

func (*App) MeshAPINodes added in v0.3.0

func (a *App) MeshAPINodes(ids ...string) (map[int]meshapi.Node, error)

func (*App) RunDaemon added in v0.4.1

func (a *App) RunDaemon(daemonCtx context.Context) (errs []error)

func (*App) Tableify

func (a *App) Tableify(headers []string, data [][]string) error

func (*App) UISPDevices added in v0.2.2

func (a *App) UISPDevices() ([]*models.DeviceStatusOverview, error)

func (*App) WatchLogs added in v0.4.0

func (a *App) WatchLogs(ctx context.Context, since time.Time, dstCh chan<- LogEvent) error

type Config added in v0.4.1

type Config struct {
	Core   CoreConfig   `json:"core"`
	Slack  SlackConfig  `json:"slack"`
	Daemon DaemonConfig `json:"daemon"`
}

func NewConfig added in v0.4.1

func NewConfig() (*Config, error)

type CoreConfig added in v0.4.1

type CoreConfig struct {
	OutputFormat string `json:"format"`
}

type DaemonConfig added in v0.4.1

type DaemonConfig struct {
	DFSEventDetection bool `json:"dfs-event-detection"`
	OutageDetection   bool `json:"outage-detection"`
	EnableSlack       bool `json:"enable-slack"`
}

DaemonConfig contains relevant configuration for the daemon's behavior.

type FusedDevice added in v0.2.2

type FusedDevice struct {
	NodeNumber    int                          `json:"nn"`
	MeshAPINode   *meshapi.Node                `json:"meshapi_node"`
	MeshAPIDevice *meshapi.Device              `json:"meshapi_device"`
	UISP          *models.DeviceStatusOverview `json:"uisp_device"`
}

type HealthStatus added in v0.5.0

type HealthStatus string
const (
	HealthStatusOnline      HealthStatus = "online"
	HealthStatusUnreachable HealthStatus = "unreachable"
	HealthStatusDegraded    HealthStatus = "degraded"
	HealthStatusOffline     HealthStatus = "offline"
	HealthStatusUnknown     HealthStatus = "unknown"
)

type LogEvent added in v0.4.0

type LogEvent struct {
	Time time.Time
	NN   int
	LogEventUISP
}

type LogEventUISP added in v0.4.0

type LogEventUISP models.Model9 // -_- generated code suxxx, why this confusing name

TODO: we should patch the UISP swagger spec to rename Model9 to something more useful here

type Outage added in v0.5.0

type Outage struct {
	NN int
	OutageUISP
	HealthStatus
	Start time.Time
}

type OutageMap added in v0.5.0

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

func (*OutageMap) GetOutagesDeviceNamesByOutageType added in v0.5.0

func (om *OutageMap) GetOutagesDeviceNamesByOutageType(nn int, outageType string) []string

func (*OutageMap) ImpactedNNs added in v0.5.0

func (om *OutageMap) ImpactedNNs() []int

func (*OutageMap) NodeDeviceOutages added in v0.5.0

func (om *OutageMap) NodeDeviceOutages(nn int) ([]Outage, error)

func (*OutageMap) OutageStartTime added in v0.5.0

func (om *OutageMap) OutageStartTime(nn int) (outageStart *time.Time, err error)

type OutageUISP added in v0.5.0

type OutageUISP models.Outage

type SlackConfig added in v0.4.1

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

Jump to

Keyboard shortcuts

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