Mackerelプラグイン追加[Apache, MySQL]

2021-06-18

概要

先日インストールしたMackerelに「Apache」・「MySQL」のプラグインを追加したのでその手順を簡単に説明します

プラグイン追加

yumでプラグイン(mackerel-agent-plugins)を追加します

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

apache設定

ApacheのServerStatusを有効にしないと監視に必要な値が取得できないので、ServerStatusを有効にします

# vim /etc/httpd/conf/httpd.conf
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from localhost
</Location>

# VirtualHost を設定している場合は以下のように設定
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/html
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from localhost
</Location>
</VirtualHost>

# /etc/init.d/httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

ServerStatusの設定が有効になったら、mackerel-agent.confを編集します

# vi /etc/mackerel-agent/mackerel-agent.conf
[plugin.metrics.apache2]
command = "/usr/local/bin/mackerel-plugin-apache2"
type = "metric"

MySQL設定

MySQLの設定は、接続ポート・DB場所がデフォルトのままなら、ユーザー・パスワードを設定するだけです

# vi /etc/mackerel-agent/mackerel-agent.conf
[plugin.metrics.mysql]
command = "/usr/local/bin/mackerel-plugin-mysql --username='<ユーザー名>' --password='<パスワード>'"
type = "metric"

mackerel再起動

最後に、mackerelを再起動して設定を有効にします

# /etc/init.d/mackerel-agent restart
Stopping mackerel-agent: [ OK ]
Starting mackerel-agent: [ OK ]

しばらくすると、Apache, MySQLの各種メトリクスが表示されます

mackerel Apacheグラフ

mackerel MySQLグラフ

スポンサーリンク

0
0

Linux監視ツール

Posted by admin