From e3fd1b9dbeba43a1776fd2eba755255bf9b5307a Mon Sep 17 00:00:00 2001 From: Oleg Gurov Date: Sun, 27 Jan 2019 22:01:28 +0300 Subject: [PATCH 1/4] pghrep: added RawIntFormat func --- pghrep/src/fmtutils/utils.go | 31 +++++++++++++++++++++++++++++++ pghrep/src/main.go | 1 + pghrep/src/reportutils.go | 5 +++++ pghrep/templates/K003.tpl | 24 ++++++++++++------------ 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/pghrep/src/fmtutils/utils.go b/pghrep/src/fmtutils/utils.go index 1ce484d..26414cf 100644 --- a/pghrep/src/fmtutils/utils.go +++ b/pghrep/src/fmtutils/utils.go @@ -118,4 +118,35 @@ func GetUnit(unit string) int64 { } value = intval * factor return value +} + +func RawIntFormat(v int64) string { + sign := "" + + // Min int64 can't be negated to a usable value, so it has to be special cased. + if v == math.MinInt64 { + return "-9,223,372,036,854,775,808" + } + + if v < 0 { + sign = "-" + v = 0 - v + } + + parts := []string{"", "", "", "", "", "", ""} + j := len(parts) - 1 + + for v > 999 { + parts[j] = strconv.FormatInt(v%1000, 10) + switch len(parts[j]) { + case 2: + parts[j] = "0" + parts[j] + case 1: + parts[j] = "00" + parts[j] + } + v = v / 1000 + j-- + } + parts[j] = strconv.Itoa(int(v)) + return sign + strings.Join(parts[j:], ",") } \ No newline at end of file diff --git a/pghrep/src/main.go b/pghrep/src/main.go index e2b23b4..5231ffe 100644 --- a/pghrep/src/main.go +++ b/pghrep/src/main.go @@ -164,6 +164,7 @@ func loadTemplates() *template.Template { tplFuncMap["Mul"] = Mul tplFuncMap["Div"] = Div tplFuncMap["NumFormat"] = NumFormat + tplFuncMap["RawIntFormat"] = RawIntFormat tplFuncMap["MsFormat"] = MsFormat tplFuncMap["DtFormat"] = DtFormat templates, err = template.New("").Funcs(tplFuncMap).ParseFiles(allFiles...) diff --git a/pghrep/src/reportutils.go b/pghrep/src/reportutils.go index 1ec7443..1bcfcb6 100644 --- a/pghrep/src/reportutils.go +++ b/pghrep/src/reportutils.go @@ -149,4 +149,9 @@ func DtFormat(value interface{}) string { return t.String() } return val +} + +func RawIntFormat(value interface{}) string { + val := pyraconv.ToInt64(value) + return fmtutils.RawIntFormat(val) } \ No newline at end of file diff --git a/pghrep/templates/K003.tpl b/pghrep/templates/K003.tpl index 066d563..21e8631 100644 --- a/pghrep/templates/K003.tpl +++ b/pghrep/templates/K003.tpl @@ -16,13 +16,13 @@ Error (total time): {{ NumFormat (index (index (index .results .hosts.master) "d {{ range $i, $key := (index (index (index (index .results .hosts.master) "data") "queries") "_keys") }} {{- $value := (index (index (index (index $.results $.hosts.master) "data") "queries") $key) -}} {{- $key}} | -{{- NumFormat $value.diff_calls 2 }}
{{ NumFormat $value.per_sec_calls 2 }}/sec
{{ NumFormat $value.per_call_calls 2 }}/call
{{ NumFormat $value.ratio_calls 2 }}% | +{{- RawIntFormat $value.diff_calls }}
{{ NumFormat $value.per_sec_calls 2 }}/sec
{{ NumFormat $value.per_call_calls 2 }}/call
{{ NumFormat $value.ratio_calls 2 }}% | {{- MsFormat $value.diff_total_time }}
{{ MsFormat $value.per_sec_total_time }}/sec
{{ MsFormat $value.per_call_total_time }}/call
{{ NumFormat $value.ratio_total_time 2 }}% | -{{- NumFormat $value.diff_rows 2 }}
{{ NumFormat $value.per_sec_rows 2 }}/sec
{{ NumFormat $value.per_call_rows 2 }}/call
{{ NumFormat $value.ratio_rows 2 }}% | -{{- NumFormat $value.diff_shared_blks_hit 2 }} blks
{{ NumFormat $value.per_sec_shared_blks_hit 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_hit 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_hit 2 }}% | -{{- NumFormat $value.diff_shared_blks_read 2 }} blks
{{ NumFormat $value.per_sec_shared_blks_read 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_read 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_read 2 }}% | -{{- NumFormat $value.diff_shared_blks_dirtied 2 }} blks
{{ NumFormat $value.per_sec_shared_blks_dirtied 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_dirtied 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_dirtied 2 }}% | -{{- NumFormat $value.diff_shared_blks_written 2 }} blks
{{ NumFormat $value.per_sec_shared_blks_written 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_written 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_written 2 }}% | +{{- RawIntFormat $value.diff_rows }}
{{ NumFormat $value.per_sec_rows 2 }}/sec
{{ NumFormat $value.per_call_rows 2 }}/call
{{ NumFormat $value.ratio_rows 2 }}% | +{{- RawIntFormat $value.diff_shared_blks_hit }} blks
{{ NumFormat $value.per_sec_shared_blks_hit 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_hit 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_hit 2 }}% | +{{- RawIntFormat $value.diff_shared_blks_read }} blks
{{ NumFormat $value.per_sec_shared_blks_read 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_read 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_read 2 }}% | +{{- RawIntFormat $value.diff_shared_blks_dirtied }} blks
{{ NumFormat $value.per_sec_shared_blks_dirtied 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_dirtied 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_dirtied 2 }}% | +{{- RawIntFormat $value.diff_shared_blks_written }} blks
{{ NumFormat $value.per_sec_shared_blks_written 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_written 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_written 2 }}% | {{- MsFormat $value.diff_blk_read_time }}
{{ MsFormat $value.per_sec_blk_read_time }}/sec
{{ MsFormat $value.per_call_blk_read_time }}/call
{{ NumFormat $value.ratio_blk_read_time 2 }}% | {{- MsFormat $value.diff_blk_write_time }}
{{ MsFormat $value.per_sec_blk_write_time }}/sec
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ NumFormat $value.ratio_blk_write_time 2 }}% | {{- NumFormat $value.diff_kcache_reads 2 }} bytes
{{ NumFormat $value.per_sec_kcache_reads 2 }} bytes/sec
{{ NumFormat $value.per_call_kcache_reads 2 }} bytes/call
{{ NumFormat $value.ratio_kcache_reads 2 }}% | @@ -50,13 +50,13 @@ Period age: {{ (index (index (index $.results $host) "data") "period_age") }} {{ range $i, $key := (index (index (index (index $.results $host) "data") "queries") "_keys") }} {{- $value := (index (index (index (index $.results $host) "data") "queries") $key) -}} {{- $key}} | -{{- NumFormat $value.diff_calls 2 }}
{{ NumFormat $value.per_sec_calls 2 }}/sec
{{ NumFormat $value.per_call_calls 2 }}/call
{{ NumFormat $value.ratio_calls 2 }}% | +{{- RawIntFormat $value.diff_calls }}
{{ NumFormat $value.per_sec_calls 2 }}/sec
{{ NumFormat $value.per_call_calls 2 }}/call
{{ NumFormat $value.ratio_calls 2 }}% | {{- MsFormat $value.diff_total_time }}
{{ MsFormat $value.per_sec_total_time }}/sec
{{ MsFormat $value.per_call_total_time }}/call
{{ NumFormat $value.ratio_total_time 2 }}% | -{{- NumFormat $value.diff_rows 2 }}
{{ NumFormat $value.per_sec_rows 2 }}/sec
{{ NumFormat $value.per_call_rows 2 }}/call
{{ NumFormat $value.ratio_rows 2 }}% | -{{- NumFormat $value.diff_shared_blks_hit 2 }} blks
{{ NumFormat $value.per_sec_shared_blks_hit 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_hit 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_hit 2 }}% | -{{- NumFormat $value.diff_shared_blks_read 2 }} blks
{{ NumFormat $value.per_sec_shared_blks_read 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_read 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_read 2 }}% | -{{- NumFormat $value.diff_shared_blks_dirtied 2 }} blks
{{ NumFormat $value.per_sec_shared_blks_dirtied 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_dirtied 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_dirtied 2 }}% | -{{- NumFormat $value.diff_shared_blks_written 2 }} blks
{{ NumFormat $value.per_sec_shared_blks_written 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_written 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_written 2 }}% | +{{- RawIntFormat $value.diff_rows }}
{{ NumFormat $value.per_sec_rows 2 }}/sec
{{ NumFormat $value.per_call_rows 2 }}/call
{{ NumFormat $value.ratio_rows 2 }}% | +{{- RawIntFormat $value.diff_shared_blks_hit }} blks
{{ NumFormat $value.per_sec_shared_blks_hit 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_hit 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_hit 2 }}% | +{{- RawIntFormat $value.diff_shared_blks_read }} blks
{{ NumFormat $value.per_sec_shared_blks_read 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_read 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_read 2 }}% | +{{- RawIntFormat $value.diff_shared_blks_dirtied }} blks
{{ NumFormat $value.per_sec_shared_blks_dirtied 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_dirtied 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_dirtied 2 }}% | +{{- RawIntFormat $value.diff_shared_blks_written }} blks
{{ NumFormat $value.per_sec_shared_blks_written 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_written 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_written 2 }}% | {{- MsFormat $value.diff_blk_read_time }}
{{ MsFormat $value.per_sec_blk_read_time }}/sec
{{ MsFormat $value.per_call_blk_read_time }}/call
{{ NumFormat $value.ratio_blk_read_time 2 }}% | {{- MsFormat $value.diff_blk_write_time }}
{{ MsFormat $value.per_sec_blk_write_time }}/sec
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ NumFormat $value.ratio_blk_write_time 2 }}% | {{- NumFormat $value.diff_kcache_reads 2 }} bytes
{{ NumFormat $value.per_sec_kcache_reads 2 }} bytes/sec
{{ NumFormat $value.per_call_kcache_reads 2 }} bytes/call
{{ NumFormat $value.ratio_kcache_reads 2 }}% | -- GitLab From 9eb1d33123827e931fc0cd164e2d99f2bc43b0f7 Mon Sep 17 00:00:00 2001 From: Oleg Gurov Date: Sun, 27 Jan 2019 22:07:24 +0300 Subject: [PATCH 2/4] pghrep: code formatting --- pghrep/src/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pghrep/src/main.go b/pghrep/src/main.go index 5231ffe..a501f50 100644 --- a/pghrep/src/main.go +++ b/pghrep/src/main.go @@ -164,7 +164,7 @@ func loadTemplates() *template.Template { tplFuncMap["Mul"] = Mul tplFuncMap["Div"] = Div tplFuncMap["NumFormat"] = NumFormat - tplFuncMap["RawIntFormat"] = RawIntFormat + tplFuncMap["RawIntFormat"] = RawIntFormat tplFuncMap["MsFormat"] = MsFormat tplFuncMap["DtFormat"] = DtFormat templates, err = template.New("").Funcs(tplFuncMap).ParseFiles(allFiles...) -- GitLab From 11876405acd8704e315eb2f9955c797e6bf56d07 Mon Sep 17 00:00:00 2001 From: Oleg Gurov Date: Sun, 27 Jan 2019 23:36:16 +0300 Subject: [PATCH 3/4] pghrep: added RawFloatFormat func --- pghrep/src/fmtutils/utils.go | 86 ++++++++++++++++++++++++------------ pghrep/src/main.go | 1 + pghrep/src/reportutils.go | 8 +++- pghrep/templates/K003.tpl | 12 ++--- 4 files changed, 72 insertions(+), 35 deletions(-) diff --git a/pghrep/src/fmtutils/utils.go b/pghrep/src/fmtutils/utils.go index 26414cf..e415736 100644 --- a/pghrep/src/fmtutils/utils.go +++ b/pghrep/src/fmtutils/utils.go @@ -1,6 +1,7 @@ package fmtutils import ( + "bytes" "strings" "strconv" "math" @@ -121,32 +122,61 @@ func GetUnit(unit string) int64 { } func RawIntFormat(v int64) string { - sign := "" - - // Min int64 can't be negated to a usable value, so it has to be special cased. - if v == math.MinInt64 { - return "-9,223,372,036,854,775,808" - } - - if v < 0 { - sign = "-" - v = 0 - v - } - - parts := []string{"", "", "", "", "", "", ""} - j := len(parts) - 1 - - for v > 999 { - parts[j] = strconv.FormatInt(v%1000, 10) - switch len(parts[j]) { - case 2: - parts[j] = "0" + parts[j] - case 1: - parts[j] = "00" + parts[j] - } - v = v / 1000 - j-- - } - parts[j] = strconv.Itoa(int(v)) - return sign + strings.Join(parts[j:], ",") + sign := "" + + // Min int64 can't be negated to a usable value, so it has to be special cased. + if v == math.MinInt64 { + return "-9,223,372,036,854,775,808" + } + + if v < 0 { + sign = "-" + v = 0 - v + } + + parts := []string{"", "", "", "", "", "", ""} + j := len(parts) - 1 + + for v > 999 { + parts[j] = strconv.FormatInt(v%1000, 10) + switch len(parts[j]) { + case 2: + parts[j] = "0" + parts[j] + case 1: + parts[j] = "00" + parts[j] + } + v = v / 1000 + j-- + } + parts[j] = strconv.Itoa(int(v)) + return sign + strings.Join(parts[j:], ",") +} + +func RawFloatFormat(v float64, precision int) string { + buf := &bytes.Buffer{} + if v < 0 { + buf.Write([]byte{'-'}) + v = 0 - v + } + + comma := []byte{','} + + parts := strings.Split(strconv.FormatFloat(v, 'f', precision, 64), ".") + pos := 0 + if len(parts[0])%3 != 0 { + pos += len(parts[0]) % 3 + buf.WriteString(parts[0][:pos]) + buf.Write(comma) + } + for ; pos < len(parts[0]); pos += 3 { + buf.WriteString(parts[0][pos : pos+3]) + buf.Write(comma) + } + buf.Truncate(buf.Len() - 1) + + if len(parts) > 1 { + buf.Write([]byte{'.'}) + buf.WriteString(parts[1]) + } + return buf.String() } \ No newline at end of file diff --git a/pghrep/src/main.go b/pghrep/src/main.go index a501f50..53de8fe 100644 --- a/pghrep/src/main.go +++ b/pghrep/src/main.go @@ -166,6 +166,7 @@ func loadTemplates() *template.Template { tplFuncMap["NumFormat"] = NumFormat tplFuncMap["RawIntFormat"] = RawIntFormat tplFuncMap["MsFormat"] = MsFormat + tplFuncMap["RawFloatFormat"] = RawFloatFormat tplFuncMap["DtFormat"] = DtFormat templates, err = template.New("").Funcs(tplFuncMap).ParseFiles(allFiles...) if err != nil { diff --git a/pghrep/src/reportutils.go b/pghrep/src/reportutils.go index 1bcfcb6..5d3e23a 100644 --- a/pghrep/src/reportutils.go +++ b/pghrep/src/reportutils.go @@ -127,7 +127,7 @@ func Sub(a int, b int) int { func MsFormat(value interface{}) string { val := pyraconv.ToInt64(value) - tm, _ := time.ParseDuration(strconv.FormatInt(val, 10) + "ms") + tm, _ := time.ParseDuration(strconv.FormatInt(val, 10) + " ms") return tm.String() } @@ -154,4 +154,10 @@ func DtFormat(value interface{}) string { func RawIntFormat(value interface{}) string { val := pyraconv.ToInt64(value) return fmtutils.RawIntFormat(val) +} + +func RawFloatFormat(value interface{}, places interface{}) string { + val := pyraconv.ToFloat64(value) + pl := pyraconv.ToInt64(places) + return fmtutils.RawFloatFormat(val, int(pl)) } \ No newline at end of file diff --git a/pghrep/templates/K003.tpl b/pghrep/templates/K003.tpl index 21e8631..9f7f0ca 100644 --- a/pghrep/templates/K003.tpl +++ b/pghrep/templates/K003.tpl @@ -17,14 +17,14 @@ Error (total time): {{ NumFormat (index (index (index .results .hosts.master) "d {{- $value := (index (index (index (index $.results $.hosts.master) "data") "queries") $key) -}} {{- $key}} | {{- RawIntFormat $value.diff_calls }}
{{ NumFormat $value.per_sec_calls 2 }}/sec
{{ NumFormat $value.per_call_calls 2 }}/call
{{ NumFormat $value.ratio_calls 2 }}% | -{{- MsFormat $value.diff_total_time }}
{{ MsFormat $value.per_sec_total_time }}/sec
{{ MsFormat $value.per_call_total_time }}/call
{{ NumFormat $value.ratio_total_time 2 }}% | +{{- RawFloatFormat $value.diff_total_time 2 }} ms
{{ MsFormat $value.per_sec_total_time }}/sec
{{ MsFormat $value.per_call_total_time }}/call
{{ NumFormat $value.ratio_total_time 2 }}% | {{- RawIntFormat $value.diff_rows }}
{{ NumFormat $value.per_sec_rows 2 }}/sec
{{ NumFormat $value.per_call_rows 2 }}/call
{{ NumFormat $value.ratio_rows 2 }}% | {{- RawIntFormat $value.diff_shared_blks_hit }} blks
{{ NumFormat $value.per_sec_shared_blks_hit 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_hit 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_hit 2 }}% | {{- RawIntFormat $value.diff_shared_blks_read }} blks
{{ NumFormat $value.per_sec_shared_blks_read 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_read 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_read 2 }}% | {{- RawIntFormat $value.diff_shared_blks_dirtied }} blks
{{ NumFormat $value.per_sec_shared_blks_dirtied 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_dirtied 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_dirtied 2 }}% | {{- RawIntFormat $value.diff_shared_blks_written }} blks
{{ NumFormat $value.per_sec_shared_blks_written 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_written 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_written 2 }}% | -{{- MsFormat $value.diff_blk_read_time }}
{{ MsFormat $value.per_sec_blk_read_time }}/sec
{{ MsFormat $value.per_call_blk_read_time }}/call
{{ NumFormat $value.ratio_blk_read_time 2 }}% | -{{- MsFormat $value.diff_blk_write_time }}
{{ MsFormat $value.per_sec_blk_write_time }}/sec
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ NumFormat $value.ratio_blk_write_time 2 }}% | +{{- RawFloatFormat $value.diff_blk_read_time 2 }} ms
{{ MsFormat $value.per_sec_blk_read_time }}/sec
{{ MsFormat $value.per_call_blk_read_time }}/call
{{ NumFormat $value.ratio_blk_read_time 2 }}% | +{{- RawFloatFormat $value.diff_blk_write_time 2 }} ms
{{ MsFormat $value.per_sec_blk_write_time }}/sec
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ NumFormat $value.ratio_blk_write_time 2 }}% | {{- NumFormat $value.diff_kcache_reads 2 }} bytes
{{ NumFormat $value.per_sec_kcache_reads 2 }} bytes/sec
{{ NumFormat $value.per_call_kcache_reads 2 }} bytes/call
{{ NumFormat $value.ratio_kcache_reads 2 }}% | {{- NumFormat $value.diff_kcache_writes 2 }} bytes
{{ NumFormat $value.per_sec_kcache_writes 2 }} bytes/sec
{{ NumFormat $value.per_call_kcache_writes 2 }} bytes/call
{{ NumFormat $value.ratio_kcache_writes 2 }}% | {{- MsFormat $value.diff_kcache_user_time_ms }}
{{ MsFormat $value.per_sec_kcache_user_time_ms }}/sec
{{ MsFormat $value.per_call_kcache_user_time_ms }}/call
{{ NumFormat $value.ratio_kcache_user_time_ms 2 }}% | @@ -51,14 +51,14 @@ Period age: {{ (index (index (index $.results $host) "data") "period_age") }} {{- $value := (index (index (index (index $.results $host) "data") "queries") $key) -}} {{- $key}} | {{- RawIntFormat $value.diff_calls }}
{{ NumFormat $value.per_sec_calls 2 }}/sec
{{ NumFormat $value.per_call_calls 2 }}/call
{{ NumFormat $value.ratio_calls 2 }}% | -{{- MsFormat $value.diff_total_time }}
{{ MsFormat $value.per_sec_total_time }}/sec
{{ MsFormat $value.per_call_total_time }}/call
{{ NumFormat $value.ratio_total_time 2 }}% | +{{- RawFloatFormat $value.diff_total_time 2 }} s
{{ MsFormat $value.per_sec_total_time }}/sec
{{ MsFormat $value.per_call_total_time }}/call
{{ NumFormat $value.ratio_total_time 2 }}% | {{- RawIntFormat $value.diff_rows }}
{{ NumFormat $value.per_sec_rows 2 }}/sec
{{ NumFormat $value.per_call_rows 2 }}/call
{{ NumFormat $value.ratio_rows 2 }}% | {{- RawIntFormat $value.diff_shared_blks_hit }} blks
{{ NumFormat $value.per_sec_shared_blks_hit 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_hit 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_hit 2 }}% | {{- RawIntFormat $value.diff_shared_blks_read }} blks
{{ NumFormat $value.per_sec_shared_blks_read 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_read 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_read 2 }}% | {{- RawIntFormat $value.diff_shared_blks_dirtied }} blks
{{ NumFormat $value.per_sec_shared_blks_dirtied 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_dirtied 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_dirtied 2 }}% | {{- RawIntFormat $value.diff_shared_blks_written }} blks
{{ NumFormat $value.per_sec_shared_blks_written 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_written 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_written 2 }}% | -{{- MsFormat $value.diff_blk_read_time }}
{{ MsFormat $value.per_sec_blk_read_time }}/sec
{{ MsFormat $value.per_call_blk_read_time }}/call
{{ NumFormat $value.ratio_blk_read_time 2 }}% | -{{- MsFormat $value.diff_blk_write_time }}
{{ MsFormat $value.per_sec_blk_write_time }}/sec
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ NumFormat $value.ratio_blk_write_time 2 }}% | +{{- RawFloatFormat $value.diff_blk_read_time 2 }} ms
{{ MsFormat $value.per_sec_blk_read_time }}/sec
{{ MsFormat $value.per_call_blk_read_time }}/call
{{ NumFormat $value.ratio_blk_read_time 2 }}% | +{{- RawFloatFormat $value.diff_blk_write_time 2 }} ms
{{ MsFormat $value.per_sec_blk_write_time }}/sec
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ NumFormat $value.ratio_blk_write_time 2 }}% | {{- NumFormat $value.diff_kcache_reads 2 }} bytes
{{ NumFormat $value.per_sec_kcache_reads 2 }} bytes/sec
{{ NumFormat $value.per_call_kcache_reads 2 }} bytes/call
{{ NumFormat $value.ratio_kcache_reads 2 }}% | {{- NumFormat $value.diff_kcache_writes 2 }} bytes
{{ NumFormat $value.per_sec_kcache_writes 2 }} bytes/sec
{{ NumFormat $value.per_call_kcache_writes 2 }} bytes/call
{{ NumFormat $value.ratio_kcache_writes 2 }}% | {{- MsFormat $value.diff_kcache_user_time_ms }}
{{ MsFormat $value.per_sec_kcache_user_time_ms }}/sec
{{ MsFormat $value.per_call_kcache_user_time_ms }}/call
{{ NumFormat $value.ratio_kcache_user_time_ms 2 }}% | -- GitLab From 19c84d2a3ea8504e72b8ffda4efaaf8dc76102c0 Mon Sep 17 00:00:00 2001 From: Oleg Gurov Date: Tue, 29 Jan 2019 00:20:58 +0300 Subject: [PATCH 4/4] fixed tpl K003 --- pghrep/templates/K003.tpl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pghrep/templates/K003.tpl b/pghrep/templates/K003.tpl index 9f7f0ca..44faf89 100644 --- a/pghrep/templates/K003.tpl +++ b/pghrep/templates/K003.tpl @@ -17,7 +17,7 @@ Error (total time): {{ NumFormat (index (index (index .results .hosts.master) "d {{- $value := (index (index (index (index $.results $.hosts.master) "data") "queries") $key) -}} {{- $key}} | {{- RawIntFormat $value.diff_calls }}
{{ NumFormat $value.per_sec_calls 2 }}/sec
{{ NumFormat $value.per_call_calls 2 }}/call
{{ NumFormat $value.ratio_calls 2 }}% | -{{- RawFloatFormat $value.diff_total_time 2 }} ms
{{ MsFormat $value.per_sec_total_time }}/sec
{{ MsFormat $value.per_call_total_time }}/call
{{ NumFormat $value.ratio_total_time 2 }}% | +{{- RawFloatFormat $value.diff_total_time 2 }} ms
{{ MsFormat $value.per_sec_total_time }}/sec
{{ MsFormat $value.per_call_total_time }}/call
{{ NumFormat $value.ratio_total_time 2 }}% | {{- RawIntFormat $value.diff_rows }}
{{ NumFormat $value.per_sec_rows 2 }}/sec
{{ NumFormat $value.per_call_rows 2 }}/call
{{ NumFormat $value.ratio_rows 2 }}% | {{- RawIntFormat $value.diff_shared_blks_hit }} blks
{{ NumFormat $value.per_sec_shared_blks_hit 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_hit 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_hit 2 }}% | {{- RawIntFormat $value.diff_shared_blks_read }} blks
{{ NumFormat $value.per_sec_shared_blks_read 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_read 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_read 2 }}% | @@ -27,8 +27,8 @@ Error (total time): {{ NumFormat (index (index (index .results .hosts.master) "d {{- RawFloatFormat $value.diff_blk_write_time 2 }} ms
{{ MsFormat $value.per_sec_blk_write_time }}/sec
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ NumFormat $value.ratio_blk_write_time 2 }}% | {{- NumFormat $value.diff_kcache_reads 2 }} bytes
{{ NumFormat $value.per_sec_kcache_reads 2 }} bytes/sec
{{ NumFormat $value.per_call_kcache_reads 2 }} bytes/call
{{ NumFormat $value.ratio_kcache_reads 2 }}% | {{- NumFormat $value.diff_kcache_writes 2 }} bytes
{{ NumFormat $value.per_sec_kcache_writes 2 }} bytes/sec
{{ NumFormat $value.per_call_kcache_writes 2 }} bytes/call
{{ NumFormat $value.ratio_kcache_writes 2 }}% | -{{- MsFormat $value.diff_kcache_user_time_ms }}
{{ MsFormat $value.per_sec_kcache_user_time_ms }}/sec
{{ MsFormat $value.per_call_kcache_user_time_ms }}/call
{{ NumFormat $value.ratio_kcache_user_time_ms 2 }}% | -{{- MsFormat $value.diff_kcache_system_time_ms }}
{{ MsFormat $value.per_sec_kcache_system_time_ms }}/sec
{{ MsFormat $value.per_call_kcache_system_time_ms }}/call
{{ NumFormat $value.ratio_kcache_system_time_ms 2 }}% | +{{- RawFloatFormat $value.diff_kcache_user_time_ms 2 }} ms
{{ MsFormat $value.per_sec_kcache_user_time_ms }}/sec
{{ MsFormat $value.per_call_kcache_user_time_ms }}/call
{{ NumFormat $value.ratio_kcache_user_time_ms 2 }}% | +{{- RawFloatFormat $value.diff_kcache_system_time_ms 2 }} ms
{{ MsFormat $value.per_sec_kcache_system_time_ms }}/sec
{{ MsFormat $value.per_call_kcache_system_time_ms }}/call
{{ NumFormat $value.ratio_kcache_system_time_ms 2 }}% | {{- Nobr (LimitStr $value.query 2000 ) }} {{ end }}{{/* range */}} {{ else }}{{/* if .host.master*/}} @@ -51,7 +51,7 @@ Period age: {{ (index (index (index $.results $host) "data") "period_age") }} {{- $value := (index (index (index (index $.results $host) "data") "queries") $key) -}} {{- $key}} | {{- RawIntFormat $value.diff_calls }}
{{ NumFormat $value.per_sec_calls 2 }}/sec
{{ NumFormat $value.per_call_calls 2 }}/call
{{ NumFormat $value.ratio_calls 2 }}% | -{{- RawFloatFormat $value.diff_total_time 2 }} s
{{ MsFormat $value.per_sec_total_time }}/sec
{{ MsFormat $value.per_call_total_time }}/call
{{ NumFormat $value.ratio_total_time 2 }}% | +{{- RawFloatFormat $value.diff_total_time 2 }} ms
{{ MsFormat $value.per_sec_total_time }}/sec
{{ MsFormat $value.per_call_total_time }}/call
{{ NumFormat $value.ratio_total_time 2 }}% | {{- RawIntFormat $value.diff_rows }}
{{ NumFormat $value.per_sec_rows 2 }}/sec
{{ NumFormat $value.per_call_rows 2 }}/call
{{ NumFormat $value.ratio_rows 2 }}% | {{- RawIntFormat $value.diff_shared_blks_hit }} blks
{{ NumFormat $value.per_sec_shared_blks_hit 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_hit 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_hit 2 }}% | {{- RawIntFormat $value.diff_shared_blks_read }} blks
{{ NumFormat $value.per_sec_shared_blks_read 2 }} blks/sec
{{ NumFormat $value.per_call_shared_blks_read 2 }} blks/call
{{ NumFormat $value.ratio_shared_blks_read 2 }}% | @@ -61,8 +61,8 @@ Period age: {{ (index (index (index $.results $host) "data") "period_age") }} {{- RawFloatFormat $value.diff_blk_write_time 2 }} ms
{{ MsFormat $value.per_sec_blk_write_time }}/sec
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ MsFormat $value.per_call_blk_write_time }}/call
{{ NumFormat $value.ratio_blk_write_time 2 }}% | {{- NumFormat $value.diff_kcache_reads 2 }} bytes
{{ NumFormat $value.per_sec_kcache_reads 2 }} bytes/sec
{{ NumFormat $value.per_call_kcache_reads 2 }} bytes/call
{{ NumFormat $value.ratio_kcache_reads 2 }}% | {{- NumFormat $value.diff_kcache_writes 2 }} bytes
{{ NumFormat $value.per_sec_kcache_writes 2 }} bytes/sec
{{ NumFormat $value.per_call_kcache_writes 2 }} bytes/call
{{ NumFormat $value.ratio_kcache_writes 2 }}% | -{{- MsFormat $value.diff_kcache_user_time_ms }}
{{ MsFormat $value.per_sec_kcache_user_time_ms }}/sec
{{ MsFormat $value.per_call_kcache_user_time_ms }}/call
{{ NumFormat $value.ratio_kcache_user_time_ms 2 }}% | -{{- MsFormat $value.diff_kcache_system_time_ms }}
{{ MsFormat $value.per_sec_kcache_system_time_ms }}/sec
{{ MsFormat $value.per_call_kcache_system_time_ms }}/call
{{ NumFormat $value.ratio_kcache_system_time_ms 2 }}% | +{{- RawFloatFormat $value.diff_kcache_user_time_ms 2 }} ms
{{ MsFormat $value.per_sec_kcache_user_time_ms }}/sec
{{ MsFormat $value.per_call_kcache_user_time_ms }}/call
{{ NumFormat $value.ratio_kcache_user_time_ms 2 }}% | +{{- RawFloatFormat $value.diff_kcache_system_time_ms 2 }} ms
{{ MsFormat $value.per_sec_kcache_system_time_ms }}/sec
{{ MsFormat $value.per_call_kcache_system_time_ms }}/call
{{ NumFormat $value.ratio_kcache_system_time_ms 2 }}% | {{- Nobr (LimitStr $value.query 2000 ) }} {{ end }}{{/* range */}} {{- else -}}{{/* if host data */}} -- GitLab