Code Monkey home page Code Monkey logo

wechat-sender's Introduction

wechat-sender

Nightingale的理念,是将告警事件扔到redis里就不管了,接下来由各种sender来读取redis里的事件并发送,毕竟发送报警的方式太多了,适配起来比较费劲,希望社区同仁能够共建。

这里提供一个微信的sender,参考了https://github.com/yanjunhui/chat,具体如何获取企业微信信息,也可以参看yanjunhui这个repo

compile

cd $GOPATH/src
mkdir -p github.com/n9e
cd github.com/n9e
git clone https://github.com/n9e/wechat-sender.git
cd wechat-sender
go build

如上编译完就可以拿到二进制了。

configuration

直接修改etc/wechat-sender.yml即可。另外n9e-monapi这个模块默认的发送通道只打开了mail,如果要同时使用im,需要在notify这里打开相关配置:

notify:
  p1: ["mail", "im"]
  p2: ["mail", "im"]
  p3: ["mail", "im"]

pack

编译完成之后可以打个包扔到线上去跑,将二进制和配置文件打包即可:

tar zcvf wechat-sender.tar.gz wechat-sender etc/wechat-sender.yml etc/wechat.tpl

test

配置etc/wechat-sender.yml,相关配置修改好,我们先来测试一下是否好使, ./wechat-sender -t <toUser>,程序会自动读取etc目录下的配置文件,发一个测试消息给toUser

run

如果测试发送没问题,扔到线上跑吧,使用systemd或者supervisor之类的托管起来,systemd的配置实例:

$ cat wechat-sender.service
[Unit]
Description=Nightingale wechat sender
After=network-online.target
Wants=network-online.target

[Service]
User=root
Group=root

Type=simple
ExecStart=/home/n9e/wechat-sender
WorkingDirectory=/home/n9e

Restart=always
RestartSec=1
StartLimitInterval=0

[Install]
WantedBy=multi-user.target

wechat-sender's People

Contributors

lahcloud avatar nondevops avatar ulricqin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.