feat(agent): log every shell command to Diagnostics
This commit is contained in:
parent
1f0ab6dd1e
commit
5a9efdd482
2 changed files with 30 additions and 1 deletions
|
|
@ -8,6 +8,14 @@ defmodule ProxmoxAgent.Shell do
|
|||
|
||||
@spec run(String.t(), [String.t()]) :: result
|
||||
def run(command, args) do
|
||||
start = System.monotonic_time(:microsecond)
|
||||
result = do_run(command, args)
|
||||
duration_us = System.monotonic_time(:microsecond) - start
|
||||
ProxmoxAgent.Diagnostics.log_command(command, args, result, duration_us)
|
||||
result
|
||||
end
|
||||
|
||||
defp do_run(command, args) do
|
||||
try do
|
||||
case System.cmd(command, args, stderr_to_stdout: true) do
|
||||
{output, 0} -> {:ok, output}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue