サーバーリソースの監視

インストール

munin と munin-node をインストール。 途中で依存している他のものを入れるかと聞かれたら「y」。

$ sudo apt-get install munin munin-node

設定

最初に、設定ファイルのバックアップを作っておきます。

$ sudo cp /etc/munin/apache.conf /etc/munin/apache.conf.org
$ sudo cp /etc/munin/munin-node.conf /etc/munin/munin-node.conf.org
$ sudo cp /etc/munin/munin.conf /etc/munin/munin.conf.org

munin-node.conf にサーバーのIPを設定。

$ sudo vi /etc/munin/munin-node.conf

# A list of addresses that are allowed to connect.  This must be a
# regular expression, since Net::Server does not understand CIDR-style
# network notation unless the perl module Net::CIDR is installed.  You
# may repeat the allow line as many times as you'd like

allow ^192\.168\.3\.101$

munin.conf に監視するサーバのIPを設定。

$ sudo vi /etc/munin/munin.conf

# a simple host tree
# [localhost.localdomain]
#   address 127.0.0.1
#   use_node_name yes

[localhost]
    address 192.168.3.101
    use_node_name yes

ローカルIP以外からも見れるようにする場合は、aapahe.conf を編集。
世界中から見れてしまうので、Basic認証とかは入れた方がが良いかも。

$ sudo vi /etc/munin/apache.conf

<Directory /var/cache/munin/www>
#       Order allow,deny
#       Allow from localhost 127.0.0.0/8 ::1
        Require all granted

<Location /munin-cgi/munin-cgi-graph>
#       Order allow,deny
#       Allow from localhost 127.0.0.0/8 ::1
        Require all granted

<Location /munin-cgi/munin-cgi-html>
#       Order allow,deny
#       Allow from localhost 127.0.0.0/8 ::1
        Require all granted

muninとapache2の再起動

設定が終わったらmuninとapache2を再起動します。

$ sudo service munin-node restart
$ sudo service apache2 restart

すぐに、結果を見たい場合は以下のコマンドで。

$ sudo -u munin munin-cron

監視対象項目の追加

apache のプロセス数

$ sudo ln -s /usr/share/munin/plugins/apache_processes /etc/munin/plugins/

MySQL の監視

$ sudo ln -s /usr/share/munin/plugins/mysql_bytes /etc/munin/plugins/mysql_bytes
$ sudo ln -s /usr/share/munin/plugins/mysql_queries /etc/munin/plugins/mysql_queries
$ sudo ln -s /usr/share/munin/plugins/mysql_slowqueries /etc/munin/plugins/mysql_slowqueries
$ sudo ln -s /usr/share/munin/plugins/mysql_threads /etc/munin/plugins/mysql_threads

[mysql*]
#user root
#env.mysqlopts --defaults-file=/etc/mysql/debian.cnf
#env.mysqluser debian-sys-maint
#env.mysqlconnection DBI:mysql:mysql;mysql_read_default_file=/etc/mysql/debian.cnf
env.mysqlopts -u root -pパスワード
env.mysqladmin /usr/bin/mysqladmin

#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
log_slow_queries        = /var/log/mysql/mysql-slow.log
long_query_time = 1
log-queries-not-using-indexes

温度、ファン、電圧監視

監視モジュールのインストール

$ sudo apt-get install lm-sensors

センサーの検出。基本的に Enter を押していくだけ。

$ sudo /usr/sbin/sensors-detect

# 最後のこの設問のみ、デフォルト NO なので y と入力
Do you want to add these lines automatically to /etc/modules? (yes/NO)

監視モジュールの起動

$ sudo service module-init-tools start

センサーの確認

$ sensors
acpitz-virtual-0
Adapter: Virtual device
temp1:        +27.8°C  (crit = +92.0°C)
temp2:        +29.8°C  (crit = +92.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Physical id 0:  +56.0°C  (high = +87.0°C, crit = +91.0°C)
Core 0:         +56.0°C  (high = +87.0°C, crit = +91.0°C)
Core 1:         +54.0°C  (high = +87.0°C, crit = +91.0°C)

温度の取得

$ sudo ln -s /usr/share/munin/plugins/sensors_ /etc/munin/plugins/sensors_temp

ファン速度の取得

$sudo ln -s  /usr/share/munin/plugins/sensors_ /etc/munin/plugins/sensors_fan

電圧の取得

$ sudo ln -s  /usr/share/munin/plugins/sensors_ /etc/munin/plugins/sensors_volt

不要(無効)なセンサを除外。搭載されていない、fan2、temp3 を除外する。

$ sensors
it8728-isa-0a30
Adapter: ISA adapter
in0:          +0.70 V  (min =  +0.23 V, max =  +0.77 V)
 :
fan1:        1607 RPM  (min =   73 RPM)
fan2:           0 RPM  (min =   26 RPM)  ALARM
 :
temp2:        +38.0°C  (low  = +61.0°C, high = +32.0°C)  ALARM  sensor = Intel PECI
temp3:       -128.0°C  (low  = +68.0°C, high =  +3.0°C)  sensor = disabled

chip "it8728-*"

    ignore fan2
    ignore temp3

SMART 監視

SMART 監視モジュールのインストール

$ sudo apt-get install smartmontools

munin に追加(sda は自分の環境に合わせる)

$ sudo ln -s /usr/share/munin/plugins/hddtemp_smartctl /etc/munin/plugins/hddtemp_smartctl
$ sudo ln -s /usr/share/munin/plugins/smart_ /etc/munin/plugins/smart_hda
$ sudo ln -s /usr/share/munin/plugins/smart_ /etc/munin/plugins/smart_sda

sda は自分の環境に合わせる

[hddtemp_smartctl]
user root
env.drives sda
env.type_sda ata

[smart_sda]
env.smartargs -d ata

APC Cache の監視

APC 監視モジュールのインストール。

$ sudo apt-get install unzip
$ sudo apt-get install liblwp-useragent-determined-perl

$ wget https://munin-php-apc.googlecode.com/files/munin_plugin_php_apc-0.1.zip
$ unzip munin_plugin_php_apc-0.1.zip

$ sudo cp php_apc/php_apc_ /usr/share/munin/plugins

minin に追加。

$ sudo ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_files
$ sudo ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_fragmentation
$ sudo ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_hit_miss
$ sudo ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_purge
$ sudo ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_rates
$ sudo ln -s /usr/share/munin/plugins/php_apc_ /etc/munin/plugins/php_apc_usage

APC 監視サイトの設定。

$ sudo mkdir /var/www-ssl/tools
$ sudo cp php_apc/apc_info.php /var/www-ssl/tools/

$ sudo vi /etc/apache2/sites-available/tools.conf

Alias /tools /var/www-ssl/tools

<Directory /var/www-ssl/tools/>
  SSLRequireSSL
  # ローカルからのアクセスのみ許可
  Require ip 127.0.0.1 192.168.3.0/24
</Directory>

$ sudo a2ensite tools.conf
$ sudo service apache2 restart

munin-node に APC の設定(一番最後に追加する)。

[php_apc_*]
user root
env.url https://localhost/tools/apc_info.php

不要なファイルの削除。

$ rm munin_plugin_php_apc-0.1.zip
$ rm -rf php_apc

Memcached の監視

プラグインのインストール

$ wget https://raw.githubusercontent.com/mhwest13/Memcached-Munin-Plugin/master/memcached_
$ sudo mv memcached_ /usr/share/munin/plugins
$ sudo chmod 755 /usr/share/munin/plugins/memcached_
$ sudo chown root:root /usr/share/munin/plugins/memcached_

$ sudo ln -s /usr/share/munin/plugins/memcached_ /etc/munin/plugins/memcached_bytes
$ sudo ln -s /usr/share/munin/plugins/memcached_ /etc/munin/plugins/memcached_commands
$ sudo ln -s /usr/share/munin/plugins/memcached_ /etc/munin/plugins/memcached_conns
$ sudo ln -s /usr/share/munin/plugins/memcached_ /etc/munin/plugins/memcached_evictions
$ sudo ln -s /usr/share/munin/plugins/memcached_ /etc/munin/plugins/memcached_items
$ sudo ln -s /usr/share/munin/plugins/memcached_ /etc/munin/plugins/memcached_memory

[memcached_*]
env.host 127.0.0.1
env.port 11211
env.timescale 3

ubuntu/v1404/サーバーリソースの監視.txt · 最終更新: 2018/03/18 09:56 (外部編集)
 
特に明示されていない限り、本Wikiの内容は次のライセンスに従います: CC Attribution-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki