28.6. 创建和修改集群警报


以下示例流程创建警报、添加接收者、修改警报、删除警报并在每一步显示配置的警报。

虽然您必须在集群中的每个节点上安装警报代理,但您只需要运行 pcs 命令一次。

流程

  1. 创建简单警报。由于没有指定报警 ID 值,系统会创建 alert 的报警 ID 值。

    # pcs alert create path=/my/path
    Copy to Clipboard Toggle word wrap
  2. 向警报添加一个接收者 rec_value 。由于这个命令没有指定接收者 ID,因此 alert-recipient 的值被用作接收者 ID。

    # pcs alert recipient add alert value=rec_value
    Copy to Clipboard Toggle word wrap
  3. 向警报添加第二个接收者 rec_value2 。此命令为接收者指定 my-recipient 的接收者 ID。

    # pcs alert recipient add alert value=rec_value2 id=my-recipient
    Copy to Clipboard Toggle word wrap
  4. 显示警报配置。

    # pcs alert config
    Alerts:
     Alert: alert (path=/my/path)
      Recipients:
       Recipient: alert-recipient (value=rec_value)
       Recipient: my-recipient (value=rec_value2)
    Copy to Clipboard Toggle word wrap
  5. 添加第二个警报,警报 ID 为 my-alert

    # pcs alert create id=my-alert path=/path/to/script description=alert_description options option1=value1 opt=val meta timeout=50s timestamp-format="%H%B%S"
    Copy to Clipboard Toggle word wrap
  6. 为第二个报警添加一个接收者值为 my-other-recipient 的接收者。因为没有指定接收者 ID,系统会提供接收者 ID my-alert-recipient

    # pcs alert recipient add my-alert value=my-other-recipient
    Copy to Clipboard Toggle word wrap
  7. 显示警报配置。

    # pcs alert
    Alerts:
     Alert: alert (path=/my/path)
      Recipients:
       Recipient: alert-recipient (value=rec_value)
       Recipient: my-recipient (value=rec_value2)
     Alert: my-alert (path=/path/to/script)
      Description: alert_description
      Options: opt=val option1=value1
      Meta options: timestamp-format=%H%B%S timeout=50s
      Recipients:
       Recipient: my-alert-recipient (value=my-other-recipient)
    Copy to Clipboard Toggle word wrap
  8. 修改警报 my-alert 的警报值。

    # pcs alert update my-alert options option1=newvalue1 meta timestamp-format="%H%M%S"
    Copy to Clipboard Toggle word wrap
  9. 修改接收者 my-alert-recipient 的警报值。

    # pcs alert recipient update my-alert-recipient options option1=new meta timeout=60s
    Copy to Clipboard Toggle word wrap
  10. 显示警报配置。

    # pcs alert
    Alerts:
     Alert: alert (path=/my/path)
      Recipients:
       Recipient: alert-recipient (value=rec_value)
       Recipient: my-recipient (value=rec_value2)
     Alert: my-alert (path=/path/to/script)
      Description: alert_description
      Options: opt=val option1=newvalue1
      Meta options: timestamp-format=%H%M%S timeout=50s
      Recipients:
       Recipient: my-alert-recipient (value=my-other-recipient)
        Options: option1=new
        Meta options: timeout=60s
    Copy to Clipboard Toggle word wrap
  11. alert 中删除接收者 my-alert-recipient

    # pcs alert recipient remove my-recipient
    Copy to Clipboard Toggle word wrap
  12. 显示警报配置。

    # pcs alert
    Alerts:
     Alert: alert (path=/my/path)
      Recipients:
       Recipient: alert-recipient (value=rec_value)
     Alert: my-alert (path=/path/to/script)
      Description: alert_description
      Options: opt=val option1=newvalue1
      Meta options: timestamp-format="%M%B%S" timeout=50s
      Recipients:
       Recipient: my-alert-recipient (value=my-other-recipient)
        Options: option1=new
        Meta options: timeout=60s
    Copy to Clipboard Toggle word wrap
  13. 从配置中删除警报 myalert

    # pcs alert remove myalert
    Copy to Clipboard Toggle word wrap
  14. 显示警报配置。

    # pcs alert
    Alerts:
     Alert: alert (path=/my/path)
      Recipients:
       Recipient: alert-recipient (value=rec_value)
    Copy to Clipboard Toggle word wrap
返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat