diff --git a/lib/ha_handler/ha_proxy.ex b/lib/ha_handler/ha_proxy.ex index 207ce0e..c7790b3 100644 --- a/lib/ha_handler/ha_proxy.ex +++ b/lib/ha_handler/ha_proxy.ex @@ -74,7 +74,19 @@ defmodule HAHandler.HAProxy do Executes and parse the output of the `show stats` HAProxy command, returning a list of Maps. """ - def get_stats() do + def get_stats(opts \\ []) + def get_stats([hide_error: true]) do + case get_stats() do + {:error, _err} -> + %{ + "Frontend" => %{}, + "Backend" => %{}, + "Server" => %{} + } + stats -> stats + end + end + def get_stats(_opts) do case execute("show stat json") do {:ok, raw} -> case Poison.decode(raw) do diff --git a/lib/ha_handler/web/controller.ex b/lib/ha_handler/web/controller.ex index 5d1f3ee..0d0c4e8 100644 --- a/lib/ha_handler/web/controller.ex +++ b/lib/ha_handler/web/controller.ex @@ -19,10 +19,8 @@ defmodule HAHandler.Web.Controller do def index(conn) do {:ok, hostname} = :net_adm.dns_hostname(:net_adm.localhost) - stats = HAProxy.get_stats() - assigns = [ - haproxy_stats: stats, + haproxy_stats: HAProxy.get_stats([hide_error: true]), pgsql_status: PGSQL.status(), hostname: hostname, otp_app: HAHandler.otp_app(),