"github.com/sjmudd/pstop/lib"
fsbi "github.com/sjmudd/pstop/p_s/file_summary_by_instance"
"github.com/sjmudd/pstop/p_s/ps_table"
+ "github.com/sjmudd/pstop/wait_info"
tiwsbt "github.com/sjmudd/pstop/p_s/table_io_waits_summary_by_table"
tlwsbt "github.com/sjmudd/pstop/p_s/table_lock_waits_summary_by_table"
"github.com/sjmudd/pstop/screen"
)
type State struct {
+ finished bool
datadir string
dbh *sql.DB
help bool
show Show
mysql_version string
want_relative_stats bool
+ wait_info.WaitInfo // embedded
}
func (state *State) Setup(dbh *sql.DB) {
state.dbh = dbh
+ state.finished = false
state.screen.Initialise()
state.SetDatadir(datadir)
}
+// have we finished ?
+func (state State) Finished() bool {
+ return state.finished
+}
+
+// indicate we have finished
+func (state *State) SetFinished() {
+ state.finished = true
+}
+
// do a fresh collection of data and then update the initial values based on that.
func (state *State) ResetDBStatistics() {
state.CollectAll()
return state.help
}
+// states go: showLatency -> showOps -> showIO -> showLocks -> showUsers
+
// display the output according to the mode we are in
func (state *State) Display() {
if state.help {
}
}
+// fix_latency_setting() ensures the SetWantsLatency() value is
+// correct. This needs to be done more cleanly.
+func (state *State) fix_latency_setting() {
+ if state.show == showLatency {
+ state.tiwsbt.SetWantsLatency(true)
+ }
+ if state.show == showOps {
+ state.tiwsbt.SetWantsLatency(false)
+ }
+}
+
+// change to the previous display mode
+func (state *State) DisplayPrevious() {
+ if state.show == showLatency {
+ state.show = showUsers
+ } else {
+ state.show--
+ }
+ state.fix_latency_setting()
+ state.screen.Clear()
+ state.screen.Flush()
+}
+
// change to the next display mode
func (state *State) DisplayNext() {
if state.show == showUsers {
} else {
state.show++
}
- // this needs to be done more cleanly
- if state.show == showLatency {
- state.tiwsbt.SetWantsLatency(true)
- }
- if state.show == showOps {
- state.tiwsbt.SetWantsLatency(false)
- }
+ state.fix_latency_setting()
state.screen.Clear()
state.screen.Flush()
}
}
func (state *State) displayOpsOrLatency() {
- state.screen.PrintAt(0, 2, state.tiwsbt.Headings())
+ state.screen.BoldPrintAt(0, 2, state.tiwsbt.Headings())
max_rows := state.screen.Height() - 3
row_content := state.tiwsbt.RowContent(max_rows)
}
// print out the totals at the bottom
- state.screen.PrintAt(0, state.screen.Height()-1, state.tiwsbt.TotalRowContent())
+ state.screen.BoldPrintAt(0, state.screen.Height()-1, state.tiwsbt.TotalRowContent())
}
// show actual I/O latency values
func (state State) displayIO() {
- state.screen.PrintAt(0, 2, state.fsbi.Headings())
+ state.screen.BoldPrintAt(0, 2, state.fsbi.Headings())
// print out the data
max_rows := state.screen.Height() - 3
}
// print out the totals at the bottom
- state.screen.PrintAt(0, state.screen.Height()-1, state.fsbi.TotalRowContent())
+ state.screen.BoldPrintAt(0, state.screen.Height()-1, state.fsbi.TotalRowContent())
}
func (state *State) displayLocks() {
- state.screen.PrintAt(0, 2, state.tlwsbt.Headings())
+ state.screen.BoldPrintAt(0, 2, state.tlwsbt.Headings())
// print out the data
max_rows := state.screen.Height() - 3
}
// print out the totals at the bottom
- state.screen.PrintAt(0, state.screen.Height()-1, state.tlwsbt.TotalRowContent())
+ state.screen.BoldPrintAt(0, state.screen.Height()-1, state.tlwsbt.TotalRowContent())
}
func (state *State) displayUsers() {
- state.screen.PrintAt(0, 2, state.users.Headings())
+ state.screen.BoldPrintAt(0, 2, state.users.Headings())
// print out the data
max_rows := state.screen.Height() - 3
}
// print out the totals at the bottom
- state.screen.PrintAt(0, state.screen.Height()-1, state.users.TotalRowContent())
+ state.screen.BoldPrintAt(0, state.screen.Height()-1, state.users.TotalRowContent())
}
// do we want to show all p_s data?