diff --git a/lib/report.ex b/lib/report.ex index 9a68da52a..c079b53a3 100644 --- a/lib/report.ex +++ b/lib/report.ex @@ -9,7 +9,9 @@ defmodule Report do Report.UserNamesAndUuids, Report.UserConfigurations, Report.NotificationsCountEstimate, - Report.NotificationsUsersCountEstimate + Report.NotificationsUsersCountEstimate, + Report.MaxConnections, + Report.AuthenticationTimeout ] @callback run() :: {:ok, [map()]} | :error diff --git a/lib/report/authentication_timeout.ex b/lib/report/authentication_timeout.ex new file mode 100644 index 000000000..f32c0d8d7 --- /dev/null +++ b/lib/report/authentication_timeout.ex @@ -0,0 +1,21 @@ +defmodule Report.AuthenticationTimeout do + @moduledoc """ + Report Postgres' configured authentication_timeout + """ + + @behaviour Report + + @impl Report + def run() do + {:ok, %Postgrex.Result{rows: [[authentication_timeout]]}} = + Ecto.Adapters.SQL.query(Skate.Repo, "SHOW authentication_timeout") + + {:ok, [%{max_connections: authentication_timeout}]} + end + + @impl Report + def short_name(), do: "authentication_timeout" + + @impl Report + def description(), do: "Postgres authentication_timeout configuration" +end diff --git a/lib/report/max_connections.ex b/lib/report/max_connections.ex new file mode 100644 index 000000000..258c5b5cd --- /dev/null +++ b/lib/report/max_connections.ex @@ -0,0 +1,21 @@ +defmodule Report.MaxConnections do + @moduledoc """ + Report Postgres' configured max_connections + """ + + @behaviour Report + + @impl Report + def run() do + {:ok, %Postgrex.Result{rows: [[max_connections]]}} = + Ecto.Adapters.SQL.query(Skate.Repo, "SHOW max_connections") + + {:ok, [%{max_connections: max_connections}]} + end + + @impl Report + def short_name(), do: "max_connections" + + @impl Report + def description(), do: "Postgres max_connections configuration" +end diff --git a/lib/skate/repo.ex b/lib/skate/repo.ex index 4e5ecee31..4e638ce06 100644 --- a/lib/skate/repo.ex +++ b/lib/skate/repo.ex @@ -18,6 +18,14 @@ defmodule Skate.Repo do %{} ) + if is_nil(token) do + Logger.info("#{__MODULE__} add_prod_credentials token_is_nil") + else + hash_string = :crypto.hash(:sha3_256, token) |> Base.encode16() + + Logger.info("#{__MODULE__} add_prod_credentials token_hash=#{hash_string}") + end + Keyword.merge(config, hostname: hostname, username: username, diff --git a/test/report_test.exs b/test/report_test.exs index 8dfab7b1d..4f90f46da 100644 --- a/test/report_test.exs +++ b/test/report_test.exs @@ -56,7 +56,9 @@ defmodule ReportTest do "user_settings" => Report.UserSettings, "user_names_and_uuids" => Report.UserNamesAndUuids, "notifications_count_estimate" => Report.NotificationsCountEstimate, - "notifications_users_count_estimate" => Report.NotificationsUsersCountEstimate + "notifications_users_count_estimate" => Report.NotificationsUsersCountEstimate, + "max_connections" => Report.MaxConnections, + "authentication_timeout" => Report.AuthenticationTimeout } end end