5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VyOSをmackerelで監視する

Posted at

本手順は以下のバージョンで作成している。

  • Linux vyos 3.3.8-1-amd64-vyatta

目的

ルーターとかで使うVyOSの監視をmackerelで行いたい。
特にそれ以上の理由は無い。

Nagiosでいいじゃんとか、SNMP使えよとか、色々意見はあるだろうけど、mackerelで管理したいのだ。

インストール

下記作業は、対象ホストにssh等で特権ユーザーでログインして行うものとする。

注意

基本的に公式のdebパッケージの手順で良いのだが、注意がある。
公式ではshにパイプしているが、vyosではshコマンドはラッパーに喰われている(下記)ので、shと記載のある場合は全てbashに置き換える必要がある。

$ type sh
sh is aliased to `_vyatta_op_run sh'

今後の手順更新に対して上記方法で追従できる保証はない。

インストール

作業ユーザーでログインしているなら、root権限のbashを起動する。

$ sudo bash

aptのリポジトリ登録をbashで実行する。

$ curl -fsSL https://mackerel.io/assets/files/scripts/setup-apt.sh | bash

そして必要なパッケージをインストールする。

$ apt-get install mackerel-agent
$ apt-get install mackerel-agent-plugins
$ apt-get install mackerel-check-plugins
$ apt-get install mkr

設定

最低限APIキーは設定が必要。他に関しては、各々のお好きなように。
以下に参考を示す。

mackerel-agent.conf
apikey = "あなたのAPIキー"

# Plugin for Linux
[plugin.metrics.linux]
command = "/usr/local/bin/mackerel-plugin-linux"

#
# Process Checks
#
[plugin.checks.bgpd_procs]
command = "/usr/local/bin/check-procs --pattern=/usr/sbin/bgpd"

[plugin.checks.ospfd_procs]
command = "/usr/local/bin/check-procs --pattern=/usr/sbin/ospfd"

[plugin.checks.ospf6d_procs]
command = "/usr/local/bin/check-procs --pattern=/usr/sbin/ospf6d"

[plugin.checks.ripd_procs]
command = "/usr/local/bin/check-procs --pattern=/usr/sbin/ripd"

[plugin.checks.ripngd_procs]
command = "/usr/local/bin/check-procs --pattern=/usr/sbin/ripngd"

[plugin.checks.zebra_procs]
command = "/usr/local/bin/check-procs --pattern=/usr/sbin/zebra"

[plugin.checks.keepalived_procs]
command = "/usr/local/bin/check-procs --pattern=/usr/sbin/keepalived"

[plugin.checks.ntpd_procs]
command = "/usr/local/bin/check-procs --pattern=/usr/sbin/ntpd"

[plugin.checks.cron_procs]
command = "/usr/local/bin/check-procs --pattern=/usr/sbin/cron"

[plugin.checks.rsyslogd_procs]
command = "/usr/local/bin/check-procs --pattern=/usr/sbin/rsyslogd"

起動

debian系列なので、サービス再起動は以下のコマンドで行う。
起動・停止とかのコマンドは割愛。

/etc/init.d/mackerel-agent restart

無事に起動したらmackerelのGUIを見て確認する。

補足

自動起動

下記のように確認して、Sがついたシンボリックリンクがあれば自動起動する。

$ ls -l /etc/rc*.d/*mackerel-agent

lrwxrwxrwx 1 root root 24 Oct 27 05:05 /etc/rc0.d/K01mackerel-agent -> ../init.d/mackerel-agent
lrwxrwxrwx 1 root root 24 Oct 27 05:05 /etc/rc1.d/K01mackerel-agent -> ../init.d/mackerel-agent
lrwxrwxrwx 1 root root 24 Oct 27 05:05 /etc/rc2.d/S03mackerel-agent -> ../init.d/mackerel-agent
lrwxrwxrwx 1 root root 24 Oct 27 05:05 /etc/rc3.d/S03mackerel-agent -> ../init.d/mackerel-agent
lrwxrwxrwx 1 root root 24 Oct 27 05:05 /etc/rc4.d/S03mackerel-agent -> ../init.d/mackerel-agent
lrwxrwxrwx 1 root root 24 Oct 27 05:05 /etc/rc5.d/S03mackerel-agent -> ../init.d/mackerel-agent
lrwxrwxrwx 1 root root 24 Oct 27 05:05 /etc/rc6.d/K01mackerel-agent -> ../init.d/mackerel-agent

もし自動起動する設定が入っていなければ以下のコマンドで有効化しておこう。

$ update-rc.d mackerel-agent enable
5
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?