GithubHelp home page GithubHelp logo

yhidetoshi / mackerelalertproclisttool Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 236 KB

mackerel-client-goを利用したCPU/Memアラートプロセスリスト通知ツールを作った

Go 86.51% Makefile 13.49%
mackerel-client-go

mackerelalertproclisttool's Introduction

Build Status

mackerelAlertProcListTool

Blog: MackerelのCPU・Memoryアラート発生時にそれぞれの高負荷なプロセスをSlackに通知するツールを作った

  • 目的
    • MackerelでCPU/Mem使用率のアラートが発生した場合にSlackにCPU/MEM使用率の高いプロセスリストをPostさせる
  • 実装
    • mackerel-client-go を利用してツールを作成
    • mackerel-agentのidをインスタンス内部で取得します。(今回はUbuntuのパスを指定)他のディストリビューションの場合は修正が必要です。
    • systemdのtimerで1分に1回実行させる
    • アラート発生から3分以内は毎分通知する。(アラートが発生し続けていると何度も通知しないようにするため)
    • Mackerelのアラート一覧に自インスタンスのmackerel-idがあるかチェック
    • 自インスタンスのアラートが存在する場合、アラートの種類が CPU % / Memory & で 管理画面の閾値設定値を超えている場合はSlackに以下のコマンド実行結果とホスト名、cpu使用率の内訳をPostする
      • ps aux --sort -%cpu | head -n 6
      • ps aux --sort -%mem | head -n 6

Usage

> $ main -slackurl=<SLACKURL>
  • MACKEREL_API_KEY は systemdで実行するときに環境変数をセットする

Slack通知の結果

CPUアラート時の通知結果

monitor一覧結果

Memアラート時の通知結果

monitor一覧結果

mackerelalertproclisttool's People

Contributors

yhidetoshi avatar

Watchers

James Cloos avatar  avatar

mackerelalertproclisttool's Issues

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.