发布时间:2026-10-12
不想每个自动化写死标题、消息内容。编写一个通用脚本,自动化调用时传入标题与消息内容,统一走PushPlus推送。
使用 script 脚本,接收变量 title、message,调用REST notify服务推送到微信。
自动化只需要调用脚本并传入参数,解耦推送渠道和告警逻辑。
notify:
- platform: rest
name: pushplus_notify
resource: https://www.pushplus.plus/send
method: POST
headers:
Content-Type: application/json
payload: >-
{
"token": "你的pushplus token",
"title": "{{ title }}",
"content": "{{ message }}",
"template": "html"
}
pushplus_send:
fields:
title:
description: 消息标题
example: 主机离线告警
message:
description: 消息正文
example: 服务器主机网络离线
sequence:
- service: notify.pushplus_notify
data:
title: "{{ title }}"
message: "{{ message }}"
action:
- service: script.pushplus_send
data:
title: "主机离线告警"
message: "监控主机 {{ trigger.to_state.name }} 网络离线"