bond

package module
v0.0.0-...-cf0b7df Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 28 Imported by: 0

README

Chen's Bond: MongoDB Sharded Cluster Analysis Tool

Chen's Bond is a MongoDB analysis tool designed for the purpose of database management and optimization. It primarily operates by querying the 'config' database, providing users with valuable insights into their MongoDB deployment. The tool is particularly focused on improving the performance and efficiency of MongoDB sharded clusters. To assess a cluster, connect Bond to a mongos instance. Alternatively, it can establish a direct connection to the config database or be used in a cluster restore from a config database backup.

Build Instructions

Build instructions and user's guide are available at Chen's Bond - MongoDB Sharded Cluster Analysis Tool.

Changes

v0.2.0
  • Added Chunk Move Errors

Chunk Move Errors

License

Apache-2.0 License

Documentation

Index

Constants

View Source
const (
	MigrationTimeChartHTML = `` /* 1184-byte string literal not displayed */

	MigrationStatsChartHTML = `` /* 1244-byte string literal not displayed */

	ChunkSplitsChartHTML = `` /* 1144-byte string literal not displayed */

)
View Source
const (
	T_MIGRATION_TIME  = "migration_time"
	T_MIGRATION_STATS = "migration_stats"
	T_CHUNK_SPLITS    = "splits"
)
View Source
const (
	CHEN_ICO   = `` /* 5716-byte string literal not displayed */
	SAGE_PNG   = `` /* 11196-byte string literal not displayed */
	SIMONE_PNG = `` /* 18360-byte string literal not displayed */
)
View Source
const (
	// Summary
	SummaryHTML = `` /* 982-byte string literal not displayed */

	// general info
	InfoHTML = `` /* 2084-byte string literal not displayed */

	// logs
	LogsHTML = `` /* 918-byte string literal not displayed */

	// chunkMove errors
	ChunkMoveErrorsHTML = `` /* 591-byte string literal not displayed */

	// shards
	ShardsHTML = `` /* 1102-byte string literal not displayed */

	// mongos
	MongosHTML = `` /* 1139-byte string literal not displayed */

	// Databases
	DatabasesHTML = `` /* 629-byte string literal not displayed */

	// Collections
	CollectionsHTML = `` /* 1030-byte string literal not displayed */

	BondVideoHTML = `` /* 390-byte string literal not displayed */

)
View Source
const (
	TOP_N = 23
)

Variables

This section is empty.

Functions

func ChartsHandler

func ChartsHandler(w http.ResponseWriter, r *http.Request, params httprouter.Params)

ChartsHandler renders charts for UI selections

func CheckUpgradeRecommendation

func CheckUpgradeRecommendation(mongoVersion string) string

func DataHandler

func DataHandler(w http.ResponseWriter, r *http.Request, params httprouter.Params)

DataHandler responds to API calls

func FaviconHandler

func FaviconHandler(w http.ResponseWriter, r *http.Request, params httprouter.Params)

func GetChartTemplate

func GetChartTemplate(chartType string) (*template.Template, error)

GetChartTemplate returns HTML

func GetContentHTML

func GetContentHTML() string

func GetInfoTemplate

func GetInfoTemplate() (*template.Template, error)

GetInfoTemplate returns HTML

func GetPieChartTemplate

func GetPieChartTemplate() (*template.Template, error)

func GetTickets

func GetTickets() *map[string]Tickets

GetTickets returns *map[string]Tickets instance

func Handler

func Handler(w http.ResponseWriter, r *http.Request, params httprouter.Params)

Handler responds to API calls

func InfoHandler

func InfoHandler(w http.ResponseWriter, r *http.Request, params httprouter.Params)

InfoHandler responds to API calls

func NamespaceChartHandler

func NamespaceChartHandler(w http.ResponseWriter, r *http.Request, params httprouter.Params)

NamespaceChartHandler renders pie charts for percentage of shards distribution for a given collection

func Run

func Run(fullVersion string)

func ShardChartHandler

func ShardChartHandler(w http.ResponseWriter, r *http.Request, params httprouter.Params)

ShardChartHandler renders pie charts for percentage of collections distribution for a given shard

func Stringify

func Stringify(doc interface{}, opts ...string) string

func StringifyIndent

func StringifyIndent(doc interface{}) string

func ToInt

func ToInt(num interface{}) int

ToInt converts to int

func ToInt64

func ToInt64(num interface{}) int64

ToInt64 converts to int64

Types

type ActionLog

type ActionLog struct {
	BalancerRounds []BalancerRound
	Stats          struct {
		AverageExecutionTime float64 `bson:"averageExecutionTime"`
		Capped               *bool   `bson:"capped"`
		MaxExecutionTime     int64   `bson:"maxExecutionTime"`
		MaxSize              int64   `bson:"maxSize"`
		TotalChunksMoved     int     `bson:"totalChunksMoved"`
		TotalErrors          int     `bson:"totalErrors"`
	}
	// contains filtered or unexported fields
}

func NewActionLog

func NewActionLog(client *mongo.Client) (*ActionLog, error)

func (*ActionLog) GetBalancerRounds

func (ptr *ActionLog) GetBalancerRounds() error

func (*ActionLog) GetStats

func (ptr *ActionLog) GetStats() error

type BalancerRound

type BalancerRound struct {
	AverageExecutionTime float64            `bson:"averageExecutionTime"`
	Time                 primitive.DateTime `bson:"time"`
	TotalChunksMoved     int                `bson:"totalChunksMoved"`
	TotalErrors          int                `bson:"totalErrors"`
}

type ChangeLog

type ChangeLog struct {
	ChunkMoveErrors []ChunkMoveError `bson:"chunkMoveErrors"`
	Splits          []Split          `bson:"splits"`

	Stats struct {
		Capped               *bool `bson:"capped"`
		MaxSize              int64 `bson:"maxSize"`
		TotalChunkMoveErrors int   `bson:"totalChunkMoveErrors"`
		TotalSplits          int   `bson:"totalSplits"`
	} `bson:"stats"`
	// contains filtered or unexported fields
}

func NewChangeLog

func NewChangeLog(client *mongo.Client) (*ChangeLog, error)

func (*ChangeLog) GetMoveChunkErrors

func (ptr *ChangeLog) GetMoveChunkErrors() error

func (*ChangeLog) GetSplits

func (ptr *ChangeLog) GetSplits() error

type Chart

type Chart struct {
	Index int
	Title string
	Descr string
	URL   string
}

type ChunkMoveError

type ChunkMoveError struct {
	From  string `bson:"from"`
	To    string `bson:"to"`
	Total int    `bson:"total"`
}

type ConfigChunk

type ConfigChunk struct {
	Chunks int              `bson:"chunks"`
	Jumbo  int              `bson:"jumbo"`
	NS     string           `bson:"ns"`
	Shard  string           `bson:"shard"`
	UUID   primitive.Binary `bson:"uuid"`
}

type ConfigCollection

type ConfigCollection struct {
	Chunks    int    `bson:"chunks"`
	Dropped   bool   `bson:"dropped"`
	ID        string `bson:"_id"`
	Key       bson.D `bson:"key"`
	NoBalance bool   `bson:"noBalance"`
	Unique    bool   `bson:"unique"`
	UUID      primitive.Binary
	// contains filtered or unexported fields
}

type ConfigDB

type ConfigDB struct {
	MongoVersion string `bson:"version"`
	Version      struct {
		ClusterID            *primitive.ObjectID `bson:"clusterId"`
		CurrentVersion       *int                `bson:"currentVersion"`
		ID                   *int                `bson:"_id"`
		MinCompatibleVersion *int                `bson:"minCompatibleVersion"`
	} `bson:"config.version"`
	Mongos         []ConfigMongos              `bson:"config.mongos"`
	ShardsMap      map[string]ConfigShard      `bson:"shards"`
	Databases      []ConfigDatabase            `bson:"config.databases"`
	CollectionsMap map[string]ConfigCollection `bson:"collections"`
	Chunks         []ConfigChunk               `bson:"config.chunks"`

	Actions  *ActionLog          `bson:"actions"`
	Changes  *ChangeLog          `bson:"changes"`
	LastPing *primitive.DateTime `bson:"lastPing"`
	Warnings []string            `bson:"warnings"`

	IsUpgrade     bool
	IsUserVersion bool
	MajorVersion  string
	// contains filtered or unexported fields
}

func GetConfigDB

func GetConfigDB() *ConfigDB

GetConfigDB returns ConfigDB instance

func NewConfigDB

func NewConfigDB(uri string, version string, verbose bool) (*ConfigDB, error)

func (*ConfigDB) CheckLogs

func (ptr *ConfigDB) CheckLogs() error

CheckLogs checks actionlog and changelog

func (*ConfigDB) CheckWarnings

func (ptr *ConfigDB) CheckWarnings() error

CheckWarnings checks any misconfigrations and anomalies

func (*ConfigDB) GetChunksInfo

func (ptr *ConfigDB) GetChunksInfo() error

func (*ConfigDB) GetShardingInfo

func (ptr *ConfigDB) GetShardingInfo() error

func (*ConfigDB) PrintInfo

func (ptr *ConfigDB) PrintInfo()

type ConfigDatabase

type ConfigDatabase struct {
	ID          string `bson:"_id"`
	Partitioned bool   `bson:"partitioned"`
	Primary     string `bson:"primary"`
}

type ConfigMongos

type ConfigMongos struct {
	AdvisoryHostFQDNs *[]string           `bson:"advisoryHostFQDNs"`
	Created           *primitive.DateTime `bson:"created"`
	ID                *string             `bson:"_id"`
	MongoVersion      *string             `bson:"mongoVersion"`
	Ping              *primitive.DateTime `bson:"ping"`
	Up                int64               `bson:"up"`
	Waiting           bool                `bson:"waiting"`
}

type ConfigShard

type ConfigShard struct {
	Chunks  int     `bson:"chunks"`
	Host    *string `bson:"host"`
	Jumbo   int     `bson:"jumbo"`
	ID      *string `bson:"_id"`
	MaxSize *int    `bson:"maxSize"`
	State   *int    `bson:"state"`
	// contains filtered or unexported fields
}

type NameValue

type NameValue struct {
	Name  string `bson:"name"`
	Value int    `bson:"value"`
}

type Split

type Split struct {
	Time  primitive.DateTime `bson:"time"`
	Total int                `bson:"total"`
}

type Tickets

type Tickets struct {
	ID       string      `bson:"id"`
	Versions [][2]string `bson:"versions"`
}

Directories

Path Synopsis
* Copyright 2023-present Kuei-chun Chen.
* Copyright 2023-present Kuei-chun Chen.

Jump to

Keyboard shortcuts

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