搜索

2.4. 检查代理和队列的健康状况

download PDF

AMQ Broker 包含一个命令行实用程序,可让您对代理拓扑中的代理和队列执行各种健康检查。

以下示例演示了如何使用 实用程序运行健康检查。

步骤

  1. 请参阅代理拓扑中为特定代理(即 节点)运行的检查列表。

    $ <broker-instance-dir>/bin/artemis help check node

    您可以看到描述可用于 arte mis 检查 node 命令的一组选项。

    NAME
            artemis check node - Check a node
    
    SYNOPSIS
            artemis check node [--backup] [--clientID <clientID>]
                    [--diskUsage <diskUsage>] [--fail-at-end] [--live]
                    [--memoryUsage <memoryUsage>] [--name <name>] [--password <password>]
                    [--peers <peers>] [--protocol <protocol>] [--silent]
                    [--timeout <timeout>] [--up] [--url <brokerURL>] [--user <user>]
                    [--verbose]
    
    OPTIONS
            --backup
                Check that the node has a backup
    
            --clientID <clientID>
                ClientID to be associated with connection
    
            --diskUsage <diskUsage>
                Disk usage percentage to check or -1 to use the max-disk-usage
    
            --fail-at-end
                If a particular module check fails, continue the rest of the checks
    
            --live
                Check that the node has a live
    
            --memoryUsage <memoryUsage>
                Memory usage percentage to check
    
            --name <name>
                Name of the target to check
    
            --password <password>
                Password used to connect
    
            --peers <peers>
                Number of peers to check
    
            --protocol <protocol>
                Protocol used. Valid values are amqp or core. Default=core.
    
            --silent
                It will disable all the inputs, and it would make a best guess for any required input
    
            --timeout <timeout>
                Time to wait for the check execution, in milliseconds
    
            --up
                Check that the node is started, it is executed by default if there are no other checks
    
            --url <brokerURL>
                URL towards the broker. (default: tcp://localhost:61616)
    
            --user <user>
                User used to connect
    
            --verbose
                Adds more information on the execution
  2. 例如,检查本地代理的磁盘用量是否低于为代理配置的最大磁盘用量。

    $ <broker-instance-dir>/bin/artemis check node --url tcp://localhost:61616 --diskUsage -1
    
    Connection brokerURL = tcp://localhost:61616
    Running NodeCheck
    Checking that the disk usage is less then the max-disk-usage ... success
    Checks run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.065 sec - NodeCheck

    在前面的示例中,为 --diskUsage 选项指定 -1 值意味着实用程序会根据 为代理配置的最大 磁盘用量检查磁盘用量。代理的最大磁盘用量是使用 broker.xml 配置文件中的 max-disk-usage 参数进行配置。为 max-disk-usage 指定的值代表允许使用代理的可用物理磁盘空间的百分比。

  3. 查看您可以在代理拓扑中为特定队列运行的检查列表。

    $ <broker-instance-dir>/bin/artemis help check queue

    您会看到输出来描述可与 artemis check queue 命令一起使用的一组选项。

    NAME
            artemis check queue - Check a queue
    
    SYNOPSIS
            artemis check queue [--browse <browse>] [--clientID <clientID>]
                    [--consume <consume>] [--fail-at-end] [--name <name>]
                    [--password <password>] [--produce <produce>] [--protocol <protocol>]
                    [--silent] [--timeout <timeout>] [--up] [--url <brokerURL>]
                    [--user <user>] [--verbose]
    
    OPTIONS
            --browse <browse>
                Number of the messages to browse or -1 to check that the queue is
                browsable
    
            --clientID <clientID>
                ClientID to be associated with connection
    
            --consume <consume>
                Number of the messages to consume or -1 to check that the queue is consumable
    
            --fail-at-end
                If a particular module check fails, continue the rest of the checks
    
            --name <name>
                Name of the target to check
    
            --password <password>
                Password used to connect
    
            --produce <produce>
                Number of the messages to produce
    
            --protocol <protocol>
                Protocol used. Valid values are amqp or core. Default=core.
    
            --silent
                It will disable all the inputs, and it would make a best guess for any required input
    
            --timeout <timeout>
                Time to wait for the check execution, in milliseconds
    
            --up
                Check that the queue exists and is not paused, it is executed by default if there are no other checks
    
            --url <brokerURL>
                URL towards the broker. (default: tcp://localhost:61616)
    
            --user <user>
                User used to connect
    
            --verbose
                Adds more information on the execution
  4. 实用程序可使用单个命令执行多个选项。例如,要检查本地代理上的默认 helloworld 队列中的 1000 信息,请使用以下命令:

    $ <broker-instance-dir>/bin/artemis check queue --name helloworld --produce 1000 --browse 1000 --consume 1000
    
    Connection brokerURL = tcp://localhost:61616
    Running QueueCheck
    Checking that a producer can send 1000 messages to the queue helloworld ... success
    Checking that a consumer can browse 1000 messages from the queue helloworld ... success
    Checking that a consumer can consume 1000 messages from the queue helloworld ... success
    Checks run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.882 sec - QueueCheck

    在前面的示例中,观察您在运行队列检查时没有指定代理 URL。如果您没有显式指定 URL,则 实用程序将使用默认值 tcp://localhost:61616

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.