「Linux/muninインストール」の版間の差分
(→munin管理画面を表示) |
(→munin設定変更) |
||
| 行15: | 行15: | ||
logdir /var/log/munin | logdir /var/log/munin | ||
rundir /var/run/munin | rundir /var/run/munin | ||
| + | |||
| + | ==muninの管理画面のpath変更== | ||
| + | 例えば、/var/www/html/muninを/var/www/muninに変更したい場合は、 | ||
| + | /var/www/htmlにmuninに追加されてるので、muninを/var/www直下に変更して、以下ファイルも変更 | ||
| + | |||
| + | # vi /etc/munin/munin.conf | ||
| + | -htmldir /var/www/html/munin | ||
| + | +htmldir /var/www/munin | ||
==munin管理画面を表示== | ==munin管理画面を表示== | ||
2022年9月16日 (金) 00:17時点における版
監視する側のmunin設定
muninインストール準備
redhut系
# yum install munin --enablerepo=epel
debian系
# apt-get install munin
munin設定変更
# vi /etc/munin/munin.conf
コメントアウトを削除して以下追加
dbdir /var/lib/munin htmldir /var/www/munin logdir /var/log/munin rundir /var/run/munin
muninの管理画面のpath変更
例えば、/var/www/html/muninを/var/www/muninに変更したい場合は、 /var/www/htmlにmuninに追加されてるので、muninを/var/www直下に変更して、以下ファイルも変更
# vi /etc/munin/munin.conf -htmldir /var/www/html/munin +htmldir /var/www/munin
munin管理画面を表示
apacheの場合
# vi /etc/httpd/conf.d/munin.conf
<VirtualHost *:80>
ServerName munin.kagoya
DocumentRoot "/var/www/munin"
HostNameLookups off
UseCanonicalName on
<Directory "/var/www/munin">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
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.conf
監視される側
# 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を追加
# vi /etc/munin/munin-node.conf allow ^192\.168\.0\.3$
これは監視する側は不要っぽい。最終確認して、あとで消すかも。
監視するサーバを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
ここの[]に囲まれたものが管理画面に出てくる。
設定変更直後じゃなくて、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
port解放
$ vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 4949 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 4949 -j ACCEPT # サーバによってはこちら $ /etc/rc.d/init.d/iptables restart
監視される側のmunin設定
muninインストール準備
redhut系
# yum install munin-node --enablerepo=epel
debian系
# apt-get install munin-node
監視する側でなければ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を追加
# vi /etc/munin/munin-node.conf allow ^192\.168\.0\.2$
監視されるサーバのhost名を変更
# vi /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
port解放
$ vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 4949 -j ACCEPT -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 4949 -j ACCEPT # サーバによってはこちら $ /etc/rc.d/init.d/iptables restart
接続テスト
telnet
監視する側から監視されるip接続を行う
telnet [ipアドレス] 4949
成功の場合
Trying [ipアドレス]... Connected to [ipアドレス]. Escape character is '^]'. # munin node at [ipアドレス]
失敗の場合
Trying [ipアドレス]... Connected to [ipアドレス]. Escape character is '^]'. Connection closed by foreign host
ファイアウォール(iptables)やmunin-nodeが起動してない場合は失敗するので確認する。
service munin-node start
munin-node startでmunin-node line 36.が発生する場合
エラーメッセージ
BEGIN failed--compilation aborted at /opt/munin/sbin/munin-node line 36.
$ sudo perl -MCPAN -e shell cpan[1]> install Net::Server::Fork
参考:https://www.atage.jp/archives/1644/
参考
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の監視対象を追加する。
