X-Git-Url: http://git.iain.cx/?a=blobdiff_plain;f=i_s%2Fpl_by_user.go;h=f5bd83ff042e63ef317011d91bc2a4175c2483a5;hb=d38bc6ef7c4b5a914e5c3e492c1efdc84944fbd1;hp=9ad2c8d60311424bc5cf882ce989bd35b9721e36;hpb=52d3c00ce729f908f342e10f48818b112dec0130;p=pstop.git diff --git a/i_s/pl_by_user.go b/i_s/pl_by_user.go index 9ad2c8d..f5bd83f 100644 --- a/i_s/pl_by_user.go +++ b/i_s/pl_by_user.go @@ -42,8 +42,8 @@ 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|%5s %4s|%4s %3s|%6s %6s %6s %6s %6s|", - "username", "Run Time", "%", "Conn", "Actv", "Hosts", "DBs", "Select", "Insert", "Update", "Delete", "Other") + return fmt.Sprintf("%-14s|%10s %6s|%4s %4s|%5s %3s|%6s %6s %6s %6s %6s|", + "User", "Run Time", "%", "Conn", "Actv", "Hosts", "DBs", "Select", "Insert", "Update", "Delete", "Other") } // generate a printable result @@ -56,7 +56,7 @@ func (r *pl_by_user_row) row_content(totals pl_by_user_row) string { } else { u = r.username } - return fmt.Sprintf("%-14s|%10s %6s|%5s %4s|%4s %3s|%6s %6s %6s %6s %6s|", + return fmt.Sprintf("%-14s|%10s %6s|%4s %4s|%5s %3s|%6s %6s %6s %6s %6s|", u, lib.FormatTime(r.runtime), lib.FormatPct(lib.MyDivide(r.runtime, totals.runtime)), @@ -74,14 +74,14 @@ 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 totals.connections += t[i].connections totals.active += t[i].active - // totals.hosts += t[i].hosts This needs to be done differently to get the total number of distinct hosts - // totals.dbs += t[i].dbs This needs to be done differently to get the total number of distinct dbs + // totals.hosts += t[i].hosts This needs to be done differently to get the total number of distinct hosts + // totals.dbs += t[i].dbs This needs to be done differently to get the total number of distinct dbs totals.selects += t[i].selects totals.inserts += t[i].inserts totals.updates += t[i].updates @@ -118,17 +118,14 @@ func (t ByRunTime) Len() int { return len(t) } func (t ByRunTime) Swap(i, j int) { t[i], t[j] = t[j], t[i] } func (t ByRunTime) Less(i, j int) bool { return (t[i].runtime > t[j].runtime) || - ((t[i].runtime == t[j].runtime) && (t[i].connections > t[j].connections)) + ((t[i].runtime == t[j].runtime) && (t[i].connections > t[j].connections)) || + ((t[i].runtime == t[j].runtime) && (t[i].connections == t[j].connections) && (t[i].username < t[j].username)) } func (t pl_by_user_rows) Sort() { sort.Sort(ByRunTime(t)) } -func (r pl_by_user_row) Description() string { - return "no description" -} - func (t pl_by_user_rows) emptyRowContent() string { var r pl_by_user_row return r.row_content(r)