feat(agent): add [debug] dump_dir config field

This commit is contained in:
Carsten 2026-04-22 22:15:01 +02:00
parent b798b462ca
commit 1c289a5a0d
3 changed files with 49 additions and 0 deletions

View file

@ -5,6 +5,7 @@ defmodule ProxmoxAgent.Config do
:server_url,
:token,
:host_id,
:dump_dir,
fast_seconds: 30,
medium_seconds: 300,
slow_seconds: 1800
@ -14,6 +15,7 @@ defmodule ProxmoxAgent.Config do
server_url: String.t(),
token: String.t(),
host_id: String.t(),
dump_dir: String.t() | nil,
fast_seconds: pos_integer(),
medium_seconds: pos_integer(),
slow_seconds: pos_integer()
@ -57,17 +59,24 @@ defmodule ProxmoxAgent.Config do
defp build(map) do
intervals = Map.get(map, "intervals", %{})
debug = Map.get(map, "debug", %{})
%__MODULE__{
server_url: map["server_url"],
token: map["token"],
host_id: map["host_id"] || hostname(),
dump_dir: normalize_dump_dir(Map.get(debug, "dump_dir")),
fast_seconds: Map.get(intervals, "fast_seconds", 30),
medium_seconds: Map.get(intervals, "medium_seconds", 300),
slow_seconds: Map.get(intervals, "slow_seconds", 1800)
}
end
defp normalize_dump_dir(nil), do: nil
defp normalize_dump_dir(""), do: nil
defp normalize_dump_dir(s) when is_binary(s), do: s
defp normalize_dump_dir(_), do: nil
defp hostname do
case :inet.gethostname() do
{:ok, name} -> List.to_string(name)