Skip to content

Commit 3067307

Browse files
committed
Remove Powershell as a backup to handle.exe
If a user does not have `handle.exe` installed in the `PATH` of their Windows system, a message will be logged once, and then the total handles being used will be set to `0`. Fixes #8700 Follow-up to: * #6614 * #6613 * #8541
1 parent a92af34 commit 3067307

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

deps/rabbitmq_management_agent/src/rabbit_mgmt_external_stats.erl

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,23 @@ get_used_fd({win32, _}, State0) ->
108108
case os:find_executable("handle.exe") of
109109
false ->
110110
State1 = log_fd_warning_once("Could not find handle.exe, using powershell to determine handle count", [], State0),
111-
UsedFd = get_used_fd_via_powershell(Pid),
112-
{State1, UsedFd};
111+
{State1, 0};
113112
HandleExe ->
114113
Args = ["/accepteula", "-s", "-p", Pid],
115114
{ok, HandleExeOutput} = rabbit_misc:win32_cmd(HandleExe, Args),
116115
case HandleExeOutput of
117116
[] ->
118-
State1 = log_fd_warning_once("Could not execute handle.exe, using powershell to determine handle count", [], State0),
119-
UsedFd = get_used_fd_via_powershell(Pid),
120-
{State1, UsedFd};
117+
State1 = log_fd_warning_once("Could not execute handle.exe, "
118+
"please install from "
119+
"https://learn.microsoft.com/en-us/sysinternals/downloads/handle", [], State0),
120+
{State1, 0};
121121
_ ->
122122
case find_files_line(HandleExeOutput) of
123123
unknown ->
124124
State1 = log_fd_warning_once("handle.exe output did not contain "
125-
"a line beginning with 'File', using "
126-
"powershell to determine used file descriptor "
127-
"count: ~tp", [HandleExeOutput], State0),
128-
UsedFd = get_used_fd_via_powershell(Pid),
129-
{State1, UsedFd};
125+
"a line beginning with 'File': ~tp",
126+
[HandleExeOutput], State0),
127+
{State1, 0};
130128
UsedFd ->
131129
{State0, UsedFd}
132130
end
@@ -144,11 +142,6 @@ find_files_line(["File " ++ Rest | _T]) ->
144142
find_files_line([_H | T]) ->
145143
find_files_line(T).
146144

147-
get_used_fd_via_powershell(Pid) ->
148-
Cmd = "Get-Process -Id " ++ Pid ++ " | Select-Object -ExpandProperty HandleCount",
149-
{ok, [Result]} = rabbit_misc:pwsh_cmd(Cmd),
150-
list_to_integer(Result).
151-
152145
-define(SAFE_CALL(Fun, NoProcFailResult),
153146
try
154147
Fun

0 commit comments

Comments
 (0)