mackerel-agent is an agent program to post your hosts' metrics to mackerel.io.

Overview

mackerel-agent

agent-si

mackerel-agent is a client software for Mackerel. Mackerel is an online visualization and monitoring service for servers.

Once mackerel-agent is installed, it runs the following tasks on the installed host in foreground:

  • register your hosts to Mackerel
  • collect specs and metrics of those hosts and post them to Mackerel

Collected information will be visualized on Mackerel.

PREREQUISITES

You have to create an organization on Mackerel at first. After that, specify apikey value in mackerel-agent.conf with the following command.

% mackerel-agent init -apikey {{YOUR_APIKEY}}

SYNOPSIS

Build and Run the mackerel-agent.

% make build
% make run

You can run the following commands instead of using make.

% go get -d github.com/mackerelio/mackerel-agent
% go build -o build/mackerel-agent \
  -ldflags="\
    -X github.com/mackerelio/mackerel-agent/version.GITCOMMIT `git rev-parse --short HEAD` \
    -X github.com/mackerelio/mackerel-agent/version.VERSION   `git describe --tags --abbrev=0 | sed 's/^v//' | sed 's/\+.*$$//'` " \
  github.com/mackerelio/mackerel-agent
./build/mackerel-agent -conf=mackerel-agent.conf

On Windows

Use .bat files instead of make commands.

% build.bat

Test

Test mackerel-agent to confirm it's working properly.

The agent will collect information about the host on which it has been installed.

% make test

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.
Issues
  • Multi platform support

    Multi platform support

    This is experiment branch to support multi platform.

    • Some refactoring to separate metrics/spec generators
    • Separates metrics/spec generators for linux to independent packages
    opened by hakobe 15
  • fatal error: s.allocCount != s.nelems && freeIndex == s.nelems

    fatal error: s.allocCount != s.nelems && freeIndex == s.nelems

    I received this error twice. Is there a way to avoid this?

    I instlled mackerel-agent from binary. Ver: 042.3 CPU: 1 x ARM926EJ-S rev 4 (v5l) OS: GNU/Linux 3.10.37-3.10.37-klk4

    opened by toruuetani 13
  • Run once and output results to stdout

    Run once and output results to stdout

    Add -once option that mackerel-agent runs once and outputs results to stdout. This option is useful for developing and debugging mackerel-agent itself and plugins.

    Example of output is as follows.

    # build/mackerel-agent -once -conf=mackerel-agent.conf | jq .
    2015/03/08 12:46:46 INFO main Starting mackerel-agent version:0.14.3, rev:85bd358
    2015/03/08 12:46:46 INFO command Collecting metrics may take one minutes.
    {
      "host": {
        "interfaces": null,
        "meta": {
          "agent-name": "mackerel-agent/0.14.3 (Revision 85bd358)",
          "agent-revision": "85bd358",
          "agent-version": "0.14.3",
          "cpu": [
            {
              "model_name": "Intel(R) Core(TM) i7-3667U CPU @ 2.00GHz\n"
            }
          ],
          ...
    }
    
    opened by stanaka 8
  • graceful shutdown

    graceful shutdown

    Wait for termination until postQueue is empty up to 30 seconds.

    This patch is not perfect because it doesn't care postDelay, but good enough for first step.

    opened by Songmu 7
  • filesystem: failed to execute df command in OpenWrt (with BusyBox)

    filesystem: failed to execute df command in OpenWrt (with BusyBox)

    In OpenWrt, mackerel-agent fails to execute df command and prints a lot of warnings.

    log:

    2019/06/14 10:56:01 WARNING <util.filesystem> 'df -Pkl' command exited with a non-zero status: 1: "df: unrecognized option: l\nBusyBox v1.30.0 () multi-call binary.\n\nUsage: df [-PkmhT] [FILESYSTEM]...\n\nPrint filesystem usage statistics\n\n\t-P\tPOSIX output format\n\t-k\t1024-byte blocks (default)\n\t-m\t1M-byte blocks\n\t-h\tHuman readable (e.g. 1K 243M 2G)\n\t-T\tPrint filesystem type\n"
    ...
    

    BusyBox df in OpenWrt outputs df: unrecognized option: l as a warning, so it seems that it has slipped through the check in func init().

    opened by musashino205 6
  • Set environment variables for plugins

    Set environment variables for plugins

    Set environment variables when running plugin.

    The following is a config example.

    [plugin.metrics.mysql3]
    command = "ruby /path/to/your/plugin/mysql.rb"
    env = { "MYSQL_USERNAME" = "user", "MYSQL_PASSWORD" = "password" }
    
    [plugin.checks.heartbeat2]
    command = "heartbeat.sh"
    env = { "ES_HOSTS" = "10.45.3.2:9220,10.45.3.1:9230" }
    action = { command = "cardiac_massage", user = "doctor", env = { "NAME_1" = "value_1", "NAME_2" = "value_2", "NAME_3" = "value_3" } }
    
    [plugin.metadata.hostinfo2]
    command = "hostinfo.sh"
    env = { "NAME_1" = "value_1" }
    
    opened by hayajo 6
  • Add an option of timeout duration for executing command

    Add an option of timeout duration for executing command

    What

    This pull-request introduces the option for specifying a duration after which a command execution will be timeout.

    Why

    Running a slightly heavy check command will be easily timeout, so users should be able to adjust the timeout duration.

    opened by taku-k 5
  • Show CPU/SoC model name on Linux/MIPS

    Show CPU/SoC model name on Linux/MIPS

    When using mackerel-agent on Linux/MIPS, the CPU/SoC model name is "undefined" in the Mackerel console.

    image

    On Linux/MIPS, the output of /proc/cpuinfo is as follows:

    # cat /proc/cpuinfo
    system type		: Atheros AR7242 rev 1
    machine			: Buffalo BHR-4GRV
    processor		: 0
    cpu model		: MIPS 24Kc V7.4
    BogoMIPS		: 265.42
    wait instruction	: yes
    microsecond timers	: yes
    tlb_entries		: 16
    extra interrupt vector	: yes
    hardware watchpoint	: yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
    isa			: mips1 mips2 mips32r1 mips32r2
    ASEs implemented	: mips16
    shadow register sets	: 1
    kscratch registers	: 0
    package			: 0
    core			: 0
    VCED exceptions		: not available
    VCEI exceptions		: not available
    

    This is a slightly different result than the Linux/x86_64 architecture. The CPU/SoC model name is displayed as "system type", however mackerel-agent doesn't support it.

    This behavior can also be confirmed by checking the linux source code: arch/mips/kernel/proc.c .

    opened by hnw 5
  • Add metadata plugin feature

    Add metadata plugin feature

    previous pull request: #331

    This pull request adds support for metadata plugin. User now can configure metadata plugins and mackerel-agent posts the metadata periodically.

    opened by itchyny 5
  • Custom metrics input values should be split with space not tab

    Custom metrics input values should be split with space not tab

    According to the Mackerel document, custom metrics plugins should output tab-separated values as follows;

    {metric name}\t{metric value}\t{epoch seconds}
    

    but Sensu plugins using Sensu::Plugin::Metric::CLI::Graphite output space-separated values;

    https://github.com/sensu-plugins/sensu-plugin/blob/master/lib/sensu-plugin/metric/cli.rb#L26

    so if you say the format is "compatible with sensu", the parser should split values with spaces not tabs or both of them.

    https://github.com/mackerelio/mackerel-agent/blob/master/metrics/plugin.go#L231

    opened by doublemarket 5
  • Enhance windows installer

    Enhance windows installer

    • Remove installed files when uninstall mackerel-agent.
    • Generate config file only if clean installation.
    • Auto fill version into the wxs file from git tag.
    opened by mechairoi 5
  • `host.meta.interfaces` is null when use `ifconfig`

    `host.meta.interfaces` is null when use `ifconfig`

    Overview

    The metric host.meta.interfaces are always null on the particular host.

    This problem seems to occur on the hosts satisfy the following conditions.

    • not installed ip command
    • installed ifconfig command
    • a newer version of Linux (maybe)

    Output of mackerel-agent

    The following log shows mackerel-agent outputs the metrics without proper .host.meta.interfaces. It is expected .host.meta.interfaces have valid information of the NICs of host, but it always be null.

    [email protected]:~$ cat /etc/issue
    Ubuntu 18.04.3 LTS \n \l
    [email protected]:~$ uname -r
    5.0.0-25-generic
    [email protected]:~$ docker run --rm -it mackerel/mackerel-agent mackerel-agent once -apikey=dummy | jq .host.meta.interfaces
    null
    

    Consideration

    It seems caused by mismatched Regexp on here (https://github.com/mackerelio/mackerel-agent/blob/master/spec/linux/interface.go#L97-L100).

    This Regexp expects the section of IP addresses begins with inet addr but it seems to begin with inet in the newer version of Linux.

    On Debian Jessie, the section of IP address begins with inet addr. But on Debian Stretch, it begins with inet.

    [email protected]:~$ docker run --rm -it debian:jessie-slim sh -c "apt update;apt install net-tools;ifconfig -a"
    (omit apt logs)
    eth0      Link encap:Ethernet  HWaddr 02:42:ac:11:00:02
              inet addr:172.17.0.2  Bcast:172.17.255.255  Mask:255.255.0.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:817 errors:0 dropped:0 overruns:0 frame:0
              TX packets:364 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:10517296 (10.0 MiB)  TX bytes:25479 (24.8 KiB)
    
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    [email protected]:~$ docker run --rm -it debian:stretch-slim sh -c "apt update;apt install net-tools;ifconfig -a"
    (omit apt logs)
    eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
            ether 02:42:ac:11:00:02  txqueuelen 0  (Ethernet)
            RX packets 508  bytes 8413071 (8.0 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 256  bytes 18348 (17.9 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            loop  txqueuelen 1000  (Local Loopback)
            RX packets 0  bytes 0 (0.0 B)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 0  bytes 0 (0.0 B)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    opened by xruins 1
  • `setup-all-apt-v2.sh` uses the deprecated `apt-key` command

    `setup-all-apt-v2.sh` uses the deprecated `apt-key` command

    I'm sorry if this is not the right place to report issues related to setup-all-apt-v2.sh, which is not part of this repository, but I was not aware of anywhere else better.

    The installer script setup-all-apt-v2.sh currently uses the apt-key command to add the repository's key to APT's trusted keyring, but this method has been deprecated due to security reasons. According to the Debian's document the recommend method is to create a new GPG key ring in some location (such as /usr/share/keyrings/mackerel.gpg) and then pin the repository signature to it in the APT source file

    deb [arch=amd64,arm64 signed-by=/usr/share/keyrings/mackerel.gpg] http://apt.mackerel.io/v2/ mackerel contrib
    

    PS: I am not a security expert nor a Debian committer so I can't take responsibility for the correctness of the above method.

    opened by cktkw 1
Releases(v0.72.14)
AutoK3s GEO collects metrics about locates remote IP-address and exposes metrics to InfluxDB.

AutoK3s GEO AutoK3s GEO collects metrics about locates remote IP-address and exposes metrics to InfluxDB. Thanks to https://freegeoip.live/ which prov

Jason 0 Jun 16, 2022
GoC2 - MacOS Post Exploitation C2 Framework

goc2 c2 client/server/paylod GoC2 - MacOS Post Exploitation C2 Framework Custom C2 for bypassing EDR and ease of use.

Brian Stegemoller 34 Jun 1, 2022
Code for the Go pipeline blog post

Concurrent and Parallel Pipelines in Go This repository contains the code that goes along with a blog post about concurrent and parallel pipelines in

AMBOSS 6 Mar 20, 2022
Joy2Mouse is a program that allows you to control your computer mouse with a joystick.

Joy2Mouse Joy2Mouse is a program that allows you to control your computer mouse with a joystick. Features Control your mouse with a joystick Mouse dow

Abby 4 Dec 26, 2021
Host yo' self from your browser, your phone, your toaster.

A hosting service from the browser, because why not. Try it at hostyoself.com. See it in action Here's an example where I use hostyoself.com to host i

Zack 1.7k Jun 28, 2022
Configuration agent for BFE control plane

conf-agent conf-agent 说明 conf-agent 从 api-server 获取最新的配置并触发bfe热加载。 获取方式 获取 conf-agent 工具。获取 conf-agent 有多种方式: 在 releases 页面下载对应平台的可执行文件 通过 go get 工具本地

null 14 Mar 29, 2022
This is a monitor agent for N9E

n9e-agentd This is a monitor agent for N9E Download Build from source $ make pkg $ ls build/ linux-amd64/ n9e-agentd n9e-agentd-5.1.0-rc1.linux.amd

null 32 May 31, 2022
Type-safe Prometheus metrics builder library for golang

gotoprom A Prometheus metrics builder gotoprom offers an easy to use declarative API with type-safe labels for building and using Prometheus metrics.

Cabify 93 Jun 9, 2022
Go port of Coda Hale's Metrics library

go-metrics Go port of Coda Hale's Metrics library: https://github.com/dropwizard/metrics. Documentation: http://godoc.org/github.com/rcrowley/go-metri

Richard Crowley 3.2k Jun 21, 2022
A tool to run queries in defined frequency and expose the count as prometheus metrics.

A tool to run queries in defined frequency and expose the count as prometheus metrics. Supports MongoDB and SQL

S Santhosh Nagaraj 18 Apr 21, 2022
Prometheus support for go-metrics

go-metrics-prometheus This is a reporter for the go-metrics library which will post the metrics to the prometheus client registry . It just updates th

Csergő Bálint 68 Jun 11, 2022
a tool for getting metrics in containers

read metrics in container if environment is container, the cpu ,memory is relative to container, else the metrics is relative to host. juejing link :

null 7 Feb 7, 2022
Collect and visualize metrics from Brigade 2

Brigade Metrics: Monitoring for Brigade 2 Brigade Metrics adds monitoring capabilities to a Brigade 2 installation. It utilizes Brigade APIs to export

Brigade 4 Mar 17, 2022
Count Dracula is a fast metrics server that counts entries while automatically expiring old ones

In-Memory Expirable Key Counter This is a fast metrics server, ideal for tracking throttling. Put values to the server, and then count them. Values ex

Mailsac 51 Jun 17, 2022
rsync wrapper (or output parser) that pushes metrics to prometheus

rsync-prom An rsync wrapper (or output parser) that pushes metrics to prometheus. This allows you to then build dashboards and alerting for your rsync

Michael Stapelberg 24 May 31, 2022
Service for firewalling graphite metrics

hadrianus Block incoming graphite metrics if they come in too fast for downstream carbon-relay/carbon-cache to handle. Building Hadrianus is written i

Kambi 7 Apr 28, 2022
The gofinder program is an acme user interface to search through Go projects.

The gofinder program is an acme user interface to search through Go projects.

null 22 Jun 14, 2021
Visualize call graph of a Go program using Graphviz

go-callvis go-callvis is a development tool to help visualize call graph of a Go program using interactive view. Introduction The purpose of this tool

Ondrej Fabry 4.1k Jun 22, 2022
Toy program for benchmarking safe and unsafe ways of saving a file

save-a-file benchmarks the many strategies an editor could use to save a file. Example output on a SSD: ext4: $ ./save-a-file ~/tmp/foo 29.195µs per s

null 2 Sep 13, 2021