Documentation ¶
Index ¶
- Constants
- func GetIndexSuggestion(explain ExplainCommand, cardList []CardinalityCount) gox.OrderedMap
- func GetKeys(document bson.D, _range ...bool) []string
- func GetOptime(optime interface{}) int64
- func GetShards(client *mongo.Client, uri string) ([]string, error)
- func GetShardsURIList(client *mongo.Client, uri string) ([]string, error)
- func GetStorageSize(num interface{}) string
- func IsMaster(client *mongo.Client) (bson.M, error)
- func ListDatabaseNames(client *mongo.Client) ([]string, error)
- func MilliToTimeString(milli float64) string
- func MongoPipeline(str string) mongo.Pipeline
- func NewMongoClient(uri string, opts ...string) (*mongo.Client, error)
- func Parse(uri string) (string, error)
- func ReadPasswordFromStdin() (string, error)
- func RunAdminCommand(client *mongo.Client, command string) (bson.M, error)
- func RunCommandOnDB(client *mongo.Client, command string, db string) (bson.M, error)
- type AccessesDoc
- type Cardinality
- type CardinalityCount
- type CardinalitySummary
- type ChangeStream
- type ConcurrentTransactionsCountDoc
- type ConcurrentTransactionsDoc
- type ConnectionsDoc
- type DBStats
- type DocumentDoc
- type ExplainCommand
- type ExplainSummary
- type ExtraInfoDoc
- type GlobalLockDoc
- type GlobalLockSubDoc
- type IndexStatsDoc
- type IndexesReader
- func (ir *IndexesReader) GetIndexes() (bson.M, error)
- func (ir *IndexesReader) GetIndexesFromCollection(collection *mongo.Collection) []IndexStatsDoc
- func (ir *IndexesReader) GetIndexesFromDB(dbName string) (bson.M, error)
- func (ir *IndexesReader) Print(indexesMap bson.M)
- func (ir *IndexesReader) SetDBName(dbName string)
- func (ir *IndexesReader) SetVerbose(verbose bool)
- type LogInfo
- type MemDoc
- type MemberDoc
- type MetricsDoc
- type MongoCluster
- type OpCountersDoc
- type OpLatenciesDoc
- type OpLatenciesOpDoc
- type OpPerformanceDoc
- type OperationDoc
- type OptimeDoc
- type QueryExecutorDoc
- type QueryExplainer
- func (qe *QueryExplainer) Explain() (ExplainSummary, error)
- func (qe *QueryExplainer) GetExplainDetails(doc bson.M) ExplainSummary
- func (qe *QueryExplainer) GetFilter() bson.D
- func (qe *QueryExplainer) GetSummary(summary ExplainSummary) string
- func (qe *QueryExplainer) ReadQueryShapeFromFile(filename string) error
- func (qe *QueryExplainer) SetCollection(collection string)
- func (qe *QueryExplainer) SetDatabase(database string)
- func (qe *QueryExplainer) SetVerbose(verbose bool)
- type ReplSetStatusDoc
- type ServerInfo
- type ServerStatusDoc
- type ShardDoc
- type ShardList
- type SlowOps
- type StageStats
- type UsageDoc
- type WiredTigerCacheDoc
- type WiredTigerDoc
Constants ¶
const COLLSCAN = "COLLSCAN"
COLLSCAN constance
const KEYHOLEDB = "_KEYHOLE_"
KEYHOLEDB -
const PRIMARY = "PRIMARY"
PRIMARY - primary node
const REPLICA = "replica"
REPLICA set
const SECONDARY = "SECONDARY"
SECONDARY - secondary node
const SHARDED = "sharded"
SHARDED cluster
const STANDALONE = "standalone"
STANDALONE cluster
Variables ¶
This section is empty.
Functions ¶
func GetIndexSuggestion ¶ added in v1.0.1
func GetIndexSuggestion(explain ExplainCommand, cardList []CardinalityCount) gox.OrderedMap
GetIndexSuggestion returns a recommended index by cardinalities index follows a principle of equality, sort, rnage
func GetShardsURIList ¶
GetShardsURIList gets shards list
func GetStorageSize ¶ added in v1.1.0
func GetStorageSize(num interface{}) string
GetStorageSize returns storage size in [TGMK] B
func ListDatabaseNames ¶
ListDatabaseNames gets all database names
func MilliToTimeString ¶ added in v1.1.3
MilliToTimeString converts milliseconds to time string, e.g. 1.5m
func MongoPipeline ¶
MongoPipeline gets aggregation pipeline from a string
func NewMongoClient ¶
NewMongoClient new mongo client
func ReadPasswordFromStdin ¶
ReadPasswordFromStdin reads password from stdin
func RunAdminCommand ¶
RunAdminCommand executes admin Command
Types ¶
type AccessesDoc ¶ added in v1.1.2
type AccessesDoc struct { Ops int `json:"ops" bson:"ops"` Since time.Time `json:"since" bson:"since"` }
AccessesDoc - accessss
type Cardinality ¶
type Cardinality struct {
// contains filtered or unexported fields
}
Cardinality -
func NewCardinality ¶
func NewCardinality(client *mongo.Client) *Cardinality
NewCardinality returns cardinality constructor
func (*Cardinality) GetCardinalityArray ¶ added in v1.0.1
func (card *Cardinality) GetCardinalityArray(database string, collection string, keys ...[]string) (CardinalitySummary, error)
GetCardinalityArray returns cardinality list
func (*Cardinality) GetSummary ¶ added in v1.0.1
func (card *Cardinality) GetSummary(summary CardinalitySummary) string
GetSummary get summary of cardinality
type CardinalityCount ¶ added in v1.0.1
CardinalityCount stores cardinality counts
type CardinalitySummary ¶ added in v1.0.1
type CardinalitySummary struct { SampledCount int64 List []CardinalityCount }
CardinalitySummary stores Cardinality summary
type ChangeStream ¶ added in v1.0.1
type ChangeStream struct {
// contains filtered or unexported fields
}
ChangeStream defines what to watch? client, database or collection
func NewChangeStream ¶ added in v1.0.1
func NewChangeStream() *ChangeStream
NewChangeStream gets a new ChangeStream
func (*ChangeStream) SetCollection ¶ added in v1.0.1
func (cs *ChangeStream) SetCollection(collection string)
SetCollection sets collection
func (*ChangeStream) SetDatabase ¶ added in v1.0.1
func (cs *ChangeStream) SetDatabase(database string)
SetDatabase sets database
func (*ChangeStream) SetPipeline ¶ added in v1.0.1
func (cs *ChangeStream) SetPipeline(pipeline []bson.D)
SetPipeline sets pipeline
func (*ChangeStream) SetPipelineString ¶ added in v1.0.1
func (cs *ChangeStream) SetPipelineString(pipe string)
SetPipelineString sets pipeline string
func (*ChangeStream) Watch ¶ added in v1.0.1
func (cs *ChangeStream) Watch(client *mongo.Client, cb callback)
Watch prints oplogs in JSON format
type ConcurrentTransactionsCountDoc ¶
type ConcurrentTransactionsCountDoc struct { Available int64 `json:"available" bson:"available"` Out int64 `json:"out" bson:"out"` TotalTickets int64 `json:"totalTickets" bson:"totalTickets"` }
ConcurrentTransactionsCountDoc contains db.serverStatus().wiredTiger.concurrentTransactions.[read|write]
type ConcurrentTransactionsDoc ¶
type ConcurrentTransactionsDoc struct { Read ConcurrentTransactionsCountDoc `json:"read" bson:"read"` Write ConcurrentTransactionsCountDoc `json:"write" bson:"write"` }
ConcurrentTransactionsDoc contains db.serverStatus().wiredTiger.concurrentTransactions
type ConnectionsDoc ¶
type ConnectionsDoc struct { Current int64 `json:"current" bson:"current"` Available int64 `json:"available" bson:"available"` TotalCreated int64 `json:"totalCreated" bson:"totalCreated"` }
ConnectionsDoc contains db.serverStatus().connections
type DBStats ¶
type DBStats struct { DB string `json:"db" bson:"db"` DataSize int `json:"dataSize" bson:"dataSize"` IndexSize int `json:"indexSize" bson:"indexSize"` Objects int `json:"objects" bson:"objects"` }
DBStats contains info from db.stats()
type DocumentDoc ¶
type DocumentDoc struct { Deleted int `json:"deleted" bson:"deleted"` Inserted int `json:"inserted" bson:"inserted"` Returned int `json:"returned" bson:"returned"` Updated int `json:"updated" bson:"updated"` }
DocumentDoc contains db.serverStatus().document
type ExplainCommand ¶ added in v1.0.1
type ExplainCommand struct { Collection string `bson:"find"` Filter bson.D `bson:"filter"` Sort bson.D `bson:"sort,omitempty"` Hint bson.D `bson:"hint,omitempty"` }
ExplainCommand stores explain document
type ExplainSummary ¶ added in v1.0.1
type ExplainSummary struct { ShardName string `json:"shardName"` ExecutionStats StageStats `json:"executionStats"` AllPlansExecutionStats []StageStats `json:"allPlansExecution"` }
ExplainSummary stores explain summary
type ExtraInfoDoc ¶
type ExtraInfoDoc struct {
PageFaults int64 `json:"page_faults" bson:"page_faults"`
}
ExtraInfoDoc contains db.serverStatus().extra_info
type GlobalLockDoc ¶
type GlobalLockDoc struct { ActiveClients GlobalLockSubDoc `json:"activeClients" bson:"activeClients"` CurrentQueue GlobalLockSubDoc `json:"currentQueue" bson:"currentQueue"` TotalTime int `json:"totalTime" bson:"totalTime"` }
GlobalLockDoc contains db.serverStatus().globalLockDoc
type GlobalLockSubDoc ¶
type GlobalLockSubDoc struct { Readers int64 `json:"readers" bson:"readers"` Total int64 `json:"total" bson:"total"` Writers int64 `json:"writers" bson:"writers"` }
GlobalLockSubDoc contains db.serverStatus().globalLockDoc.[activeClients|currentQueue]
type IndexStatsDoc ¶
type IndexStatsDoc struct { Fields []string Key string `json:"key"` Name string `json:"name"` EffectiveKey string `json:"effectiveKey"` IsDupped bool `json:"dupped"` IsShardKey bool `json:"shardKey"` TotalOps int `json:"totalOps"` Usage []UsageDoc `json:"stats"` }
IndexStatsDoc -
type IndexesReader ¶ added in v1.1.2
type IndexesReader struct {
// contains filtered or unexported fields
}
IndexesReader holder indexes reader struct
func NewIndexesReader ¶ added in v1.1.2
func NewIndexesReader(client *mongo.Client) *IndexesReader
NewIndexesReader establish seeding parameters
func (*IndexesReader) GetIndexes ¶ added in v1.1.2
func (ir *IndexesReader) GetIndexes() (bson.M, error)
GetIndexes list all indexes of collections of databases
func (*IndexesReader) GetIndexesFromCollection ¶ added in v1.1.2
func (ir *IndexesReader) GetIndexesFromCollection(collection *mongo.Collection) []IndexStatsDoc
GetIndexesFromCollection gets indexes from a collection
func (*IndexesReader) GetIndexesFromDB ¶ added in v1.1.2
func (ir *IndexesReader) GetIndexesFromDB(dbName string) (bson.M, error)
GetIndexesFromDB list all indexes of collections of a database
func (*IndexesReader) Print ¶ added in v1.1.2
func (ir *IndexesReader) Print(indexesMap bson.M)
Print prints indexes
func (*IndexesReader) SetDBName ¶ added in v1.1.2
func (ir *IndexesReader) SetDBName(dbName string)
SetDBName sets verbose level
func (*IndexesReader) SetVerbose ¶ added in v1.1.2
func (ir *IndexesReader) SetVerbose(verbose bool)
SetVerbose sets verbose level
type LogInfo ¶ added in v1.0.1
type LogInfo struct { OpsPatterns []OpPerformanceDoc OutputFilename string SlowOps []SlowOps // contains filtered or unexported fields }
LogInfo keeps loginfo struct
func (*LogInfo) SetCollscan ¶ added in v1.0.1
SetCollscan -
func (*LogInfo) SetVerbose ¶ added in v1.0.1
SetVerbose -
type MemDoc ¶
type MemDoc struct { Resident int64 `json:"resident" bson:"resident"` Virtual int64 `json:"virtual" bson:"virtual"` }
MemDoc containers db.serverStatus().mem
type MemberDoc ¶
type MemberDoc struct { Name string `json:"name" bson:"name"` Optime interface{} `json:"optime" bson:"optime"` State int `json:"state" bson:"state"` }
MemberDoc stores replset status
type MetricsDoc ¶
type MetricsDoc struct { Document DocumentDoc `json:"document" bson:"document"` QueryExecutor QueryExecutorDoc `json:"queryExecutor" bson:"queryExecutor"` Operation OperationDoc `json:"operation" bson:"operation"` }
MetricsDoc contains db.serverStatus().metrics
type MongoCluster ¶ added in v1.1.0
type MongoCluster struct {
// contains filtered or unexported fields
}
MongoCluster holds mongo cluster info
func NewMongoCluster ¶ added in v1.1.0
func NewMongoCluster(client *mongo.Client) *MongoCluster
NewMongoCluster server info struct
func (*MongoCluster) GetClusterInfo ¶ added in v1.1.0
func (mc *MongoCluster) GetClusterInfo() (bson.M, error)
GetClusterInfo -
func (*MongoCluster) SetVerbose ¶ added in v1.1.0
func (mc *MongoCluster) SetVerbose(verbose bool)
SetVerbose -
func (*MongoCluster) WriteGzippedJSON ¶ added in v1.1.2
func (mc *MongoCluster) WriteGzippedJSON(filename string) error
WriteGzippedJSON outputs cluster into to a JSON file
type OpCountersDoc ¶
type OpCountersDoc struct { Command int64 `json:"command" bson:"command"` Delete int64 `json:"delete" bson:"delete"` Getmore int64 `json:"getmore" bson:"getmore"` Insert int64 `json:"insert" bson:"insert"` Query int64 `json:"query" bson:"query"` Update int64 `json:"update" bson:"update"` }
OpCountersDoc contains db.serverStatus().OpCounters
type OpLatenciesDoc ¶
type OpLatenciesDoc struct { Commands OpLatenciesOpDoc `json:"commands" bson:"commands"` Reads OpLatenciesOpDoc `json:"reads" bson:"reads"` Writes OpLatenciesOpDoc `json:"writes" bson:"writes"` }
OpLatenciesDoc contains db.serverStatus().opLatencies
type OpLatenciesOpDoc ¶
type OpLatenciesOpDoc struct { Latency int64 `json:"latency" bson:"latency"` Ops int64 `json:"ops" bson:"ops"` }
OpLatenciesOpDoc contains doc of db.serverStatus().opLatencies
type OpPerformanceDoc ¶ added in v1.1.3
type OpPerformanceDoc struct { Command string // count, delete, find, remove, and update Count int // number of ops Filter string // query pattern MaxMilli int // max millisecond Namespace string // database.collectin Scan string // COLLSCAN TotalMilli int // total milliseconds Index string // index used }
OpPerformanceDoc stores performance data
type OperationDoc ¶
type OperationDoc struct { ScanAndOrder int64 `json:"scanAndOrder" bson:"scanAndOrder"` WriteConflicts int64 `json:"writeConflicts" bson:"writeConflicts"` }
OperationDoc contains db.serverStatus().operation
type QueryExecutorDoc ¶
type QueryExecutorDoc struct { Scanned int64 `json:"scanned" bson:"scanned"` ScannedObjects int64 `json:"scannedObjects" bson:"scannedObjects"` }
QueryExecutorDoc contains db.serverStatus().queryExecutor
type QueryExplainer ¶ added in v1.0.1
type QueryExplainer struct { ExplainDoc ExplainCommand `bson:"explain"` // contains filtered or unexported fields }
QueryExplainer stores query analyzer info
func NewQueryExplainer ¶ added in v1.0.1
func NewQueryExplainer(client *mongo.Client) *QueryExplainer
NewQueryExplainer returns QueryExplainer
func (*QueryExplainer) Explain ¶ added in v1.0.1
func (qe *QueryExplainer) Explain() (ExplainSummary, error)
Explain explains query plans
func (*QueryExplainer) GetExplainDetails ¶ added in v1.0.1
func (qe *QueryExplainer) GetExplainDetails(doc bson.M) ExplainSummary
GetExplainDetails returns summary from a doc
func (*QueryExplainer) GetFilter ¶ added in v1.0.1
func (qe *QueryExplainer) GetFilter() bson.D
GetFilter sets verbosity
func (*QueryExplainer) GetSummary ¶ added in v1.0.1
func (qe *QueryExplainer) GetSummary(summary ExplainSummary) string
GetSummary get summary of explain executionStats
func (*QueryExplainer) ReadQueryShapeFromFile ¶ added in v1.1.3
func (qe *QueryExplainer) ReadQueryShapeFromFile(filename string) error
ReadQueryShapeFromFile gets filter map
func (*QueryExplainer) SetCollection ¶ added in v1.1.3
func (qe *QueryExplainer) SetCollection(collection string)
SetCollection sets collection name
func (*QueryExplainer) SetDatabase ¶ added in v1.1.3
func (qe *QueryExplainer) SetDatabase(database string)
SetDatabase sets database
func (*QueryExplainer) SetVerbose ¶ added in v1.0.1
func (qe *QueryExplainer) SetVerbose(verbose bool)
SetVerbose sets verbosity
type ReplSetStatusDoc ¶
type ReplSetStatusDoc struct { Date time.Time `json:"date" bson:"date"` Members []MemberDoc `json:"members" bson:"members"` }
ReplSetStatusDoc stores replset status
type ServerInfo ¶
type ServerInfo struct { Cluster string `json:"cluster" bson:"cluster"` Host string `json:"host" bson:"host"` Process string `json:"process" bson:"process"` Version string `json:"version" bson:"version"` Sharding bson.M `json:"sharding" bson:"sharding"` Repl bson.M `json:"repl" bson:"repl"` StorageSize bson.M }
ServerInfo constains server info from db.serverStatus()
func GetServerInfo ¶
func GetServerInfo(client *mongo.Client) (ServerInfo, error)
GetServerInfo returns ServerInfo from db.serverStatus()
type ServerStatusDoc ¶
type ServerStatusDoc struct { Connections ConnectionsDoc `json:"connections" bson:"connections"` ExtraInfo ExtraInfoDoc `json:"extra_info" bson:"extra_info"` GlobalLock GlobalLockDoc `json:"globalLock" bson:"globalLock"` Host string `json:"host" bson:"host"` LocalTime time.Time `json:"localTime" bson:"localTime"` Mem MemDoc `json:"mem" bson:"mem"` Metrics MetricsDoc `json:"metrics" bson:"metrics"` OpCounters OpCountersDoc `json:"opcounters" bson:"opcounters"` OpLatencies OpLatenciesDoc `json:"opLatencies" bson:"opLatencies"` Process string `json:"process" bson:"process"` Repl bson.M `json:"repl" bson:"repl"` Sharding bson.M `json:"sharding" bson:"sharding"` Uptime int64 `json:"uptime" bson:"uptime"` Version string `json:"version" bson:"version"` WiredTiger WiredTigerDoc `json:"wiredTiger" bson:"wiredTiger"` }
ServerStatusDoc contains docs from db.serverStatus()
type ShardDoc ¶
type ShardDoc struct { ID string `json:"_id" bson:"_id"` Host string `json:"host" bson:"host"` State int `json:"state" bson:"state"` }
ShardDoc information
type ShardList ¶
type ShardList struct { Shards []ShardDoc `json:"shards" bson:"shards"` OK int `json:"ok" bson:"ok"` }
ShardList -
type StageStats ¶ added in v1.0.1
type StageStats struct { Level int Score float64 `json:"Score"` Stage string `json:"stage"` Filter *gox.OrderedMap `json:"filter"` KeyPattern *gox.OrderedMap `json:"keyPattern"` Advanced int32 `json:"advanced"` Works int32 `json:"works"` ExecTimeMillisEst int32 `json:"executionTimeMillisEstimate"` TotalKeysExamined int32 `json:"totalKeysExamined"` TotalDocsExamined int32 `json:"totalDocsExamined"` InputStages []StageStats `json:"inputStages"` }
StageStats stores stats for each stage
type UsageDoc ¶
type UsageDoc struct { Host string `json:"host"` Accesses AccessesDoc `json:"accesses"` }
UsageDoc -
type WiredTigerCacheDoc ¶
type WiredTigerCacheDoc struct { MaxBytesConfigured int64 `json:"maximum bytes configured" bson:"maximum bytes configured"` CurrentlyInCache int64 `json:"bytes currently in the cache" bson:"bytes currently in the cache"` ModifiedPagesEvicted int64 `json:"modified pages evicted" bson:"modified pages evicted"` UnmodifiedPagesEvicted int64 `json:"unmodified pages evicted" bson:"unmodified pages evicted"` TrackedDirtyBytes int64 `json:"tracked dirty bytes in the cache" bson:"tracked dirty bytes in the cache"` PagesReadIntoCache int64 `json:"pages read into cache" bson:"pages read into cache"` PagesWrittenFromCache int64 `json:"pages written from cache" bson:"pages written from cache"` }
WiredTigerCacheDoc contains db.serverStatus().wiredTiger.cache
type WiredTigerDoc ¶
type WiredTigerDoc struct { Perf interface{} `json:"perf" bson:"perf"` Cache WiredTigerCacheDoc `json:"cache" bson:"cache"` ConcurrentTransactions ConcurrentTransactionsDoc `json:"concurrentTransactions" bson:"concurrentTransactions"` }
WiredTigerDoc contains db.serverStatus().wiredTiger