diff options
author | Sam Helman <sam.helman@10gen.com> | 2014-11-06 14:12:15 -0500 |
---|---|---|
committer | Sam Helman <sam.helman@10gen.com> | 2014-11-06 14:13:10 -0500 |
commit | ce252c168f0f2bbb3f45f269d3c76f6bd9d09292 (patch) | |
tree | 814b9243065c38fe6f34062a863932bec51aec33 | |
parent | ca4415aefd056d1d961a7b0668482cd2c340a453 (diff) | |
download | mongo-ce252c168f0f2bbb3f45f269d3c76f6bd9d09292.tar.gz |
TOOLS-342: display warning message if running mongostat against wiredtiger storage engine
Former-commit-id: 57e635ce7a99ef2700bb24e3454a7d8202dfc5fa
-rw-r--r-- | mongostat/main/mongostat.go | 1 | ||||
-rw-r--r-- | mongostat/mongostat.go | 23 |
2 files changed, 21 insertions, 3 deletions
diff --git a/mongostat/main/mongostat.go b/mongostat/main/mongostat.go index 891603bc1fc..f022c330692 100644 --- a/mongostat/main/mongostat.go +++ b/mongostat/main/mongostat.go @@ -74,6 +74,7 @@ func main() { ReportChan: make(chan mongostat.StatLine), LastStatLines: map[string]*mongostat.StatLine{}, NoHeaders: statOpts.NoHeaders, + UseJson: statOpts.Json, }, } diff --git a/mongostat/mongostat.go b/mongostat/mongostat.go index 1635b66c4b5..33a7937a63c 100644 --- a/mongostat/mongostat.go +++ b/mongostat/mongostat.go @@ -82,13 +82,16 @@ type ClusterMonitor struct { //Mutex to protect access to LastStatLines and LastPollTimes mapLock sync.Mutex + //Whether or not json is being used for the output + UseJson bool + //Used to format the StatLines for printing formatter LineFormatter } //initialize the formatter that will be used -func (cluster *ClusterMonitor) initializeFormatter(useJson bool) { - if useJson { +func (cluster *ClusterMonitor) initializeFormatter() { + if cluster.UseJson { cluster.formatter = &JSONLineFormatter{} } else { cluster.formatter = &GridLineFormatter{} @@ -120,6 +123,20 @@ func (cluster *ClusterMonitor) printSnapshot(includeHeaders bool, discover bool) for _, stat := range cluster.LastStatLines { stat.LastPrinted = stat.Time } + + //If this is the beginning of execution and any of the stat lines are + //using wired tiger as the storage engine, print an appropriate + //warning message + if includeHeaders && !cluster.UseJson { + for _, stat := range cluster.LastStatLines { + if stat.StorageEngine == "wiredtiger" { + fmt.Printf("Warning: not all columns will apply to mongods" + + " running wiredtiger storage engine\n") + break + } + } + } + fmt.Print(out) } @@ -280,7 +297,7 @@ func (mstat *MongoStat) AddNewNode(fullhost string) { func (mstat *MongoStat) Run() error { // initialize the correct formatter for the data - mstat.Cluster.initializeFormatter(mstat.StatOptions.Json) + mstat.Cluster.initializeFormatter() if mstat.Discovered != nil { go func() { |