V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
kingapi
V2EX  ›  分享创造

你的小项目是否为日志监控报警而烦恼?开源小工具来啦! 7M 大小、3 分钟部署。

  •  
  •   kingapi · 2020-07-22 21:26:19 +08:00 · 2833 次点击
    这是一个创建于 1345 天前的主题,其中的信息可能已经有所发展或是发生改变。

    marx-agent

    一款日志文件监控报警(支持企业微信机器人、钉钉机器人等)工具。

    优势

    • 体积小巧仅 7M
    • 部署简单仅需 3 分钟
    • 监控报警程序与业务代码解耦
    • 免费、开源、安全

    快速使用

    编译

    • 方法一:
    git clone https://github.com/51daticom/marx-agent.git
    cd marx-agent
    export GO111MODULE=on
    export GOPROXY=https://goproxy.io
    go build -o marx-agent
    
    • 方法二:
    go get -u github.com/51daticom/marx-agent
    ls {GORPATH}/bin/marx-agent
    

    配置

    mv config.nginx.example.in config.ini;
    vim config.in
    
    [pro]
    buf = 1
    whiteList = ""
    blackList = "\ 500\ ","\ 502\ ","\ 501\ " #监控报警的状态码(正则匹配)
    log = /var/log/nginx/access.log  #监控的日志文件路径
    wxpush = https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={{youkey}} #企业微信机器人 webhook 地址
    dingpush =  #钉钉机器人 webhook 地址
    
    #/var/log/nginx/access.log format data such as:
    #127.0.0.1 - - [21/Jul/2020:05:57:48 +0800] "GET /thinkphp/html/public/index.php HTTP/1.1" 500 47 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.0;en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6)" "-" "0.001" "0.001
    
    

    启动监控报警

    ./max-agent config.ini pro
    

    项目地址

    https://github.com/51daticom/marx-agent

    5 条回复    2020-07-24 21:04:10 +08:00
    yifanes
        1
    yifanes  
       2020-07-22 21:33:53 +08:00 via iPhone
    从你们开源项目找到你家官网,可用点心吧,截图还有错位和裂图的
    kingapi
        2
    kingapi  
    OP
       2020-07-22 21:36:36 +08:00
    @yifanes 抱歉了老铁,自己不会 UI 设计[委屈]
    chucongqing
        3
    chucongqing  
       2020-07-23 09:15:11 +08:00   ❤️ 1
    file.go line 15
    var filebuf = make(chan byte, 2>>30)
    这个 2 >>30 有什么玄妙的用法吗?
    kingapi
        4
    kingapi  
    OP
       2020-07-23 11:16:04 +08:00
    @chucongqing 感谢 review 目前这个 buf 还没用到,2<<30 才为正确的,已修改。
    就随便定了一个 buffer size 。后续会把它配置化。
    mengzhuo
        5
    mengzhuo  
       2020-07-24 21:04:10 +08:00
    2>>30 = 0
    2<<30 这么大 buffer……
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2997 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 14:48 · PVG 22:48 · LAX 07:48 · JFK 10:48
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.