From 99e8324ae6cc0c84dd9ced4486b4d7b6c049790c Mon Sep 17 00:00:00 2001 From: Simon J Mudd Date: Sun, 14 Dec 2014 18:20:32 +0100 Subject: [PATCH] Adjust to highlight headings and totals --- i_s/pl_by_user.go | 4 ++-- p_s/file_summary_by_instance/file_summary_by_instance.go | 2 +- .../file_summary_by_instance_row.go | 10 ++++------ .../table_io_waits_summary_by_table_row.go | 8 ++++---- .../table_lock_waits_summary_by_table_row.go | 6 +++--- screen/screen.go | 12 ++++++++++++ state/state.go | 16 ++++++++-------- 7 files changed, 34 insertions(+), 24 deletions(-) diff --git a/i_s/pl_by_user.go b/i_s/pl_by_user.go index ae5b4aa..576045b 100644 --- a/i_s/pl_by_user.go +++ b/i_s/pl_by_user.go @@ -43,7 +43,7 @@ xxxxxxxxxxxxxx|hh:mm:ss 100.0%|9999 9999|9999 999|100.0% 100.0% 100.0% 100.0% 1 func (r *pl_by_user_row) headings() string { return fmt.Sprintf("%-14s|%10s %6s|%4s %4s|%5s %3s|%6s %6s %6s %6s %6s|", - "username", "Run Time", "%", "Conn", "Actv", "Hosts", "DBs", "Select", "Insert", "Update", "Delete", "Other") + "User", "Run Time", "%", "Conn", "Actv", "Hosts", "DBs", "Select", "Insert", "Update", "Delete", "Other") } // generate a printable result @@ -74,7 +74,7 @@ func (r *pl_by_user_row) row_content(totals pl_by_user_row) string { // generate a row of totals from a table func (t pl_by_user_rows) totals() pl_by_user_row { var totals pl_by_user_row - totals.username = "TOTALS" + totals.username = "Totals" for i := range t { totals.runtime += t[i].runtime diff --git a/p_s/file_summary_by_instance/file_summary_by_instance.go b/p_s/file_summary_by_instance/file_summary_by_instance.go index c1e402e..7a8f2d8 100644 --- a/p_s/file_summary_by_instance/file_summary_by_instance.go +++ b/p_s/file_summary_by_instance/file_summary_by_instance.go @@ -141,7 +141,7 @@ func (t File_summary_by_instance) EmptyRowContent() string { func (t File_summary_by_instance) Description() string { count := t.count_rows() - return fmt.Sprintf("File I/O by filename (file_summary_by_instance) %4d row(s) ", count) + return fmt.Sprintf("I/O Latency by File (file_summary_by_instance) %4d row(s) ", count) } // create a new structure and include various variable values: diff --git a/p_s/file_summary_by_instance/file_summary_by_instance_row.go b/p_s/file_summary_by_instance/file_summary_by_instance_row.go index 711b742..2050c61 100644 --- a/p_s/file_summary_by_instance/file_summary_by_instance_row.go +++ b/p_s/file_summary_by_instance/file_summary_by_instance_row.go @@ -103,7 +103,7 @@ func (r *file_summary_by_instance_row) pretty_name() string { if len(s) > 30 { s = s[:29] } - return fmt.Sprintf("%-30s", s) + return s } func (r *file_summary_by_instance_row) headings() string { @@ -124,14 +124,12 @@ func (r *file_summary_by_instance_row) headings() string { // generate a printable result func (row *file_summary_by_instance_row) row_content(totals file_summary_by_instance_row) string { - var name string + var name string = row.pretty_name() // We assume that if COUNT_STAR = 0 then there's no data at all... // when we have no data we really don't want to show the name either. - if row.COUNT_STAR == 0 { + if row.COUNT_STAR == 0 && name != "Totals" { name = "" - } else { - name = row.pretty_name() } return fmt.Sprintf("%-30s %10s %6s|%6s %6s %6s|%8s %8s|%8s %6s %6s %6s", @@ -182,7 +180,7 @@ func (this *file_summary_by_instance_row) subtract(other file_summary_by_instanc // return the totals of a slice of rows func (t file_summary_by_instance_rows) totals() file_summary_by_instance_row { var totals file_summary_by_instance_row - totals.FILE_NAME = "TOTALS" + totals.FILE_NAME = "Totals" for i := range t { totals.add(t[i]) diff --git a/p_s/table_io_waits_summary_by_table/table_io_waits_summary_by_table_row.go b/p_s/table_io_waits_summary_by_table/table_io_waits_summary_by_table_row.go index 2551e0d..5d52b60 100644 --- a/p_s/table_io_waits_summary_by_table/table_io_waits_summary_by_table_row.go +++ b/p_s/table_io_waits_summary_by_table/table_io_waits_summary_by_table_row.go @@ -62,7 +62,7 @@ func (r *table_io_waits_summary_by_table_row) pretty_name() string { if len(s) > 30 { s = s[:29] } - return fmt.Sprintf("%-30s", s) + return s } func (r *table_io_waits_summary_by_table_row) latency_headings() string { @@ -76,7 +76,7 @@ func (r *table_io_waits_summary_by_table_row) ops_headings() string { func (r *table_io_waits_summary_by_table_row) latency_row_content(totals table_io_waits_summary_by_table_row) string { // assume the data is empty so hide it. name := r.pretty_name() - if r.COUNT_STAR == 0 { + if r.COUNT_STAR == 0 && name != "Totals" { name = "" } @@ -94,7 +94,7 @@ func (r *table_io_waits_summary_by_table_row) latency_row_content(totals table_i func (r *table_io_waits_summary_by_table_row) ops_row_content(totals table_io_waits_summary_by_table_row) string { // assume the data is empty so hide it. name := r.pretty_name() - if r.COUNT_STAR == 0 { + if r.COUNT_STAR == 0 && name != "Totals" { name = "" } @@ -155,7 +155,7 @@ func (this *table_io_waits_summary_by_table_row) subtract(other table_io_waits_s func (t table_io_waits_summary_by_table_rows) totals() table_io_waits_summary_by_table_row { var totals table_io_waits_summary_by_table_row - totals.OBJECT_SCHEMA = "TOTALS" + totals.OBJECT_SCHEMA = "Totals" for i := range t { totals.add(t[i]) diff --git a/p_s/table_lock_waits_summary_by_table/table_lock_waits_summary_by_table_row.go b/p_s/table_lock_waits_summary_by_table/table_lock_waits_summary_by_table_row.go index 01dda25..006e094 100644 --- a/p_s/table_lock_waits_summary_by_table/table_lock_waits_summary_by_table_row.go +++ b/p_s/table_lock_waits_summary_by_table/table_lock_waits_summary_by_table_row.go @@ -140,7 +140,7 @@ func (r *table_lock_waits_summary_by_table_row) pretty_name() string { if len(s) > 30 { s = s[:29] } - return fmt.Sprintf("%-30s", s) + return s } // Table Name Latency %| Read Write|S.Lock High NoIns Normal Extrnl|AlloWr CncIns WrtDly Low Normal Extrnl| @@ -158,7 +158,7 @@ func (r *table_lock_waits_summary_by_table_row) row_content(totals table_lock_wa // assume the data is empty so hide it. name := r.pretty_name() - if r.COUNT_STAR == 0 { + if r.COUNT_STAR == 0 && name != "Totals" { name = "" } @@ -218,7 +218,7 @@ func (this *table_lock_waits_summary_by_table_row) subtract(other table_lock_wai // return the totals of a slice of rows func (t table_lock_waits_summary_by_table_rows) totals() table_lock_waits_summary_by_table_row { var totals table_lock_waits_summary_by_table_row - totals.OBJECT_SCHEMA = "TOTALS" + totals.OBJECT_SCHEMA = "Totals" for i := range t { totals.add(t[i]) diff --git a/screen/screen.go b/screen/screen.go index 9266ad8..f428da8 100644 --- a/screen/screen.go +++ b/screen/screen.go @@ -78,6 +78,18 @@ func (s *TermboxScreen) PrintAt(x int, y int, text string) { s.Flush() } +// print the characters in bold (for headings) but don't print them outside the screen +func (s *TermboxScreen) BoldPrintAt(x int, y int, text string) { + offset := 0 + for c := range text { + if (x + offset) < s.width { + termbox.SetCell(x+offset, y, rune(text[c]), s.fg | termbox.AttrBold, s.bg) + offset++ + } + } + s.Flush() +} + func (s *TermboxScreen) DisplayHelp() { s.PrintAt(0, 0, lib.MyName()+" version "+version.Version()+" (C) 2014 Simon J Mudd ") diff --git a/state/state.go b/state/state.go index 682fb1c..124b884 100644 --- a/state/state.go +++ b/state/state.go @@ -261,7 +261,7 @@ func (state State) displayDescription() { } 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) @@ -280,12 +280,12 @@ func (state *State) displayOpsOrLatency() { } // 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 @@ -305,11 +305,11 @@ func (state State) displayIO() { } // 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 @@ -329,11 +329,11 @@ func (state *State) displayLocks() { } // 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 @@ -353,7 +353,7 @@ func (state *State) displayUsers() { } // 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? -- 2.7.4