fix(telemetry): use required fields, rolling distro use PRETTY_NAME
This commit is contained in:
parent
2ee683d2f9
commit
5c29c20426
|
@ -253,13 +253,11 @@ os_info() ->
|
|||
[{os_name, Name},
|
||||
{os_version, Version}];
|
||||
{unix, _} ->
|
||||
case file:read_file_info("/etc/os-release") of
|
||||
case file:read_file("/etc/os-release") of
|
||||
{error, _} ->
|
||||
[{os_name, "Unknown"},
|
||||
{os_version, "Unknown"}];
|
||||
{ok, FileInfo} ->
|
||||
case FileInfo#file_info.access of
|
||||
Access when Access =:= read orelse Access =:= read_write ->
|
||||
{ok, FileContent} ->
|
||||
OSInfo = lists:foldl(fun(Line, Acc) ->
|
||||
[Var, Value] = string:tokens(Line, "="),
|
||||
NValue = case Value of
|
||||
|
@ -269,13 +267,9 @@ os_info() ->
|
|||
Value
|
||||
end,
|
||||
[{Var, NValue} | Acc]
|
||||
end, [], string:tokens(os:cmd("cat /etc/os-release"), "\n")),
|
||||
end, [], string:tokens(binary:bin_to_list(FileContent), "\n")),
|
||||
[{os_name, get_value("NAME", OSInfo)},
|
||||
{os_version, get_value("VERSION", OSInfo, get_value("VERSION_ID", OSInfo))}];
|
||||
_ ->
|
||||
[{os_name, "Unknown"},
|
||||
{os_version, "Unknown"}]
|
||||
end
|
||||
{os_version, get_value("VERSION", OSInfo, get_value("VERSION_ID", OSInfo, get_value("PRETTY_NAME", OSInfo)))}]
|
||||
end;
|
||||
{win32, nt} ->
|
||||
Ver = os:cmd("ver"),
|
||||
|
@ -429,5 +423,7 @@ module_attributes(Module) ->
|
|||
|
||||
bin(L) when is_list(L) ->
|
||||
list_to_binary(L);
|
||||
bin(A) when is_atom(A) ->
|
||||
atom_to_binary(A);
|
||||
bin(B) when is_binary(B) ->
|
||||
B.
|
||||
|
|
Loading…
Reference in New Issue