Skip to content

Commit af20933

Browse files
Merge pull request #8961 from rabbitmq/rabbitmq-server-8700
Remove Powershell as a backup to `handle.exe`
2 parents a92af34 + d4d1f88 commit af20933

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

deps/rabbitmq_management_agent/src/rabbit_mgmt_external_stats.erl

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,29 +104,27 @@ get_used_fd({unix, _}, State0) ->
104104
%% you will see a list of handles of various types, including network sockets
105105
%% shown as file handles to \Device\Afd.
106106
get_used_fd({win32, _}, State0) ->
107+
MissingHandleMsg = "Could not execute handle.exe, please install from "
108+
"https://learn.microsoft.com/en-us/sysinternals/downloads/handle",
107109
Pid = os:getpid(),
108110
case os:find_executable("handle.exe") of
109111
false ->
110-
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};
112+
State1 = log_fd_warning_once(MissingHandleMsg, [], State0),
113+
{State1, 0};
113114
HandleExe ->
114115
Args = ["/accepteula", "-s", "-p", Pid],
115116
{ok, HandleExeOutput} = rabbit_misc:win32_cmd(HandleExe, Args),
116117
case HandleExeOutput of
117118
[] ->
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};
119+
State1 = log_fd_warning_once(MissingHandleMsg, [], 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)