keyhole

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2022 License: Apache-2.0 Imports: 36 Imported by: 1

README

Keyhole - Survey Your Mongo Land

Keyhole is a tool to explore MongoDB deployments. Start with Survey Your Mongo Land.

License

Apache-2.0 License

Disclaimer

This software is not supported by MongoDB, Inc. under any of their commercial support subscriptions or otherwise. Any usage of keyhole is at your own risk.

Changes

v1.2.1
  • Supports ReadPreferenceTagSets
v1.2
  • Prints connected client information from all mongod processes
  • Prints client information from a log file
  • Compares two clusters using internal metadata
  • Performs deep comparison of two clusters

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnalyzeMongoLogs added in v1.0.4

func AnalyzeMongoLogs(loginfo *mdb.LogInfo, filenames []string, maobiURL string) error

AnalyzeMongoLogs a helper function to analyze logs

func CollectIndexStats added in v1.0.4

func CollectIndexStats(index *mdb.IndexStats, client *mongo.Client, maobiURL string) error

CollectIndexStats collects all indexes stats

func CompareClusters added in v1.2.1

func CompareClusters(cfg *Config) error

CompareClusters compares two clusters, source and target

func CompareMetadata added in v1.2.1

func CompareMetadata(cfg *Config) error

CompareMetadata compares two clusters' metadata

func DuplicateIndexesFromFile added in v1.0.4

func DuplicateIndexesFromFile(index *mdb.IndexStats, client *mongo.Client, filename string, isDrop bool) error

DuplicateIndexesFromFile duplicate indexes from definitions defined in a file

func Exec added in v1.2.1

func Exec(filename string, signature string) error

Exec executes a plan based on a configuration file

func GenerateMaobiReport added in v1.1.5

func GenerateMaobiReport(maobiURL string, data []byte, ofile string) error

GenerateMaobiReport outputs an HTML from Maobi

func GetClusterSummary added in v1.0.4

func GetClusterSummary(version string, client *mongo.Client) string

GetClusterSummary returns MongoDB cluster summary

func GetMongoClientFromPool added in v1.2.1

func GetMongoClientFromPool(uri string) (*mongo.Client, error)

GetMongoClientFromPool returns a mongo client by an endpoint

func GetQualifiedDatabases added in v1.2.1

func GetQualifiedDatabases(client *mongo.Client) ([]string, error)

GetQualifiedDatabases returns a list of qualified database names

func GetQualifiedNamespaces added in v1.2.1

func GetQualifiedNamespaces(client *mongo.Client) ([]string, error)

GetQualifiedNamespaces returns a list of qualified namespace names

func GetQualifiedNamespacesByDB added in v1.2.1

func GetQualifiedNamespacesByDB(client *mongo.Client, dbName string) ([]string, error)

GetQualifiedNamespacesByDB returns a list of qualified namespace names

func GetValidatorTemplate added in v1.2.1

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

GetValidatorTemplate returns HTML of -compare

func MonitorWiredTigerCache added in v1.0.4

func MonitorWiredTigerCache(version string, client *mongo.Client)

MonitorWiredTigerCache monitor wiredTiger cache

func PrintCompareHelp added in v1.2.1

func PrintCompareHelp()

PrintCompareHelp prints help message

func PrintConnections added in v1.2.1

func PrintConnections(cfg *Config) error

PrintConnections print all connection info

func PrintConnectionsFromFile added in v1.2.1

func PrintConnectionsFromFile(filename string) error

PrintConnectionsFromFile print all connection info from a log file

func PrintConnectionsFromURI added in v1.2.1

func PrintConnectionsFromURI(uri string) error

PrintConnectionsFromURI print all connection info from all mongod

func Run

func Run(fullVersion string)

Run executes main()

func StartSimulation added in v1.0.4

func StartSimulation(runner *sim.Runner) error

StartSimulation kicks off simulation

func Stringify added in v1.2.1

func Stringify(doc interface{}) string

Stringify returns JSON string

func WirteValidatorHTML added in v1.2.1

func WirteValidatorHTML(stats ComparatorStats) error

WirteValidatorHTML outputs validators to a HTML file

Types

type Comparator added in v1.2.1

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

Comparator stores validation info

func NewComparator added in v1.2.1

func NewComparator(source string, target string) (*Comparator, error)

NewComparator returns Comparator

func (*Comparator) Compare added in v1.2.1

func (p *Comparator) Compare(filters []Filter, sampleSize int) error

Compare Compare namespaces

type ComparatorStats added in v1.2.1

type ComparatorStats struct {
	Messages []ErrorMessage
	Status   []NamespaceStats
}

ComparatorStats stores data for HTML

type Comparison

type Comparison struct {
	Logger      *gox.Logger       `bson:"keyhole"`
	SourceStats *mdb.ClusterStats `bson:"source"`
	TargetStats *mdb.ClusterStats `bson:"target"`
	// contains filtered or unexported fields
}

Comparison contains parameters of comparison parameters

func NewComparison

func NewComparison(keyholeVersion string) *Comparison

NewComparison returns *Comparison

func (*Comparison) Compare added in v1.0.6

func (p *Comparison) Compare(source string, target string) error

Compare executes compare commands

func (*Comparison) OutputBSON

func (p *Comparison) OutputBSON() error

OutputBSON writes bson data to a file

func (*Comparison) SetNoColor

func (p *Comparison) SetNoColor(nocolor bool)

SetNoColor set nocolor flag

func (*Comparison) SetVerbose

func (p *Comparison) SetVerbose(verbose bool)

SetVerbose sets verbose

type Config added in v1.2.1

type Config struct {
	Action    string `bson:"action,omitempty"`
	Filename  string `bson:"filename,omitempty"`
	NoColor   bool   `bson:"no_color,omitempty"`
	Signature string `bson:"signature,omitempty"`
	URI       string `bson:"uri,omitempty"`
	Verbose   bool   `bson:"verbose,omitempty"`

	IsDeepCompare bool     `bson:"deep_compare,omitempty"`
	Filters       []Filter `bson:"filters,omitempty"`
	SampleSize    int      `bson:"sample_size,omitempty"`
	SourceURI     string   `bson:"source_uri,omitempty"`
	TargetURI     string   `bson:"target_uri,omitempty"`
}

Config stores keyhole configuration

type ErrorMessage added in v1.2.1

type ErrorMessage struct {
	Descr string
	Error string
	NS    string
}

ErrorMessage keeps error message and info

type Filter added in v1.2.1

type Filter struct {
	NS       string `bson:"ns"`
	Query    bson.D `bson:"query"`
	TargetNS string `bson:"target_ns,omitempty"`
}

Filter holds query filter of a namespace

type IncludeDB added in v1.1.7

type IncludeDB []string

IncludeDB stores excluded QueryFilter

func (*IncludeDB) Set added in v1.1.7

func (p *IncludeDB) Set(value string) error

Set sets flag var

func (*IncludeDB) String added in v1.1.7

func (p *IncludeDB) String() string

type Logv2Network added in v1.2.1

type Logv2Network struct {
	Attributes struct {
		ConnectionCount int    `json:"connectionCount" bson:"connectionCount"`
		ConnectionID    int    `json:"connectionId" bson:"connectionId"`
		Remote          string `json:"remote" bson:"remote"`
	} `json:"attr" bson:"attr"`
	Component string            `json:"c" bson:"c"`
	Context   string            `json:"ctx" bson:"ctx"`
	ID        int               `json:"id" bson:"id"`
	Message   string            `json:"msg" bson:"msg"`
	Timestamp map[string]string `json:"t" bson:"t"`
}

Logv2Network stores logv2 network info

type Model added in v1.0.4

type Model struct {
	ID          string `json:"_id" bson:"_id"`
	Name        string
	Description string
	Year        int
}

Model - robot model

type NamespaceStats added in v1.2.1

type NamespaceStats struct {
	NS            string `json:"ns" bson:"ns"`
	Query         bson.D `json:"query" bson:"query"`
	SourceCount   int64  `json:"source_counts" bson:"source_counts"`
	SourceIndexes int64  `json:"source_indexes" bson:"source_indexes"`
	TargetCount   int64  `json:"target_counts" bson:"target_counts"`
	TargetIndexes int64  `json:"target_indexes" bson:"target_indexes"`
}

NamespaceStats stores migration counts

type Robot added in v1.0.4

type Robot struct {
	ID         string  `json:"_id" bson:"_id"`
	ModelID    string  `json:"modelId,omitempty" bson:"modelId,omitempty"`
	Notes      string  `json:"notes" bson:"notes"`
	BatteryPct float32 `json:"batteryPct,omitempty" bson:"batteryPct,omitempty"`
	Tasks      []Task  `json:"tasks" bson:"tasks"`
}

Robot -

type Seed added in v1.0.4

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

Seed seeds feeder

func NewSeed added in v1.0.4

func NewSeed() *Seed

NewSeed establish seeding parameters

func (*Seed) SeedAllDemoData added in v1.0.4

func (f *Seed) SeedAllDemoData(client *mongo.Client) error

SeedAllDemoData - seed data for demo

 models: {
   "_id": string
  "name": string,
  "description": string
  "year": integer
}
robots: {
  "_id": string
  "modelId": string
  "notes": string,
  "batteryPct": float,
  "tasks": [{"for": string, "minutesUsed": integer}]
}

func (*Seed) SeedData added in v1.0.4

func (f *Seed) SeedData(client *mongo.Client) error

SeedData seeds all demo data

func (*Seed) SeedFavorites added in v1.0.4

func (f *Seed) SeedFavorites(client *mongo.Client) error

SeedFavorites seeds demo data of collection favorites

func (*Seed) SeedTimeSeriesData added in v1.1.5

func (f *Seed) SeedTimeSeriesData(client *mongo.Client) error

SeedTimeSeriesData seeds demo data of timeseries

func (*Seed) SeedTimeSeriesWeather added in v1.1.5

func (f *Seed) SeedTimeSeriesWeather(client *mongo.Client) error

SeedTimeSeriesWeather seeds demo data of timeseries

func (*Seed) SeedVehicles added in v1.0.4

func (f *Seed) SeedVehicles(client *mongo.Client) error

SeedVehicles seeds vehicles collection

func (*Seed) SetCollection added in v1.0.4

func (f *Seed) SetCollection(collection string)

SetCollection set collection

func (*Seed) SetDatabase added in v1.0.4

func (f *Seed) SetDatabase(database string)

SetDatabase set database

func (*Seed) SetFile added in v1.0.4

func (f *Seed) SetFile(file string)

SetFile set file

func (*Seed) SetIsDrop added in v1.0.4

func (f *Seed) SetIsDrop(isDrop bool)

SetIsDrop set isDrop

func (*Seed) SetNumberConnections added in v1.0.4

func (f *Seed) SetNumberConnections(conns int)

SetNumberConnections set conns

func (*Seed) SetShowProgress added in v1.0.4

func (f *Seed) SetShowProgress(showProgress bool)

SetShowProgress set showProgress

func (*Seed) SetTotal added in v1.0.4

func (f *Seed) SetTotal(total int)

SetTotal set total

type Task added in v1.0.4

type Task struct {
	For         string `json:"for" bson:"for"`
	MinutesUsed int    `json:"minutesUsed" bson:"minutesUsed"`
}

Task - robot task

Directories

Path Synopsis
sim

Jump to

Keyboard shortcuts

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