From e7c37fe0af6c9b3482a356f7e031660cc633dd9a Mon Sep 17 00:00:00 2001 From: Dmitry Fomin Date: Thu, 2 May 2024 18:59:20 +0000 Subject: [PATCH 1/6] update of jq bin file in the Docker --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 7690e46..a8f66b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,8 @@ RUN apk add --update --no-cache \ curl \ gawk \ sed +RUN wget https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64 +RUN cp ./jq-linux-amd64 /usr/local/bin/jq && chmod +x /usr/local/bin/jq WORKDIR ./checkup COPY --from=build /go/pghrep/bin/pghrep ./pghrep/bin/ COPY . . -- GitLab From 706157559c46ea7a63ea6e39ba87a12c02ee117a Mon Sep 17 00:00:00 2001 From: Dmitry Fomin Date: Tue, 7 May 2024 10:10:40 +0000 Subject: [PATCH 2/6] Update checkup --- checkup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/checkup b/checkup index 4c1ac70..4537cb4 100755 --- a/checkup +++ b/checkup @@ -712,7 +712,7 @@ generate_report_json() { local tmp_output_json_fname=$(mktemp "${JSON_REPORTS_DIR}"/${check_id}_${check_name}_tmp_XXXXXX) jq -r \ - --argfile Results "${tmp_input_json_fname}" \ + --slurpfile Results "${tmp_input_json_fname}" \ --arg CheckId "${check_id}" \ --arg CheckName "${check_name}" \ --arg TimestampTz "${TIMESTAMPTZ}" \ @@ -727,7 +727,7 @@ generate_report_json() { # extend check for current host with actual 'nodes.json' inside a json report tmp_output_json_fname=$(mktemp "${JSON_REPORTS_DIR}"/${check_id}_${check_name}_tmp_ex_XXXXXX) - jq --argfile nodes_json "${PROJECT_DIR}/nodes.json" \ + jq --slurpfile nodes_json "${PROJECT_DIR}/nodes.json" \ '.results.'\"${HOST}\"'."nodes.json" = $nodes_json' \ "${json_output_fname}" \ > "$tmp_output_json_fname" @@ -735,7 +735,7 @@ generate_report_json() { # update json report by attaching 'nodes.json' into top of the report tmp_output_json_fname=$(mktemp "${JSON_REPORTS_DIR}"/${check_id}_${check_name}_tmp_ex_XXXXXX) - jq --argfile nodes_json "${PROJECT_DIR}/nodes.json" \ + jq --slurpfile nodes_json "${PROJECT_DIR}/nodes.json" \ '.last_nodes_json = $nodes_json' \ "${json_output_fname}" \ > "$tmp_output_json_fname" -- GitLab From 50dae159d9e1ea91a297d35e05c0e004ebe078ec Mon Sep 17 00:00:00 2001 From: Dmitry Fomin Date: Tue, 7 May 2024 10:58:20 +0000 Subject: [PATCH 3/6] Update checkup --- checkup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/checkup b/checkup index 4537cb4..6921fc8 100755 --- a/checkup +++ b/checkup @@ -719,7 +719,7 @@ generate_report_json() { --arg Host "${HOST}" \ --arg Project "${PROJECT}" \ --arg Database "${DBNAME}" \ - '.checkId = $CheckId | .name = $CheckName | ."timestamptz" = $TimestampTz | ."project" = $Project | ."database" = $Database | .results += { ($Host): { data: $Results } }' \ + '.checkId = $CheckId | .name = $CheckName | ."timestamptz" = $TimestampTz | ."project" = $Project | ."database" = $Database | .results += { ($Host): { data: ($Results[0]) } }' \ "${json_input_fname}" \ > "${tmp_output_json_fname}" mv "${tmp_output_json_fname}" "${json_output_fname}" @@ -728,7 +728,7 @@ generate_report_json() { # extend check for current host with actual 'nodes.json' inside a json report tmp_output_json_fname=$(mktemp "${JSON_REPORTS_DIR}"/${check_id}_${check_name}_tmp_ex_XXXXXX) jq --slurpfile nodes_json "${PROJECT_DIR}/nodes.json" \ - '.results.'\"${HOST}\"'."nodes.json" = $nodes_json' \ + '.results.'\"${HOST}\"'."nodes.json" = ($nodes_json[0])' \ "${json_output_fname}" \ > "$tmp_output_json_fname" mv "$tmp_output_json_fname" "${json_output_fname}" @@ -736,7 +736,7 @@ generate_report_json() { # update json report by attaching 'nodes.json' into top of the report tmp_output_json_fname=$(mktemp "${JSON_REPORTS_DIR}"/${check_id}_${check_name}_tmp_ex_XXXXXX) jq --slurpfile nodes_json "${PROJECT_DIR}/nodes.json" \ - '.last_nodes_json = $nodes_json' \ + '.last_nodes_json = ($nodes_json[0])' \ "${json_output_fname}" \ > "$tmp_output_json_fname" mv "$tmp_output_json_fname" "${json_output_fname}" -- GitLab From 07160360b764bd6df70b1d9217f3dc0a42d692a2 Mon Sep 17 00:00:00 2001 From: Dmitry Fomin Date: Tue, 14 May 2024 08:55:47 +0000 Subject: [PATCH 4/6] Update F005_index_bloat.sh to correct index data with non-superuser roles --- resources/checks/F005_index_bloat.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/resources/checks/F005_index_bloat.sh b/resources/checks/F005_index_bloat.sh index 46691b1..dd4bf40 100755 --- a/resources/checks/F005_index_bloat.sh +++ b/resources/checks/F005_index_bloat.sh @@ -15,6 +15,17 @@ with data as ( from pg_class pc join pg_namespace pn on pn.oid = pc.relnamespace where reloptions::text ~ 'autovacuum' + ), pg_rel_stats as ( + select n.nspname as schemaname, + c.relname as tablename, + a.attname, + s.stawidth as avg_width, + s.stanullfrac as null_frac + from pg_statistic s + join pg_class c on c.oid = s.starelid + join pg_attribute a on c.oid = a.attrelid AND a.attnum = s.staattnum + left join pg_namespace n on n.oid = c.relnamespace + where not a.attisdropped ), step0 as ( select tbl.oid tblid, -- GitLab From 2f51de25ff26e11a7f9c462d6381b149cc88c760 Mon Sep 17 00:00:00 2001 From: Dmitry Fomin Date: Tue, 14 May 2024 09:03:35 +0000 Subject: [PATCH 5/6] Update F005_index_bloat.sh --- resources/checks/F005_index_bloat.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/checks/F005_index_bloat.sh b/resources/checks/F005_index_bloat.sh index dd4bf40..9916930 100755 --- a/resources/checks/F005_index_bloat.sh +++ b/resources/checks/F005_index_bloat.sh @@ -79,7 +79,7 @@ with data as ( i.table_size_bytes from pg_attribute as a join step0 as i on a.attrelid = i.indexrelid - join pg_stats as s on + join pg_rel_stats as s on s.schemaname = i.nspname and ( (s.tablename = i.tblname and s.attname = pg_catalog.pg_get_indexdef(a.attrelid, a.attnum, true)) -- stats from tbl -- GitLab From 4d3afc704fd3b189f95ff490638b72bae80aadab Mon Sep 17 00:00:00 2001 From: Dmitry Fomin Date: Sat, 8 Jun 2024 18:16:58 +0000 Subject: [PATCH 6/6] exclude pg_catalof from int2 and int4 checks --- resources/checks/L003_integer_in_pk.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/checks/L003_integer_in_pk.sh b/resources/checks/L003_integer_in_pk.sh index 692ce9d..b8b989e 100644 --- a/resources/checks/L003_integer_in_pk.sh +++ b/resources/checks/L003_integer_in_pk.sh @@ -42,6 +42,7 @@ begin and (c.relpages > MIN_RELPAGES or (select pg_get_serial_sequence(quote_ident(nspname) || '.' || quote_ident(relname), attname)) is not null) and t.typname in ('int2', 'int4') and nspname <> 'pg_toast' + and nspname <> 'pg_catalog' group by 1, 2, 3, 4, 5, 6 having count(*) = 1 -- skip PKs with 2+ columns loop -- GitLab