1## This Source Code Form is subject to the terms of the Mozilla Public
2## License, v. 2.0. If a copy of the MPL was not distributed with this
3## file, You can obtain one at https://mozilla.org/MPL/2.0/.
4##
5## Copyright (c) 2007-2021 VMware, Inc. or its affiliates.  All rights reserved.
6
7defmodule RabbitMQ.CLI.Diagnostics.Commands.MaybeStuckCommand do
8  @behaviour RabbitMQ.CLI.CommandBehaviour
9  use RabbitMQ.CLI.DefaultOutput
10
11  use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout
12  use RabbitMQ.CLI.Core.MergesNoDefaults
13  use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
14  use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
15
16  def run([], %{node: node_name, timeout: timeout}) do
17    :rabbit_misc.rpc_call(node_name, :rabbit_diagnostics, :maybe_stuck, [], timeout)
18  end
19
20  def help_section(), do: :observability_and_health_checks
21
22  def description(), do: "Detects Erlang processes (\"lightweight threads\") potentially not making progress on the target node"
23
24  def usage, do: "maybe_stuck"
25
26  def banner(_, %{node: node_name}) do
27    "Asking node #{node_name} to detect potentially stuck Erlang processes..."
28  end
29end
30