Raspberry PiにMackerelを導入する
2020/12/01
Raspberry Piだって一応サーバーということでサーバー管理・監視サービスのMackerelを導入してみた。
とりあえずモニタリングができる状態までで、監視ルールの設定はしていない。
環境
- Raspberry Pi 4 Model B
- Raspberry Pi OS 10.6
手順
mackerel-agentのダウンロードとインストール
$ curl -sL https://github.com/mackerelio/mackerel-agent/releases/latest/download/mackerel-agent_linux_arm.tar.gz | tar xz
$ cd mackerel-agent_linux_arm
$ sudo cp mackerel-agent /usr/local/bin
$ sudo mkdir /etc/mackerel-agent
$ sudo cp mackerel-agent.conf /etc/mackerel-agent
$ mackerel-agent version
mackerel-agent version 0.70.3 (rev 4c4f91f) [linux arm go1.14.12]
mackerel-agentのセットアップ
sudo mackerel-agent init -apikey="YOUR API KEY"
サービスの設定
$ vim /etc/systemd/system/mackerel-agent.service
/etc/systemd/system/mackerel-agent.service
[Unit]
Description=mackerel-agent
After=network.target network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/mackerel-agent
ExecReload=/bin/kill -HUP $MAINPID
KillMode=control-group
Restart=on-failure
[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
起動
$ sudo systemctl start mackerel-agent
$ sudo systemctl status mackerel-agent
● mackerel-agent.service - mackerel-agent
Loaded: loaded (/etc/systemd/system/mackerel-agent.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-12-01 00:44:51 JST; 6min ago
Main PID: 1856 (mackerel-agent)
Tasks: 7 (limit: 4915)
CGroup: /system.slice/mackerel-agent.service
└─1856 /usr/local/bin/mackerel-agent
自動起動設定
$ sudo systemctl enable mackerel-agent
Created symlink /etc/systemd/system/multi-user.target.wants/mackerel-agent.service → /etc/systemd/system/mackerel-agent.service.