Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commitcf7be4a

Browse files
committed
Merge branch '158-k001-merge-all-kXXX-to-k000' into 'master'
Merge all Kxxx reports to K000, implemet K001, k002Closes #158See merge request postgres-ai-team/postgres-checkup!212
2 parents41169c8 +8e9ddc2 commitcf7be4a

File tree

5 files changed

+242
-21
lines changed

5 files changed

+242
-21
lines changed

‎pghrep/src/main.go

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"strings"
1818
"encoding/json"
1919
"io/ioutil"
20-
"path"
2120
"path/filepath"
2221
"./pyraconv"
2322
"log"
@@ -207,6 +206,47 @@ func getRawData(data map[string]interface{}) {
207206
data["rawData"]=rawData
208207
}
209208

209+
/*
210+
Generate MD reports by given check Id
211+
CheckId can be either ID of concrete check (e.g. H003) or represent the whole category (e.g. K000)
212+
*/
213+
funcgenerateMdReports(checkIdstring,reportDatamap[string]interface{},outputDirstring)bool{
214+
category:=checkId[0:1]
215+
checkNum,err:=strconv.ParseInt(checkId[1:4],10,64)
216+
217+
reportPrefix:=""
218+
ifcheckNum!=0 {
219+
reportPrefix=checkId// specified check given
220+
}else {
221+
reportPrefix=category// category given
222+
}
223+
224+
dir,_:=filepath.Abs(filepath.Dir(os.Args[0]))
225+
iferr!=nil {
226+
Err(err)
227+
returnfalse
228+
}
229+
files,err:=ioutil.ReadDir(dir+"/../templates")
230+
iferr!=nil {
231+
Err(err)
232+
returnfalse
233+
}
234+
for_,file:=rangefiles {
235+
fileName:=file.Name()
236+
ifstrings.HasPrefix(fileName,reportPrefix)&&strings.HasSuffix(fileName,".tpl") {
237+
curCheckId:=fileName[0:4]
238+
outputFileName:=strings.Replace(fileName,".tpl",".md",-1)
239+
reportData["checkId"]=curCheckId
240+
if!generateMdReport(curCheckId,outputFileName,reportData,outputDir) {
241+
Err("Can't generate report "+outputFileName+" based on "+checkId+" json data")
242+
returnfalse
243+
}
244+
}
245+
}
246+
247+
returntrue
248+
}
249+
210250
// Generate md report (file) on base of reportData and save them to file in outputDir
211251
funcgenerateMdReport(checkIdstring,reportFilenamestring,reportDatamap[string]interface{},outputDirstring)bool{
212252
varoutputFileNamestring
@@ -300,12 +340,7 @@ func main() {
300340
DEBUG=true
301341
}
302342

303-
reportFilename:=""
304343
ifFileExists(checkData) {
305-
_,file:=path.Split(checkData)
306-
//fmt.Println(file)
307-
reportFilename=strings.Replace(file,".json",".md",-1)
308-
309344
resultData=LoadJsonFile(checkData)
310345
ifresultData==nil {
311346
log.Fatal("ERROR: File given by --checkdata content wrong json data.")
@@ -354,7 +389,7 @@ func main() {
354389
}else {
355390
outputDir=*outDirPtr
356391
}
357-
reportDone:=generateMdReport(checkId,reportFilename,reportData,outputDir)
392+
reportDone:=generateMdReports(checkId,reportData,outputDir)
358393
if!reportDone {
359394
log.Fatal("Cannot generate report. Data file or template is wrong.")
360395
}

‎pghrep/templates/K001.tpl

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#{{ .checkId}} Globally aggregated query metrics
2+
3+
## Observations ##
4+
{{if .hosts.master}}
5+
### Master (`{{.hosts.master}}`) ###
6+
Start:{{ (index (index (index .results .hosts.master)"data")"start_timestamptz")}}
7+
End:{{ (index (index (index .results .hosts.master)"data")"end_timestamptz")}}
8+
Period seconds:{{ (index (index (index .results .hosts.master)"data")"period_seconds")}}
9+
Period age:{{ (index (index (index .results .hosts.master)"data")"period_age")}}
10+
11+
Error (calls):{{ NumFormat (index (index (index .results .hosts.master)"data")"absolute_error_calls") 2}} ({{ NumFormat (index (index (index .results .hosts.master)"data")"relative_error_calls") 2}}%)
12+
Error (total time):{{ NumFormat (index (index (index .results .hosts.master)"data")"absolute_error_total_time") 2}} ({{ NumFormat (index (index (index .results .hosts.master)"data")"relative_error_total_time") 2}}%)
13+
14+
Calls | Total time | Rows | shared_blks_hit | shared_blks_read | shared_blks_dirtied | shared_blks_written | blk_read_time | blk_write_time | kcache_reads | kcache_writes | kcache_user_time_ms | kcache_system_time
15+
-------|------------|------|-----------------|------------------|---------------------|---------------------|---------------|----------------|--------------|---------------|---------------------|--------------------
16+
{{ range$i,$key := (index (index (index (index .results .hosts.master)"data")"aggregated")"_keys")}}
17+
{{-$value := (index (index (index (index $.results $.hosts.master)"data")"aggregated")$key) -}}
18+
{{- NumFormat$value.diff_calls 2}}<br/>{{ NumFormat$value.per_sec_calls 2}}/sec<br/>{{ NumFormat$value.per_call_calls 2}}/call<br/>{{ NumFormat$value.ratio_calls 2}}% |
19+
{{- MsFormat$value.diff_total_time}}<br/>{{ MsFormat$value.per_sec_total_time}}/sec<br/>{{ MsFormat$value.per_call_total_time}}/call<br/>{{ NumFormat$value.ratio_total_time 2}}% |
20+
{{- NumFormat$value.diff_rows 2}}<br/>{{ NumFormat$value.per_sec_rows 2}}/sec<br/>{{ NumFormat$value.per_call_rows 2}}/call<br/>{{ NumFormat$value.ratio_rows 2}}% |
21+
{{- NumFormat$value.diff_shared_blks_hit 2}}&nbsp;blks<br/>{{ NumFormat$value.per_sec_shared_blks_hit 2}}&nbsp;blks/sec<br/>{{ NumFormat$value.per_call_shared_blks_hit 2}}&nbsp;blks/call<br/>{{ NumFormat$value.ratio_shared_blks_hit 2}}% |
22+
{{- NumFormat$value.diff_shared_blks_read 2}}&nbsp;blks<br/>{{ NumFormat$value.per_sec_shared_blks_read 2}}&nbsp;blks/sec<br/>{{ NumFormat$value.per_call_shared_blks_read 2}}&nbsp;blks/call<br/>{{ NumFormat$value.ratio_shared_blks_read 2}}% |
23+
{{- NumFormat$value.diff_shared_blks_dirtied 2}}&nbsp;blks<br/>{{ NumFormat$value.per_sec_shared_blks_dirtied 2}}&nbsp;blks/sec<br/>{{ NumFormat$value.per_call_shared_blks_dirtied 2}}&nbsp;blks/call<br/>{{ NumFormat$value.ratio_shared_blks_dirtied 2}}% |
24+
{{- NumFormat$value.diff_shared_blks_written 2}}&nbsp;blks<br/>{{ NumFormat$value.per_sec_shared_blks_written 2}}&nbsp;blks/sec<br/>{{ NumFormat$value.per_call_shared_blks_written 2}}&nbsp;blks/call<br/>{{ NumFormat$value.ratio_shared_blks_written 2}}% |
25+
{{- MsFormat$value.diff_blk_read_time}}<br/>{{ MsFormat$value.per_sec_blk_read_time}}/sec<br/>{{ MsFormat$value.per_call_blk_read_time}}/call<br/>{{ NumFormat$value.ratio_blk_read_time 2}}% |
26+
{{- MsFormat$value.diff_blk_write_time}}<br/>{{ MsFormat$value.per_sec_blk_write_time}}/sec<br/>{{ MsFormat$value.per_call_blk_write_time}}/call<br/>{{ MsFormat$value.per_call_blk_write_time}}/call<br/>{{ NumFormat$value.ratio_blk_write_time 2}}% |
27+
{{- NumFormat$value.diff_kcache_reads 2}}&nbsp;bytes<br/>{{ NumFormat$value.per_sec_kcache_reads 2}}&nbsp;bytes/sec<br/>{{ NumFormat$value.per_call_kcache_reads 2}}&nbsp;bytes/call<br/>{{ NumFormat$value.ratio_kcache_reads 2}}% |
28+
{{- NumFormat$value.diff_kcache_writes 2}}&nbsp;bytes<br/>{{ NumFormat$value.per_sec_kcache_writes 2}}&nbsp;bytes/sec<br/>{{ NumFormat$value.per_call_kcache_writes 2}}&nbsp;bytes/call<br/>{{ NumFormat$value.ratio_kcache_writes 2}}% |
29+
{{- MsFormat$value.diff_kcache_user_time_ms}}<br/>{{ MsFormat$value.per_sec_kcache_user_time_ms}}/sec<br/>{{ MsFormat$value.per_call_kcache_user_time_ms}}/call<br/>{{ NumFormat$value.ratio_kcache_user_time_ms 2}}% |
30+
{{- MsFormat$value.diff_kcache_system_time_ms}}<br/>{{ MsFormat$value.per_sec_kcache_system_time_ms}}/sec<br/>{{ MsFormat$value.per_call_kcache_system_time_ms}}/call<br/>{{ NumFormat$value.ratio_kcache_system_time_ms 2}}%
31+
{{ end}}{{/* range */}}
32+
{{else}}{{/*if .host.master*/}}
33+
No data
34+
{{ end}}{{/*if .host.master*/}}
35+
36+
{{ifgt (len .hosts.replicas) 0}}
37+
### Replica servers: ###
38+
{{ range$key,$host := .hosts.replicas}}
39+
#### Replica (`{{$host}}`) ####
40+
{{if (index $.results$host)}}
41+
Start:{{ (index (index (index $.results$host)"data")"start_timestamptz")}}
42+
End:{{ (index (index (index $.results$host)"data")"end_timestamptz")}}
43+
Period seconds:{{ (index (index (index $.results$host)"data")"period_seconds")}}
44+
Period age:{{ (index (index (index $.results$host)"data")"period_age")}}
45+
46+
Calls | Total&nbsp;time | Rows | shared_blks_hit | shared_blks_read | shared_blks_dirtied | shared_blks_written | blk_read_time | blk_write_time | kcache_reads | kcache_writes | kcache_user_time_ms | kcache_system_time
47+
-------|------------|------|-----------------|------------------|---------------------|---------------------|---------------|----------------|--------------|---------------|---------------------|--------------------
48+
{{ range$i,$key := (index (index (index (index $.results$host)"data")"aggregated")"_keys")}}
49+
{{-$value := (index (index (index (index $.results$host)"data")"aggregated")$key) -}}
50+
{{- NumFormat$value.diff_calls 2}}<br/>{{ NumFormat$value.per_sec_calls 2}}/sec<br/>{{ NumFormat$value.per_call_calls 2}}/call<br/>{{ NumFormat$value.ratio_calls 2}}% |
51+
{{- MsFormat$value.diff_total_time}}<br/>{{ MsFormat$value.per_sec_total_time}}/sec<br/>{{ MsFormat$value.per_call_total_time}}/call<br/>{{ NumFormat$value.ratio_total_time 2}}% |
52+
{{- NumFormat$value.diff_rows 2}}<br/>{{ NumFormat$value.per_sec_rows 2}}/sec<br/>{{ NumFormat$value.per_call_rows 2}}/call<br/>{{ NumFormat$value.ratio_rows 2}}% |
53+
{{- NumFormat$value.diff_shared_blks_hit 2}}&nbsp;blks<br/>{{ NumFormat$value.per_sec_shared_blks_hit 2}}&nbsp;blks/sec<br/>{{ NumFormat$value.per_call_shared_blks_hit 2}}&nbsp;blks/call<br/>{{ NumFormat$value.ratio_shared_blks_hit 2}}% |
54+
{{- NumFormat$value.diff_shared_blks_read 2}}&nbsp;blks<br/>{{ NumFormat$value.per_sec_shared_blks_read 2}}&nbsp;blks/sec<br/>{{ NumFormat$value.per_call_shared_blks_read 2}}&nbsp;blks/call<br/>{{ NumFormat$value.ratio_shared_blks_read 2}}% |
55+
{{- NumFormat$value.diff_shared_blks_dirtied 2}}&nbsp;blks<br/>{{ NumFormat$value.per_sec_shared_blks_dirtied 2}}&nbsp;blks/sec<br/>{{ NumFormat$value.per_call_shared_blks_dirtied 2}}&nbsp;blks/call<br/>{{ NumFormat$value.ratio_shared_blks_dirtied 2}}% |
56+
{{- NumFormat$value.diff_shared_blks_written 2}}&nbsp;blks<br/>{{ NumFormat$value.per_sec_shared_blks_written 2}}&nbsp;blks/sec<br/>{{ NumFormat$value.per_call_shared_blks_written 2}}&nbsp;blks/call<br/>{{ NumFormat$value.ratio_shared_blks_written 2}}% |
57+
{{- MsFormat$value.diff_blk_read_time}}<br/>{{ MsFormat$value.per_sec_blk_read_time}}/sec<br/>{{ MsFormat$value.per_call_blk_read_time}}/call<br/>{{ NumFormat$value.ratio_blk_read_time 2}}% |
58+
{{- MsFormat$value.diff_blk_write_time}}<br/>{{ MsFormat$value.per_sec_blk_write_time}}/sec<br/>{{ MsFormat$value.per_call_blk_write_time}}/call<br/>{{ MsFormat$value.per_call_blk_write_time}}/call<br/>{{ NumFormat$value.ratio_blk_write_time 2}}% |
59+
{{- NumFormat$value.diff_kcache_reads 2}}&nbsp;bytes<br/>{{ NumFormat$value.per_sec_kcache_reads 2}}&nbsp;bytes/sec<br/>{{ NumFormat$value.per_call_kcache_reads 2}}&nbsp;bytes/call<br/>{{ NumFormat$value.ratio_kcache_reads 2}}% |
60+
{{- NumFormat$value.diff_kcache_writes 2}}&nbsp;bytes<br/>{{ NumFormat$value.per_sec_kcache_writes 2}}&nbsp;bytes/sec<br/>{{ NumFormat$value.per_call_kcache_writes 2}}&nbsp;bytes/call<br/>{{ NumFormat$value.ratio_kcache_writes 2}}% |
61+
{{- MsFormat$value.diff_kcache_user_time_ms}}<br/>{{ MsFormat$value.per_sec_kcache_user_time_ms}}/sec<br/>{{ MsFormat$value.per_call_kcache_user_time_ms}}/call<br/>{{ NumFormat$value.ratio_kcache_user_time_ms 2}}% |
62+
{{- MsFormat$value.diff_kcache_system_time_ms}}<br/>{{ MsFormat$value.per_sec_kcache_system_time_ms}}/sec<br/>{{ MsFormat$value.per_call_kcache_system_time_ms}}/call<br/>{{ NumFormat$value.ratio_kcache_system_time_ms 2}}%
63+
{{ end}}{{/* range */}}
64+
{{-else -}}{{/*if host data */}}
65+
No data
66+
{{- end -}}{{/*if host data */}}
67+
{{- end -}}{{/* hosts range */}}
68+
{{- end -}}{{/*if replicas */}}
69+
70+
## Conclusions ##
71+
72+
73+
## Recommendations ##
74+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp