Giter Club home page Giter Club logo

show-mackerel's Introduction

show-mackerel

Description

Show mackerel monitor setting and agent checkplugin settings by markdown format.

caution: Host type monitor setting only can be parsed. Service type and external type can't be parsed.

Build

$ go get github.com/suzukiyuzs/show-mackerel
$ cd $GOPATH/src/github.com/suzukiyuzs/show-mackerel
$ go build .

Help

$ ./show-mackerel -h
Usage:
  show-mackerel [OPTIONS]

Application Options:
  -m, --mackerel= Mackerel type(check or monitor)
  -f, --file=     Mackerel file path

Help Options:
  -h, --help      Show this help message

$
  • Mackerel type option:
    • check: Show mackerel agent checkplugin setting
    • monitor: Show mackerel monitor setting

Example

Show agent checkplugin settings

$ cat ./check-pluguin
[plugin.checks.ssh]
command = "ruby /path/to/check-ssh.rb"
notification_interval = 60
max_check_attempts = 1
check_interval = 5
timeout_seconds = 45
prevent_alert_auto_close = true
env = { HOST = "hostname", PORT = "port" }
action = { command = "ruby /path/to/notify_something.rb", env = { NOTIFY_API_KEY = "API_KEY" } }
memo = "This check monitor is ..."
$
$ ./show-mackerel -m check -f ./check-pluguin
# Mackerel check plugin
| Name |          Command           | NotificationInterval | MaxCheckAttempts | CheckInterval | TimeoutSeconds | PreventAlertAutoClose |           Env            |          Action.Command           | Action.TimeoutSeconds |       Action.Env       |           Memo            |
|------|----------------------------|----------------------|------------------|---------------|----------------|-----------------------|--------------------------|-----------------------------------|-----------------------|------------------------|---------------------------|
| ssh  | ruby /path/to/check-ssh.rb |                   60 |                1 |             5 | 45s            | true                  | HOST=hostname, PORT=port | ruby /path/to/notify_something.rb | 0s                    | NOTIFY_API_KEY=API_KEY | This check monitor is ... |
$

Show monitor settings

$ export MACKEREL_APIKEY=<Mackerel API Key>
$ mkr monitors pull
$ cat monitors
{
    "monitors": [
        {
            "id": "3pd4qrKKhRw",
            "id": "0123456789a",
            "name": "disk.aa-00.writes.delta",
            "memo": "This monitor is ...",
            "type": "host",
            "duration": 3,
            "metric": "disk.aa-00.writes.delta",
            "operator": ">",
            "warning": 20000.0,
            "critical": 400000.0,
            "maxCheckAttempts": 3,
            "notificationInterval": 60,
            "scopes": [
                "Hatena-Blog"
            ],
            "excludeScopes": [
                "Hatena-Bookmark: db-master"
            ]
        }
    ]
}
$
$ ./show-mackerel -m monitor -f ./monitors.json
# Mackerel monitor
|     ID      |          Name           |        Memo         | Type | IsMute | NotificationInterval |         Metric          | Operator | Warning | Critical | Duratoin | MaxCheckAttempts |   Scopes    |       ExcludeScopes        |
|-------------|-------------------------|---------------------|------|--------|----------------------|-------------------------|----------|---------|----------|----------|------------------|-------------|----------------------------|
| 0123456789a | disk.aa-00.writes.delta | This monitor is ... | host | false  |                   60 | disk.aa-00.writes.delta | >        |   20000 |   400000 |        3 |                3 | Hatena-Blog | Hatena-Bookmark: db-master |
$

show-mackerel's People

Contributors

suzukiyuzs avatar

Watchers

James Cloos avatar  avatar

show-mackerel's Issues

go get github.com/suzukiyuzs/show-mackerelでビルドに失敗します。

よろしくお願いします。
以下のようにビルドに失敗します。

$ go get github.com/suzukiyuzs/show-mackerel
# github.com/suzukiyuzs/show-mackerel/lib
src/github.com/suzukiyuzs/show-mackerel/lib/check.go:79:11: invalid operation: memo != nil (mismatched types string and nil)
src/github.com/suzukiyuzs/show-mackerel/lib/check.go:80:15: invalid indirect of memo (type string)

goのバージョンは以下の2つで実施しました。
go1.9.4
go1.12.1

go envの結果は以下になります。

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/ec2-user/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/ec2-user/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build514494546=/tmp/go-build -gno-record-gcc-switches"

以上です。

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.