sms-provider

@ 最近测试 open-falcon. 
@ 首先得准备报警接口.

sms-provider

  • 邮件发送http接口:
method: post  
  • params:

    • content: 邮件内容
    • subject: 邮件标题
    • tos: 使用逗号分隔的多个邮件地址  
  • falcon将这样调用该接口:

url=您公司提供的http邮件接口  
curl -X POST $url -d "content=xxx&tos=xxx@gmail.com,user@example.com&subject=xxx"  

django

  • 定义url
(r'^monitor/mail$', views.mail),
  • 定义views
def mail(request):

   content = request.POST.get("content")
   tos = request.POST.get("tos")
   subject = request.POST.get("subject")
   try:
        send_mail(subject, content, 'xxxx@xxx.com', ['%s'%tos], fail_silently=False)
        log = {"log":"ok"}
        return HttpResponse(json.dumps(log),content_type='application/json')
    except Exception,e:
        error = {"error": e}
        return HttpResponse(json.dumps(error),content_type='application/json')

PostMan进行测试

posted @ 2016-05-21 20:33  fengjian1585  阅读(384)  评论(0编辑  收藏  举报