Go Shell Makefile Other
itchyny Merge pull request #166 from mackerelio/omit-symbol-table
Omit symbol table and debug information from the executable
Latest commit 6f843c9 Jul 26, 2018
Permalink
Failed to load latest commit information.
example Add example Oct 26, 2014
logger Lint logger package Dec 7, 2014
packaging ready for next release and update changelogs. version: 0.31.1 Jul 4, 2018
plugin Merge pull request #150 from fujiwara/upgrade Mar 16, 2018
script Update Mackerel::ReleaseUtils to check git workspace is clean Sep 5, 2017
test Prefer apibase in mackerel-agent confFile Aug 30, 2017
.gitignore add coveralls settings Oct 22, 2015
.travis.yml build with Go 1.10 Jun 11, 2018
CHANGELOG.md ready for next release and update changelogs. version: 0.31.1 Jul 4, 2018
Dockerfile name build stage in Dockerfile Jul 26, 2018
LICENSE Add apache V2 license Dec 7, 2014
Makefile omit symbol table and debug information from the executable Jul 26, 2018
README.md tweak Docker usage Jul 9, 2018
RELEASE.md Add release document Jun 18, 2015
alerts.go change monitor thresholds to pointers to follow the changes in the ma… Feb 22, 2018
alerts_test.go update tests for monitors and alerts Feb 22, 2018
annotations.go add title as a necessary parameter Feb 14, 2017
appveyor.yml Specify go 1.10 explicitly on AppVeyor CI Jun 11, 2018
commands.go Retry when API request failed Jun 13, 2018
commands_test.go check len(c.Flags) for c.ArgsUsage check Feb 10, 2017
config.go Use new API BaseURL Oct 2, 2017
config_test.go Add metrics command Oct 11, 2017
dashboards.go [dashboards] Add unit to expression graph Aug 18, 2017
dashboards_test.go [dashboards] Add unit to expression graph Aug 18, 2017
format.go change `createdAt` to ISO 8601 extended format Apr 3, 2018
format_test.go change `createdAt` to ISO 8601 extended format Apr 3, 2018
mkr.go Log error recursively and exit with error code, when command returns err Oct 10, 2017
monitors.go Merge pull request #85 from haya14busa/improve-help-doc-management Feb 13, 2017
monitors_test.go update tests for monitors and alerts Feb 22, 2018
throw.go fix option name Jul 4, 2018
throw_test.go fix vet/lint Jun 29, 2018
version.go ready for next release and update changelogs. version: 0.31.1 Jul 4, 2018

README.md

mkr

Latest Version Build Status Go Documentation

mkr - Command Line Tool For Mackerel written in Go.

DESCRIPTION

mkr is a command-line interface tool for the Mackerel API written in Go. mkr helps to automate tedious daily server operations to best leverage Mackerel's and Unix's tools. mkr output format is JSON, so it can be filtered with a JSON processor such as jq.

INSTALLATION

Install the plugin package from either the yum or the apt repository.

CentOS 5/6

curl -fsSL https://mackerel.io/assets/files/scripts/setup-yum.sh | sh
yum install mkr

Debian 6/7

curl -fsSL https://mackerel.io/assets/files/scripts/setup-apt.sh | sh
apt-get install mkr

Homebrew

You can also install from the brew rule we maintain, but we don't officially support the environment.

brew tap mackerelio/mackerel-agent
brew install mkr

Build from source

$ go get github.com/mackerelio/mkr
$ go install github.com/mackerelio/mkr

USAGE

First the MACKEREL_APIKEY environment variable must be set. It is not necessary to set the MACKEREL_APIKEY on hosts running mackerel-agent. For more details, see below.

export MACKEREL_APIKEY=<Put your API key>

EXAMPLES

mkr status <hostId>
{
    "id": "2eQGEaLxiYU",
    "name": "myproxy001",
    "status": "standby",
    "roleFullnames": [
        "My-Service:proxy"
    ],
    "isRetired": false,
    "createdAt": "2014-11-15T21:41:00+09:00"
}
mkr hosts --service My-Service --role proxy
[
    {
        "id": "2eQGEaLxiYU",
        "name": "myproxy001",
        "status": "standby",
        "roleFullnames": [
            "My-Service:proxy"
        ],
        "isRetired": false,
        "createdAt": "2014-11-15T21:41:00+09:00"
    },
    {
        "id": "2eQGDXqtoXs",
        "name": "myproxy002",
        "status": "standby",
        "roleFullnames": [
            "My-Service:proxy"
        ],
        "isRetired": false,
        "createdAt": "2014-11-15T21:41:00+09:00"
    },
]

The format of createdAt uses ISO-8601 in the current time zone.

The mkr hosts command has an '-f' option to format the output.

mkr hosts -f '{{range .}}{{if (len .Interfaces)}}{{(index .Interfaces 0).IPAddress}}{{end}}{{"\t"}}{{.Name}}{{"\n"}}{{end}}'
10.0.1.1  myproxy001
10.0.1.2  myproxy002
...
mkr create --status working -R My-Service:db-master mydb001
mkr update --status maintenance --roleFullname My-Service:db-master <hostId>
cat <<EOF | mkr throw --host <hostId>
<name>  <value> <time>
<name>  <value> <time>
EOF
...

cat <<EOF | mkr throw --service My-Service
<name>  <value> <time>
<name>  <value> <time>
EOF
...
mkr fetch --name loadavg5 2eQGDXqtoXs
{
    "2eQGDXqtoXs": {
        "loadavg5": {
            "time": 1416061500,
            "value": 0.025
        }
    }
}
mkr retire <hostId> ...

Examples (on hosts running mackerel-agent)

Specifying the and MACKEREL_APIKEY is not necessary because mkr refers to /var/lib/mackerel-agent/id and /etc/mackerel-agent/mackerel-agent.conf instead of specifying manually.

mkr status
mkr update --status maintenance <hostIds>...
mkr fetch --name loadavg5 <hostId>
cat <<EOF | mkr throw --host <hostId>
<name>  <value> <time>
EOF
mkr retire

ADVANCED USAGE

$ mkr update --st working $(mkr hosts -s My-Service -r proxy | jq -r '.[].id')

Using Docker Image

https://registry.hub.docker.com/u/mackerel/mkr/

$ docker run --rm --env MACKEREL_APIKEY=<API key> mackerel/mkr help

CONTRIBUTION

  1. Fork (https://github.com/mackerelio/mkr/fork)
  2. Create a feature branch
  3. Commit your changes
  4. Rebase your local changes against the master branch
  5. Run test suite with the go test ./... command and confirm that it passes
  6. Run gofmt -s
  7. Create new Pull Request

License

Copyright 2014 Hatena Co., Ltd.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.