Red Hat Training

A Red Hat training course is available for RHEL 8

27.6. 集群警报配置命令示例

以下后续示例演示了一些基本警报配置命令,以显示用于创建警报、添加接收方和显示配置的警报的格式。

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

以下命令创建了一个简单的警报,为警报添加两个接受者,并显示配置的值。

  • 由于没有指定警报 ID 值,系统会创建警报的警报 ID 值
  • 第一个接收者创建命令指定 rec_value 的接收者。由于这个命令没有指定接收者 ID,alert-recipient 的值被用作接收者 ID。
  • 第二个接收者创建命令指定 rec_value2 的接收者。此命令 为接收者指定 my- repient 的接收者 ID。
# pcs alert create path=/my/path
# pcs alert recipient add alert value=rec_value
# pcs alert recipient add alert value=rec_value2 id=my-recipient
# pcs alert config
Alerts:
 Alert: alert (path=/my/path)
  Recipients:
   Recipient: alert-recipient (value=rec_value)
   Recipient: my-recipient (value=rec_value2)

以下命令添加第二个警报以及该警报的接收者。第二个警报的警报 ID 是 my-alert,接收者值为 my-other-recipient。因为没有指定接收者 ID,系统会提供接收者 ID my-alert-recipient

# 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"
# pcs alert recipient add my-alert value=my-other-recipient
# 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)

以下命令修改警报 my-alert 和接收者 my-alert -recipient 的警报值。

# pcs alert update my-alert options option1=newvalue1 meta timestamp-format="%H%M%S"
# pcs alert recipient update my-alert-recipient options option1=new meta timeout=60s
# 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

以下命令从 警报 中删除接收者 my-alert-recipient

# pcs alert recipient remove my-recipient
# 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

以下命令将从配置中删除 myalert

# pcs alert remove myalert
# pcs alert
Alerts:
 Alert: alert (path=/my/path)
  Recipients:
   Recipient: alert-recipient (value=rec_value)