Skip to content
This repository was archived by the owner on Jul 6, 2021. It is now read-only.

Commit 0abbb0b

Browse files
authored
Merge pull request #125 from postgres-ai/46-connections-check
G0002 current connections check
2 parents c9c39e0 + bcfc214 commit 0abbb0b

File tree

11 files changed

+71
-4
lines changed

11 files changed

+71
-4
lines changed

check

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,8 @@ generate_report_json() {
486486
fi
487487

488488
local tmp_output_json_fname=$(mktemp "${JSON_REPORTS_DIR}"/${check_id}_${check_name}_tmp_XXXXXX)
489-
jq --argfile Results "${tmp_input_json_fname}" \
489+
jq -r \
490+
--argfile Results "${tmp_input_json_fname}" \
490491
--arg CheckId "${check_id}" \
491492
--arg CheckName "${check_name}" \
492493
--arg TimestampTz "${TIMESTAMPTZ}" \

pghrep/templates/G002.tpl

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Current values
2+
===
3+
4+
Connections and current activity
5+
6+
Master DB server '{{.hosts.master}}':
7+
8+
```
9+
{{ (index (index .results .hosts.master) "data").raw }}
10+
```
11+
{{/* newline */}}
12+
{{/* newline */}}
13+
14+
{{- if gt (len .hosts.replicas) 0 -}}
15+
Slave DB servers
16+
{{/* newline */}}
17+
{{/* newline */}}
18+
{{- range $skey, $host := .hosts.replicas -}}
19+
DB slave server: '{{ $host }}':
20+
{{- if (index $.results $host) -}}
21+
{{/* newline */}}
22+
{{/* newline */}}
23+
```
24+
{{ (index (index $.results $host) "data").raw }}
25+
```
26+
{{- else -}}
27+
```
28+
No data
29+
```
30+
{{- end -}}
31+
{{- end -}}
32+
{{- end -}}
33+
34+
{{/* newline */}}
35+
{{/* newline */}}
36+
Conclusions
37+
===
38+
{{.Conclusion}}
39+
40+
Recommendations
41+
===
42+
{{.Recommended}}

pghrep/templates/raw.tpl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ Some collected
55
data with help of checker
66

77
{{ range $host, $data := .rawData }}
8-
Host: {{ (index $data "host") }}
9-
``` {{ (index $data "data") }} ```
10-
{{ end }}
118

9+
Host: {{ (index $data "host") }}
10+
11+
```bash
12+
{{ (index $data "data") }}
13+
```
1214

15+
{{ end }}
1316

resources/checks/A004_cluster_info.sh

100755100644
File mode changed.

resources/checks/A005_extensions.sh

100755100644
File mode changed.

resources/checks/A006_pg_conf_diff.sh

100755100644
File mode changed.

resources/checks/A007_altersettings.sh

100755100644
File mode changed.

resources/checks/D004_ext_settings.sh

100755100644
File mode changed.

resources/checks/F001_heap_bloat.sh

100755100644
File mode changed.

resources/checks/F002_index_bloat.sh

100755100644
File mode changed.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Current Activity: count of current connections grouped by database, user name, state
2+
3+
sql=$(curl -s -L https://raw.githubusercontent.com/NikolayS/postgres_dba/4.0/sql/a1_activity.sql | awk '{gsub("; *$", "", $0); print $0}')
4+
5+
data=$(${CHECK_HOST_CMD} "${_PSQL} ${PSQL_CONN_OPTIONS} -f -" <<SQL
6+
-- disble psql CLI options '-A -t' for this report
7+
\pset tuples_only
8+
\pset format aligned
9+
10+
with data as (
11+
$sql
12+
),
13+
num_data as (
14+
select row_number() over () num, data.* from data
15+
)
16+
select * from num_data
17+
SQL)
18+
19+
data="{ \"raw\": \"${data}\" }"
20+
jq -n "${data}"
21+

0 commit comments

Comments
 (0)