Documentation ¶
Overview ¶
Package mongostat provides an overview of the status of a currently running mongod or mongos instance.
Index ¶
- Constants
- Variables
- type AsyncClusterMonitor
- type CacheStats
- type ClientStats
- type ClusterMonitor
- type ConcurrentTransStats
- type ConcurrentTransactions
- type ConfigShard
- type ConnectionStats
- type DBRecordStats
- type DurStats
- type DurTiming
- type ExtraInfo
- type FlushStats
- type GlobalLockStats
- type GridLineFormatter
- type JSONLineFormatter
- type LineFormatter
- type LockStats
- type LockStatus
- type LockUsage
- type MemStats
- type MongoStat
- type NamespacedLocks
- type NetworkStats
- type NodeMonitor
- type OpcountStats
- type QueueStats
- type ReadWriteLockTimes
- type RecordAccesses
- type ReplStatus
- type ServerStatus
- type StatHeader
- type StatLine
- type StatLines
- type StatOptions
- type SyncClusterMonitor
- type TransactionStats
- type WiredTiger
Constants ¶
const ( Always = 1 << iota // always activate the column Discover // only active when mongostat is in discover mode Repl // only active if one of the nodes being monitored is in a replset Locks // only active if node is capable of calculating lock info AllOnly // only active if mongostat was run with --all option MMAPOnly // only active if node has mmap-specific fields WTOnly // only active if node has wiredtiger-specific fields )
Flags to determine cases when to activate/deactivate columns for output.
const (
MongosProcess = "mongos"
)
Variables ¶
var StatHeaders = []StatHeader{ {"", Always}, {"insert", Always}, {"query", Always}, {"update", Always}, {"delete", Always}, {"getmore", Always}, {"command", Always}, {"% dirty", WTOnly}, {"% used", WTOnly}, {"flushes", Always}, {"mapped", MMAPOnly}, {"vsize", Always}, {"res", Always}, {"non-mapped", MMAPOnly | AllOnly}, {"faults", MMAPOnly}, {" locked db", Locks}, {"qr|qw", Always}, {"ar|aw", Always}, {"netIn", Always}, {"netOut", Always}, {"conn", Always}, {"set", Repl}, {"repl", Repl}, {"time", Always}, }
StatHeaders are the complete set of data metrics supported by mongostat.
var Usage = `` /* 168-byte string literal not displayed */
Functions ¶
This section is empty.
Types ¶
type AsyncClusterMonitor ¶
type AsyncClusterMonitor struct { Discover bool // Channel to listen for incoming stat data ReportChan chan StatLine // Map of hostname -> latest stat data for the host LastStatLines map[string]*StatLine // Used to format the StatLines for printing Formatter LineFormatter // contains filtered or unexported fields }
AsyncClusterMonitor is an implementation of ClusterMonitor that writes output gotten from polling samples collected asynchronously from one or more servers.
func (*AsyncClusterMonitor) Monitor ¶
func (cluster *AsyncClusterMonitor) Monitor(maxRows int, done chan error, sleep time.Duration, startNode string)
The Async implementation of Monitor starts the goroutines that listen for incoming stat data, and dump snapshots at a regular interval.
func (*AsyncClusterMonitor) Update ¶
func (cluster *AsyncClusterMonitor) Update(statLine StatLine)
Update sends a new StatLine on the cluster's report channel.
type CacheStats ¶
type CacheStats struct { TrackedDirtyBytes int64 `bson:"tracked dirty bytes in the cache"` CurrentCachedBytes int64 `bson:"bytes currently in the cache"` MaxBytesConfigured int64 `bson:"maximum bytes configured"` }
CacheStats stores cache statistics for WiredTiger.
type ClientStats ¶
type ClientStats struct { Total int64 `bson:"total"` Readers int64 `bson:"readers"` Writers int64 `bson:"writers"` }
ClientStats stores the number of active read/write operations.
type ClusterMonitor ¶
type ClusterMonitor interface { // Monitor() triggers monitoring and dumping output to begin // maxRows is the number of times to dump output before exiting. If <0, // Monitor() will run indefinitely. // done is a channel to send an error if one is encountered. A nil value will // be sent on this channel if Monitor() completes with no error. // sleep is the interval to sleep between output dumps. Monitor(maxRows int, done chan error, sleep time.Duration, startNode string) // Update signals the ClusterMonitor implementation to refresh its internal // state using the data contained in the provided StatLine. Update(statLine StatLine) }
ClusterMonitor maintains an internal representation of a cluster's state, which can be refreshed with calls to Update(), and dumps output representing this internal state on an interval.
type ConcurrentTransStats ¶
type ConcurrentTransStats struct {
Out int64 `bson:"out"`
}
type ConcurrentTransactions ¶
type ConcurrentTransactions struct { Write ConcurrentTransStats `bson:"write"` Read ConcurrentTransStats `bson:"read"` }
type ConfigShard ¶
ConfigShard holds a mapping for the format of shard hosts as they appear in the config.shards collection.
type ConnectionStats ¶
type ConnectionStats struct { Current int64 `bson:"current"` Available int64 `bson:"available"` TotalCreated int64 `bson:"totalCreated"` }
ConnectionStats stores information related to incoming database connections.
type DBRecordStats ¶
type DBRecordStats struct { AccessesNotInMemory int64 `bson:"accessesNotInMemory"` PageFaultExceptionsThrown int64 `bson:"pageFaultExceptionsThrown"` DBRecordAccesses map[string]RecordAccesses `bson:",inline"` }
DBRecordStats stores data related to memory operations across databases.
type DurStats ¶
type DurStats struct { Commits int64 `bson:"commits"` JournaledMB int64 `bson:"journaledMB"` WriteToDataFilesMB int64 `bson:"writeToDataFilesMB"` Compression int64 `bson:"compression"` CommitsInWriteLock int64 `bson:"commitsInWriteLock"` EarlyCommits int64 `bson:"earlyCommits"` TimeMs DurTiming }
DurStats stores information related to journaling statistics.
type DurTiming ¶
type DurTiming struct { Dt int64 `bson:"dt"` PrepLogBuffer int64 `bson:"prepLogBuffer"` WriteToJournal int64 `bson:"writeToJournal"` WriteToDataFiles int64 `bson:"writeToDataFiles"` RemapPrivateView int64 `bson:"remapPrivateView"` }
DurTiming stores information related to journaling.
type ExtraInfo ¶
type ExtraInfo struct {
PageFaults *int64 `bson:"page_faults"`
}
ExtraInfo stores additional platform specific information.
type FlushStats ¶
type FlushStats struct { Flushes int64 `bson:"flushes"` TotalMs int64 `bson:"total_ms"` AverageMs float64 `bson:"average_ms"` LastMs int64 `bson:"last_ms"` LastFinished time.Time `bson:"last_finished"` }
FlushStats stores information about memory flushes.
type GlobalLockStats ¶
type GlobalLockStats struct { TotalTime int64 `bson:"totalTime"` LockTime int64 `bson:"lockTime"` CurrentQueue *QueueStats `bson:"currentQueue"` ActiveClients *ClientStats `bson:"activeClients"` }
GlobalLockStats stores information related locks in the MMAP storage engine.
type GridLineFormatter ¶
type GridLineFormatter struct { // If true, enables printing of headers to output IncludeHeader bool // Number of line outputs to skip between adding in headers HeaderInterval int // Grid writer Writer *text.GridWriter }
Implementation of LineFormatter - uses a common/text.GridWriter to format the StatLines as a grid.
func (*GridLineFormatter) FormatLines ¶
func (glf *GridLineFormatter) FormatLines(lines []StatLine, index int, discover bool) string
Satisfy the LineFormatter interface. Formats the StatLines as a grid.
type JSONLineFormatter ¶
type JSONLineFormatter struct{}
Implementation of LineFormatter - converts the StatLines to JSON.
func (*JSONLineFormatter) FormatLines ¶
func (jlf *JSONLineFormatter) FormatLines(lines []StatLine, index int, discover bool) string
Satisfy the LineFormatter interface. Formats the StatLines as JSON.
type LineFormatter ¶
type LineFormatter interface { // FormatLines returns the string representation of the StatLines that // are passed in. It also takes a bool if cluster discovery is active. FormatLines(lines []StatLine, index int, discover bool) string }
A LineFormatter formats StatLines for printing.
type LockStats ¶
type LockStats struct { TimeLockedMicros ReadWriteLockTimes `bson:"timeLockedMicros"` TimeAcquiringMicros ReadWriteLockTimes `bson:"timeAcquiringMicros"` // AcquireCount is a new field of the lock stats only populated on 3.0 or newer. // Typed as a pointer so that if it is nil, mongostat can assume the field is not populated // with real namespace data. AcquireCount *ReadWriteLockTimes `bson:"acquireCount,omitempty"` }
LockStats stores information related to time spent acquiring/holding locks for a given database.
type LockStatus ¶
LockStatus stores a database's lock statistics.
type MemStats ¶
type MemStats struct { Bits int64 `bson:"bits"` Resident int64 `bson:"resident"` Virtual int64 `bson:"virtual"` Supported interface{} `bson:"supported"` Mapped int64 `bson:"mapped"` MappedWithJournal int64 `bson:"mappedWithJournal"` }
MemStats stores data related to memory statistics.
type MongoStat ¶
type MongoStat struct { // Generic mongo tool options. Options *options.ToolOptions // Mongostat-specific output options. StatOptions *StatOptions // How long to sleep between printing the rows, and polling the server. SleepInterval time.Duration // New nodes can be "discovered" by any other node by sending a hostname // on this channel. Discovered chan string // A map of hostname -> NodeMonitor for all the hosts that // are being monitored. Nodes map[string]*NodeMonitor // ClusterMonitor to manage collecting and printing the stats from all nodes. Cluster ClusterMonitor // contains filtered or unexported fields }
MongoStat is a container for the user-specified options and internal cluster state used for running mongostat.
func (*MongoStat) AddNewNode ¶
AddNewNode adds a new host name to be monitored and spawns the necessary goroutines to collect data from it.
type NamespacedLocks ¶
type NamespacedLocks map[string]LockStatus
NamespacedLocks stores information on the LockStatus of namespaces.
type NetworkStats ¶
type NetworkStats struct { BytesIn int64 `bson:"bytesIn"` BytesOut int64 `bson:"bytesOut"` NumRequests int64 `bson:"numRequests"` }
NetworkStats stores information related to network traffic.
type NodeMonitor ¶
type NodeMonitor struct { // Enable/Disable collection of optional fields. All bool // The previous result of the ServerStatus command used to calculate diffs. LastStatus *ServerStatus // The time at which the node monitor last processed an update successfully. LastUpdate time.Time // The most recent error encountered when collecting stats for this node. Err error // contains filtered or unexported fields }
NodeMonitor contains the connection pool for a single host and collects the mongostat data for that host on a regular interval.
func NewNodeMonitor ¶
func NewNodeMonitor(opts options.ToolOptions, fullHost string, all bool) (*NodeMonitor, error)
NewNodeMonitor copies the same connection settings from an instance of ToolOptions, but monitors fullHost.
func (*NodeMonitor) Poll ¶
func (node *NodeMonitor) Poll(discover chan string, all bool, checkShards bool, sampleSecs int64) *StatLine
Report collects the stat info for a single node, and sends the result on the "out" channel. If it fails, the error is stored in the NodeMonitor Err field.
func (*NodeMonitor) Watch ¶
func (node *NodeMonitor) Watch(sleep time.Duration, discover chan string, cluster ClusterMonitor)
Watch spawns a goroutine to continuously collect and process stats for a single node on a regular interval. At each interval, the goroutine triggers the node's Report function with the 'discover' and 'out' channels.
type OpcountStats ¶
type OpcountStats struct { Insert int64 `bson:"insert"` Query int64 `bson:"query"` Update int64 `bson:"update"` Delete int64 `bson:"delete"` GetMore int64 `bson:"getmore"` Command int64 `bson:"command"` }
OpcountStats stores information related to comamnds and basic CRUD operations.
type QueueStats ¶
type QueueStats struct { Total int64 `bson:"total"` Readers int64 `bson:"readers"` Writers int64 `bson:"writers"` }
QueueStats stores the number of queued read/write operations.
type ReadWriteLockTimes ¶
type ReadWriteLockTimes struct { Read int64 `bson:"R"` Write int64 `bson:"W"` ReadLower int64 `bson:"r"` WriteLower int64 `bson:"w"` }
ReadWriteLockTimes stores time spent holding read/write locks.
type RecordAccesses ¶
type RecordAccesses struct { AccessesNotInMemory int64 `bson:"accessesNotInMemory"` PageFaultExceptionsThrown int64 `bson:"pageFaultExceptionsThrown"` }
RecordAccesses stores data related to memory operations scoped to a database.
type ReplStatus ¶
type ReplStatus struct { SetName interface{} `bson:"setName"` IsMaster interface{} `bson:"ismaster"` Secondary interface{} `bson:"secondary"` IsReplicaSet interface{} `bson:"isreplicaset"` ArbiterOnly interface{} `bson:"arbiterOnly"` Hosts []string `bson:"hosts"` Passives []string `bson:"passives"` Me string `bson:"me"` }
ReplStatus stores data related to replica sets.
type ServerStatus ¶
type ServerStatus struct { SampleTime time.Time `bson:""` Host string `bson:"host"` Version string `bson:"version"` Process string `bson:"process"` Pid int64 `bson:"pid"` Uptime int64 `bson:"uptime"` UptimeMillis int64 `bson:"uptimeMillis"` UptimeEstimate int64 `bson:"uptimeEstimate"` LocalTime time.Time `bson:"localTime"` Asserts map[string]int64 `bson:"asserts"` BackgroundFlushing *FlushStats `bson:"backgroundFlushing"` ExtraInfo *ExtraInfo `bson:"extra_info"` Connections *ConnectionStats `bson:"connections"` Dur *DurStats `bson:"dur"` GlobalLock *GlobalLockStats `bson:"globalLock"` Locks map[string]LockStats `bson:"locks,omitempty"` Network *NetworkStats `bson:"network"` Opcounters *OpcountStats `bson:"opcounters"` OpcountersRepl *OpcountStats `bson:"opcountersRepl"` RecordStats *DBRecordStats `bson:"recordStats"` Mem *MemStats `bson:"mem"` Repl *ReplStatus `bson:"repl"` ShardCursorType map[string]interface{} `bson:"shardCursorType"` StorageEngine map[string]string `bson:"storageEngine"` WiredTiger *WiredTiger `bson:"wiredTiger"` }
type StatHeader ¶
type StatHeader struct { // The text to appear in the column's header cell HeaderText string // Bitmask containing flags to determine if this header is active or not ActivateFlags int }
StatHeader describes a single column for mongostat's terminal output, its formatting, and in which modes it should be displayed.
type StatLine ¶
type StatLine struct { Key string // What storage engine is being used for the node with this stat line StorageEngine string Error error IsMongos bool Host string // The time at which this StatLine was generated. Time time.Time // The last time at which this StatLine was printed to output. LastPrinted time.Time // Opcounter fields Insert, Query, Update, Delete, GetMore, Command int64 // Cache utilization (wiredtiger only) CacheDirtyPercent float64 CacheUsedPercent float64 // Replicated Opcounter fields InsertR, QueryR, UpdateR, DeleteR, GetMoreR, CommandR int64 Flushes int64 Mapped, Virtual, Resident, NonMapped int64 Faults int64 HighestLocked *LockStatus QueuedReaders, QueuedWriters int64 ActiveReaders, ActiveWriters int64 NetIn, NetOut int64 NumConnections int64 ReplSetName string NodeType string }
StatLine is a wrapper for all metrics reported by mongostat for monitored hosts.
func NewStatLine ¶
func NewStatLine(oldStat, newStat ServerStatus, key string, all bool, sampleSecs int64) *StatLine
NewStatLine constructs a StatLine object from two ServerStatus objects.
type StatOptions ¶
type StatOptions struct { NoHeaders bool `long:"noheaders" description:"don't output column names"` RowCount int `long:"rowcount" short:"n" description:"number of stats lines to print (0 for indefinite)"` Discover bool `long:"discover" description:"discover nodes and display stats for all"` Http bool `long:"http" description:"use HTTP instead of raw db connection"` All bool `long:"all" description:"all optional fields"` Json bool `long:"json" description:"output as JSON rather than a formatted table"` }
StatOptions defines the set of options to use for configuring mongostat.
func (*StatOptions) Name ¶
func (_ *StatOptions) Name() string
Name returns a human-readable group name for mongostat options.
type SyncClusterMonitor ¶
type SyncClusterMonitor struct { // Channel to listen for incoming stat data. ReportChan chan StatLine // Used to format the StatLines for printing. Formatter LineFormatter }
SyncClusterMonitor is an implementation of ClusterMonitor that writes output synchronized with the timing of when the polling samples are collected. Only works with a single host at a time.
func (*SyncClusterMonitor) Monitor ¶
func (cluster *SyncClusterMonitor) Monitor(maxRows int, done chan error, sleep time.Duration, _ string)
Monitor waits for data on the cluster's report channel. Once new data comes in, it formats and then displays it to stdout.
func (*SyncClusterMonitor) Update ¶
func (cluster *SyncClusterMonitor) Update(statLine StatLine)
Update refreshes the internal state of the cluster monitor with the data in the StatLine. SyncClusterMonitor's implementation of Update blocks until it has written out its state, so that output is always dumped exactly once for each poll.
type TransactionStats ¶
type TransactionStats struct {
TransCheckpoints int64 `bson:"transaction checkpoints"`
}
TransactionStats stores transaction checkpoints in WiredTiger.
type WiredTiger ¶
type WiredTiger struct { Transaction TransactionStats `bson:"transaction"` Concurrent ConcurrentTransactions `bson:"concurrentTransactions"` Cache CacheStats `bson:"cache"` }
WiredTiger stores information related to the WiredTiger storage engine.