~cypheon/ecertmon

887e68db83b331ff76c7a75eba04ab1dd0a7c6e9 — Johann Rudloff 1 year, 9 months ago 7ba65e8
Do not crash metrics handler, when scanner process does not exist
1 files changed, 5 insertions(+), 1 deletions(-)

M src/metrics_handler.erl
M src/metrics_handler.erl => src/metrics_handler.erl +5 -1
@@ 4,9 4,13 @@
-export([init/2]).

format_metric({{Hostname, Port}, ScannerPid}) ->
  Valid = case gen_server:call(ScannerPid, {get_status}) of
  Valid = try gen_server:call(ScannerPid, {get_status}) of
            {valid, Epoch} -> Epoch;
            _ -> 0
          catch
            exit:Reason ->
              logger:error("failed to get status for ~p: Reason: ~p", [{Hostname, Port}, Reason]),
              0
          end,
  [<<"tls_cert_expiry{hostname=\"">>, Hostname, <<"\", port=\"">>,
   io_lib:format("~p", [Port]), <<"\"} ">>, io_lib:format("~p\n", [Valid])