Giter VIP home page Giter VIP logo

monitor_web's Introduction

项目

  • 当接口返回值和预期不一致时候,发送邮件报警

分析

  • 访问普通界面(无需登录)时,获取返回值,使用json解析,如果能解析并达到自己设定的大小/条数,认为正常,如果不对就出发报警。

  • 访问登录后的界面时,首先自动登录,获取session/cookie,带着session/cookie去访问,如果能解析并达到自己设定的大小/条数,认为正常,如果不对就出发报警。

  • 发送邮件的时候,使用异步发送,即主程序只执行触发发邮件的方法,具体发送邮件由异步调度软件去执行发邮件程序(主程序调celery的sendmail任务)。

  • 每分钟轮训一遍所需访问的接口,用crontab或者celery的Schedule。

项目组件

代码结构

代码结构

项目详解

1. Supervisor服务

  1. 服务功能 supervisor配置文件监听了两个任务: 其一是celery worker,现将发送邮件的任务准备起来,待到主项目调用的时候,直接执行。supervisor监控到这个进程消失,会主动重启。 其二是celery beat,这个是调用定时任务的模块,supervisor监控到这个进程消失,会主动重启。
  2. 配置文件 配置文件

2. Celery服务

Celery分成两部分功能来讲: 其一是主程序monitor_xx.py触发发邮件的时候调用celery worker. 其二是需要celery beat来定时执行主程序monitor_xx.py

  1. Celery文件说明 tree
  2. 任务文件tasks 任务文文件

3. 主程序monitor_tob_app

  • monitor_tob_app.py有详细注释

monitor_web's People

Contributors

anliming 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.