clusterinfo

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: BSD-3-Clause Imports: 15 Imported by: 1

README

clusterinfo

clusterinfo parses data from the output of Redis Inc's rladmin tool Specifically, it takes the output of rladmin status and builds useful data structures from them.

See (rlatool)[https://github.com/goslogan/rlatool] for normal usage details. This package contains the backend library as used in rlatool and others.

Documentation

Overview

chunks.go provides a base parser that loads rladmin output and parses it into chunks for each section. Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

databases.go provides a parser for the database information in the rladmin output Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

endpoints.go provides a parser for the node information in the rladmin output Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

nodes.go provides a parser for the node information in the rladmin output Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

shards.go provides a parser for the shard information in the rladmin output Copyright © 2024 Nic Gibson <nic.gibson@redis.com>

Index

Constants

View Source
const (
	ChunkNone = iota
	ChunkCluster
	ChunkNodes
	ChunkDatabases
	ChunkEndpoints
	ChunkShards
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunks

type Chunks struct {
	Intro     string
	Nodes     []byte
	Databases []byte
	Endpoints []byte
	Shards    []byte
}

Chunks is used to store the output of the base parser.

func (*Chunks) ExtractTimeStamp

func (c *Chunks) ExtractTimeStamp() (time.Time, error)

ExtractTimeStamp finds the timestamp at the start of the output and returns it as time.Time

func (*Chunks) Parse

func (c *Chunks) Parse(input io.Reader) error

func (*Chunks) ParseDatabases

func (c *Chunks) ParseDatabases(parent *ClusterInfo) (Databases, error)

func (*Chunks) ParseEndpoints

func (c *Chunks) ParseEndpoints(parent *ClusterInfo) (Endpoints, error)

func (*Chunks) ParseNodes

func (c *Chunks) ParseNodes(parent *ClusterInfo) (Nodes, error)

func (*Chunks) ParseShards

func (c *Chunks) ParseShards(parent *ClusterInfo) (Shards, error)

type ClusterInfo

type ClusterInfo struct {
	Key       string    `json:"key"`
	Source    string    `json:"source"`
	Unparsed  *Chunks   `json:"-"`
	Databases Databases `json:"databases"`
	Endpoints Endpoints `json:"endpoints"`
	Shards    Shards    `json:"shards"`
	Nodes     Nodes     `json:"nodes"`
	TimeStamp time.Time `json:"timeStamp"`
}

ClusterInfo represents all the data loaded from the rladmin status output

func NewClusterInfo

func NewClusterInfo(key string, in io.Reader) (*ClusterInfo, error)

func (*ClusterInfo) CSV added in v0.1.4

func (c *ClusterInfo) CSV(skipHeaders bool) (map[string]string, error)

func (*ClusterInfo) JSON

func (c *ClusterInfo) JSON() (string, error)

type ComponentBase added in v0.1.6

type ComponentBase struct {
	Key       string    `column:"-" json:"key" csv:"key"`
	Source    string    `column:"-" json:"source" csv:"source"`
	TimeStamp time.Time `json:"timeStamp" csv:"timeStamp" column:"-"`
	// contains filtered or unexported fields
}

func (*ComponentBase) SetParent added in v0.1.6

func (cb *ComponentBase) SetParent(info *ClusterInfo)

type DBEndPoints

type DBEndPoints []string

func (*DBEndPoints) UnmarshalText

func (db *DBEndPoints) UnmarshalText(text []byte) error

type DBNodes

type DBNodes map[string]*DBShards

func (*DBNodes) MarshalCSV

func (n *DBNodes) MarshalCSV() (string, error)

type DBShards

type DBShards struct {
	Masters  uint16
	Replicas uint16
}

type Database

type Database struct {
	ComponentBase
	Id                string      `column:"DB:ID" json:"id" csv:"id"`
	Name              string      `column:"NAME" json:"name" csv:"name"`
	Type              string      `column:"TYPE" json:"type" csv:"type"`
	Status            string      `column:"STATUS" json:"status" csv:"status"`
	MasterShards      uint16      `column:"SHARDS" json:"shards" csv:"shards"`
	Placement         string      `column:"PLACEMENT" json:"placement" csv:"placement"`
	Replication       string      `column:"REPLICATION" json:"replication" csv:"replication"`
	Persistence       string      `column:"PERSISTENCE" json:"persistence" csv:"persistence"`
	Endpoint          DBEndPoints `column:"ENDPOINT" json:"endpoints" csv:"endpoints"`
	ExecState         string      `column:"EXEC_STATE" json:"execState" csv:"execState"`
	ExecStateMachine  string      `column:"EXEC_STATE_MACHINE" json:"execStateMachine" csv:"execStateMachine"`
	BackupProgress    string      `column:"BACKUP_PROGRESS" json:"backupProgress" csv:"backupProgress"`
	MissingBackupTime string      `column:"MISSING_BACKUP_TIME" json:"missingBackupTime" csv:"missingBackupTime"`
	RedisVersion      string      `column:"REDIS_VERSION" json:"redisVersion" csv:"redisVersion"`
}

func (*Database) ClusterName added in v0.1.6

func (db *Database) ClusterName() string

ClusterName builds a cluster name from the database endpoints and returns it

func (*Database) JSON

func (db *Database) JSON() (string, error)

JSON returns the database struct marsalled to JSON

type Databases

type Databases []*Database

func (Databases) CSV

func (d Databases) CSV(skipHeaders bool) (string, error)

Marshal the databases to a string and return it. If the skipHeaders parameter is true, marshall without headers

func (Databases) ClusterName added in v0.1.6

func (dbs Databases) ClusterName() string

ClusterName gets the cluster name from the first database in the list

func (Databases) JSON

func (d Databases) JSON() (string, error)

func (Databases) SetParent added in v0.1.6

func (d Databases) SetParent(info *ClusterInfo)

Set the parent (and associated fields) for all dbs

func (Databases) SetSource added in v0.1.6

func (d Databases) SetSource(source string)

Set the source only for all dbs {

type Endpoint

type Endpoint struct {
	ComponentBase
	Id             string `column:"ID" json:"id" csv:"endpointId"`
	DBId           string `column:"DB:ID" json:"dbId" csv:"dbid"`
	Name           string `column:"NAME" json:"name" csv:"name"`
	Node           string `column:"NODE" json:"node" csv:"node"`
	Role           string `column:"ROLE" json:"role" csv:"endpointRole"`
	SSL            bool   `column:"SSL" json:"ssl" csv:"ssl"`
	WatchdogStatus string `column:"WATCHDOG_STATUS" json:"watchdogStatus" csv:"watchDogStatus"`
}

type Endpoints

type Endpoints []*Endpoint

func (Endpoints) CSV

func (endpoints Endpoints) CSV(skipHeaders bool) (string, error)

func (Endpoints) JSON

func (endpoints Endpoints) JSON() (string, error)

func (Endpoints) SetParent added in v0.1.6

func (endpoints Endpoints) SetParent(info *ClusterInfo)

Set the parent (and associated fields) for all endpoints

func (Endpoints) SetSource added in v0.1.6

func (endpoints Endpoints) SetSource(source string)

Set the source only for all dbs {

type IP

type IP struct {
	net.IP
}

func (*IP) UnmarshalText

func (i *IP) UnmarshalText(input []byte) error

type MemoryInfo

type MemoryInfo struct {
	Free RAMFloat `json:"free"`
	Max  RAMFloat `json:"max"`
}

func (*MemoryInfo) UnmarshalText

func (m *MemoryInfo) UnmarshalText(input []byte) error

type Node

type Node struct {
	ComponentBase
	Id               string     `json:"nodeId" csv:"nodeId" column:"NODE:ID" `
	Role             string     `json:"role" csv:"role" column:"ROLE"`
	Address          IP         `json:"address" csv:"address" column:"ADDRESS"`
	ExternalAddress  IP         `json:"externalAddress" csv:"externalAddress" column:"EXTERNAL_ADDRESS"`
	HostName         string     `json:"hostName" csv:"hostName" column:"HOSTNAME"`
	OverbookingDepth RAMFloat   `json:"overbookingDepth" csv:"overbookingDepth" column:"OVERBOOKING_DEPTH"`
	Masters          uint16     `json:"masters" csv:"masters" column:"MASTERS"`
	Replicas         uint16     `json:"replicas" csv:"replicas" column:"SLAVES"`
	ShardUsage       ShardInfo  `json:"shards" csv:"shards" column:"SHARDS"`
	Cores            uint16     `json:"cores" csv:"cores" column:"CORES"`
	RedisRAM         MemoryInfo `json:"redisRAM" csv:"redisRAM" column:"FREE_RAM"`
	ProvisionalRAM   MemoryInfo `json:"provisionalRAM" csv:"provisionalRAM" column:"PROVISIONAL_RAM"`
	Version          string     `json:"version" csv:"version" column:"VERSION"`
	SHA              string     `json:"sha" csv:"sha" column:"SHA"`
	RackId           string     `json:"rackId" csv:"rackId" column:"RACK-ID"`
	Status           string     `json:"status" csv:"status" column:"STATUS"`
	Quorum           bool       `json:"quorum" csv:"quorum" column:"-"`
}

type Nodes

type Nodes []*Node

func (Nodes) CSV

func (ns Nodes) CSV(skipHeaders bool) (string, error)

func (Nodes) JSON

func (ns Nodes) JSON() (string, error)

type RAMFloat

type RAMFloat float64

func (*RAMFloat) MarshalText

func (g *RAMFloat) MarshalText() ([]byte, error)

func (*RAMFloat) UnmarshalText

func (g *RAMFloat) UnmarshalText(s []byte) error

type Shard

type Shard struct {
	ComponentBase
	Id             string   `column:"ID" json:"id" csv:"shardid"`
	DBId           string   `column:"DB:ID" json:"dbId" csv:"dbid"`
	Name           string   `column:"NAME" json:"name" csv:"name"`
	Node           string   `column:"NODE" json:"node" csv:"node"`
	Role           string   `column:"ROLE" json:"role" csv:"role"`
	Slots          string   `column:"SLOTS" json:"slots" csv:"slots"`
	UsedMemory     RAMFloat `column:"USED_MEMORY" json:"usedMemory" csv:"usedMemory"`
	BackupProgress string   `column:"BACKUP_PROGRESS" json:"backupProgress" csv:"backupProgress"`
	RAMFrag        RAMFloat `column:"RAM_FRAG" json:"ramFrag" csv:"ramFrag"`
	WatchdogStatus string   `column:"WATCHDOG_STATUS" json:"watchdogStatus" csv:"watchdogStatus"`
	Status         string   `column:"STATUS" json:"status" csv:"status"`
}

type ShardInfo

type ShardInfo struct {
	InUse uint16 `json:"shardsInUse"`
	Max   uint16 `json:"maxShards"`
}

func (*ShardInfo) UnmarshalCSV

func (s *ShardInfo) UnmarshalCSV(input string) error

func (*ShardInfo) UnmarshalText

func (s *ShardInfo) UnmarshalText(input []byte) error

type Shards

type Shards []*Shard

func (Shards) CSV

func (s Shards) CSV(skipHeaders bool) (string, error)

func (Shards) ForDB

func (s Shards) ForDB(id string) Shards

ForDB returns all the shards for a given database, sorted in Id order

func (Shards) JSON

func (s Shards) JSON() (string, error)

Jump to

Keyboard shortcuts

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