「Linux/muninインストール」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→監視される側のmunin設定) |
(→munin-node起動) |
||
| 行94: | 行94: | ||
==munin-node起動== | ==munin-node起動== | ||
service munin-node start | service munin-node start | ||
| + | |||
| + | ==munin自動起動== | ||
| + | $ sudo /sbin/chkconfig munin-node on | ||
| + | $ /sbin/chkconfig --list | grep munin-node | ||
| + | munin-node 0:off 1:off 2:on 3:on 4:on 5:on 6:off | ||
==監視されるサーバの場合は監視元サーバのIPを追加== | ==監視されるサーバの場合は監視元サーバのIPを追加== | ||
2018年9月9日 (日) 13:58時点における版
監視する側のmunin設定
muninインストール準備
# yum install munin --enablerepo=epel
munin設定変更
# vi /etc/munin/munin.conf
コメントアウトを削除して以下追加
dbdir /var/lib/munin htmldir /var/www/munin logdir /var/log/munin rundir /var/run/munin
munin管理画面を表示
apacheの場合
# vi /etc/httpd/conf.d/munin.conf
ngxinの場合
# vi /etc/nginx/conf.d/munin.localhost.conf
server {
listen 80;
server_name munin.localhost;
location / {
alias /var/www/munin/;
}
location /nginx_status {
stub_status on;
access_log off;
}
location = /50x.html {
root /usr/share/nginx/html;
}
}
muninの設定
# vi /etc/munin/munin-node.conf
munin起動
service munin-node start
5分すると/var/www/muninにhtmlファイルが追加さmunin.localhostが表示できるようになる
5分待てなければ以下を実行
sudo -u munin munin-cron
監視するサーバに監視されるサーバのIPを追加
# /etc/munin/munin-node.conf allow ^192\.168\.0\.3$
監視するサーバをmunin管理画面に追加
vi /etc/munin/munin.conf
[localhost] address 127.0.0.1 use_node_name yes [test1.example.com] address 192.168.xxx.xxx use_node_name yes
ここの[]に囲まれたものが管理画面に出てくる。
設定変更直後じゃなくて、5分ごとにcronが走るので、そのタイミングで変更される。
munin自動起動
$ sudo /sbin/chkconfig munin-node on $ /sbin/chkconfig --list | grep munin-node munin-node 0:off 1:off 2:on 3:on 4:on 5:on 6:off
muninのcron設定
# vi /etc/cron.d/munin
監視されるサーバ情報追加
監視されるipを許可するために以下を監視するサーバに設定する
vi /etc/munin/munin.conf
[localhost] address 127.0.0.1 use_node_name yes [test1.example.com] address 192.168.xxx.xxx use_node_name yes
port解放
$ vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 4949 -j ACCEPT
$ /etc/rc.d/init.d/iptables restart
監視される側のmunin設定
muninインストール準備
# yum install munin-node --enablerepo=epel
監視する側でなければmuninは不要でmunin-nodeのみで良い
munin-node起動
service munin-node start
munin自動起動
$ sudo /sbin/chkconfig munin-node on $ /sbin/chkconfig --list | grep munin-node munin-node 0:off 1:off 2:on 3:on 4:on 5:on 6:off
監視されるサーバの場合は監視元サーバのIPを追加
# /etc/munin/munin-node.conf allow ^192\.168\.0\.2$
監視されるサーバのhost名を変更
# /etc/munin/munin-node.conf
hogedomainに変更する場合は以下のように変更
-host_name localhost.localdomain +host_name hogedomain
nginx監視
php-fpmで使えるように
cd /usr/share/munin/plugins sudo git clone git://github.com/tjstein/php5-fpm-munin-plugins.git sudo chmod +x php5-fpm-munin-plugins/phpfpm_* cd /etc/munin/plugins/ ln -s /usr/share/munin/plugins/php5-fpm-munin-plugins/phpfpm_average phpfpm_average ln -s /usr/share/munin/plugins/php5-fpm-munin-plugins/phpfpm_connections phpfpm_connections ln -s /usr/share/munin/plugins/php5-fpm-munin-plugins/phpfpm_memory phpfpm_memory ln -s /usr/share/munin/plugins/php5-fpm-munin-plugins/phpfpm_processes phpfpm_processes ln -s /usr/share/munin/plugins/php5-fpm-munin-plugins/phpfpm_status phpfpm_status
nginxのstatusにアクセスできるように
# vi /etc/php-fpm.d/www.conf ;pm.status_path = /status pm.status_path = /phpfpm_status
vi /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
location /phpfpm_status {
include fastcgi_params;
fastcgi_pass localhost:9000;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
allow 127.0.0.1;
deny all;
}
}
以下で動作確認
wget http://localhost/phpfpm_status
監視対象サービス追加
vi /etc/munin/plugin-conf.d/munin-node [nginx*] env.url http://localhost/nginx_status [phpfpm*] env.url http://localhost/phpfpm_status env.phpbin php-fpm
監視稼働確認
$ /usr/sbin/munin-run phpfpm_average #phpfpmの場合 php_average.value 86642102 $ /usr/sbin/munin-run load #loadaverageの場合 load.value 0.86
監視するサーバ情報追加
監視するipを許可するために以下を監視されるサーバに設定する
vi /etc/munin/munin.conf
[localhost] address 127.0.0.1 use_node_name yes [test1.example.com] address 192.168.xxx.xxx use_node_name yes
port解放
監視される側も4949portを解放
参考
https://tech.basicinc.jp/articles/8 nginx + PHP-FPMをmuninでリソース監視する
https://www.server-memo.net/server-setting/munin/munin-install.html Munin インストール
http://blog.katty.in/1598 Muninの監視対象を追加する。
