44

如何使用serverchan微信推送告警

 5 years ago
source link: https://www.linuxprobe.com/serverchan-waring-tui.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

之前实现推送告警信息到微信的方法有如下几种:

1、通过企业公众号实现----收费:

2、通过QQ邮箱,在微信平台上开启收到邮件进行提醒;

3、第三方告警平台API,一般也是收费的;

不过最近看文档时,发现serverchan应用,其原理属于第三种,不过其是免费的,而且操作步骤非常简单。先看下效果:

Serverchan配置步骤

  1. 登入:用GitHub账号登入网站,就能获得一个SCKEY(在「发送消息」页面)
  2. 绑定:点击「微信推送」,扫码关注同时即可完成绑定
  3. 发消息:往 http://sc.ftqq.com/SCKEY.send 发GET请求,就可以在微信里收到消息啦

发送消息非常简单,只需要向以下URL发一个GET或者POST请求:https://sc.ftqq.com/SCKEY.send

接受两个参数:

text:消息标题,最长为256,必填。
desp:消息内容,最长64Kb,可空,支持MarkDown。

最简单的消息发送方式是通过浏览器,在地址栏输入以下URL,回车后即可发送,例如:

https://sc.ftqq.com/SCKEY.send?text=恭喜发财&desp=www.361way.com站点还是不错的

在具体调用的时候可以直接curl 直接调用该URL,也可以使用 shell 做一个简单的函数封装,例如:

send(){
key=your key id
title=运维之路可用性监控
content=www.361way.com暂时不可用,赶快检查
curl "http://sc.ftqq.com/$key.send?text=$title&desp=$content" >/dev/null 2>&1 &
}

在使用的时候,直接send调用就行了。

serverchan官方页面也提供了php调用的示例。本身get方法无论在任何语言里调用都不复杂。其很方便的可以在任何语言下进行接口连接。

sererchan也提供了一对多的发送服务 ------ PushBear ,不过其每天只有1000条发送的上限。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK