目次 >> Ganglia
Ganglia(ガングリア)は複数の計算機の状態をウェブ上で簡単に確認できるソフトウェアである。Gangliaのインストール方法について述べる。
必要となるのは、rrdtool、ganglia-monitor、gmetad、ganglia-webfrontendである。そのうち、rrdtool、ganglia-monitorはクラスタの全ノードにインストールする必要がある。
注:もし、1台のみしか状態を監視しないのであれば、MRTGの方が簡単かもしれない。
各種データを集めるrrdtoolをインストールする。これは各ノードすべてのインストールする。
$ sudo apt-get install rrdtool Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libdbi1 librrd4 ttf-dejavu ttf-dejavu-extra Suggested packages: librrds-perl The following NEW packages will be installed: libdbi1 librrd4 rrdtool ttf-dejavu ttf-dejavu-extra 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 4,063 kB of archives. After this operation, 8,332 kB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/main libdbi1 amd64 0.8.4-5.1 [28.5 kB] Get:2 http://us.archive.ubuntu.com/ubuntu/ precise/main librrd4 amd64 1.4.7-1 [242 kB] Get:3 http://us.archive.ubuntu.com/ubuntu/ precise/main ttf-dejavu-extra all 2.33-2ubuntu1 [3,420 kB] Get:4 http://us.archive.ubuntu.com/ubuntu/ precise/main ttf-dejavu all 2.33-2ubuntu1 [3,178 B] Get:5 http://us.archive.ubuntu.com/ubuntu/ precise/main rrdtool amd64 1.4.7-1 [369 kB] Fetched 4,063 kB in 3s (1,190 kB/s) Selecting previously unselected package libdbi1. (Reading database ... 168490 files and directories currently installed.) Unpacking libdbi1 (from .../libdbi1_0.8.4-5.1_amd64.deb) ... Selecting previously unselected package librrd4. Unpacking librrd4 (from .../librrd4_1.4.7-1_amd64.deb) ... Selecting previously unselected package ttf-dejavu-extra. Unpacking ttf-dejavu-extra (from .../ttf-dejavu-extra_2.33-2ubuntu1_all.deb) ... Selecting previously unselected package ttf-dejavu. Unpacking ttf-dejavu (from .../ttf-dejavu_2.33-2ubuntu1_all.deb) ... Selecting previously unselected package rrdtool. Unpacking rrdtool (from .../rrdtool_1.4.7-1_amd64.deb) ... Processing triggers for fontconfig ... Processing triggers for doc-base ... Processing 1 added doc-base file... Processing triggers for man-db ... Setting up libdbi1 (0.8.4-5.1) ... Setting up librrd4 (1.4.7-1) ... Setting up ttf-dejavu-extra (2.33-2ubuntu1) ... Setting up ttf-dejavu (2.33-2ubuntu1) ... Setting up rrdtool (1.4.7-1) ... Processing triggers for libc-bin ... ldconfig deferred processing now taking place
これはgmetadから要求があった際にXMLデータを送る役割をする。すべてのノードにインストールする。
$ sudo apt-get install ganglia-monitor Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libapr1 libconfuse-common libconfuse0 libganglia1 The following NEW packages will be installed: ganglia-monitor libapr1 libconfuse-common libconfuse0 libganglia1 0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded. Need to get 310 kB of archives. After this operation, 1,513 kB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/universe libconfuse-common all 2.7-4 [4,798 B] Get:2 http://us.archive.ubuntu.com/ubuntu/ precise/universe libconfuse0 amd64 2.7-4 [24.5 kB] Get:3 http://us.archive.ubuntu.com/ubuntu/ precise/main libapr1 amd64 1.4.6-1 [89.6 kB] Get:4 http://us.archive.ubuntu.com/ubuntu/ precise/universe libganglia1 amd64 3.1.7-2ubuntu1 [136 kB] Get:5 http://us.archive.ubuntu.com/ubuntu/ precise/universe ganglia-monitor amd64 3.1.7-2ubuntu1 [54.8 kB] Fetched 310 kB in 1s (196 kB/s) Selecting previously unselected package libconfuse-common. (Reading database ... 168624 files and directories currently installed.) Unpacking libconfuse-common (from .../libconfuse-common_2.7-4_all.deb) ... Selecting previously unselected package libconfuse0. Unpacking libconfuse0 (from .../libconfuse0_2.7-4_amd64.deb) ... Selecting previously unselected package libapr1. Unpacking libapr1 (from .../libapr1_1.4.6-1_amd64.deb) ... Selecting previously unselected package libganglia1. Unpacking libganglia1 (from .../libganglia1_3.1.7-2ubuntu1_amd64.deb) ... Selecting previously unselected package ganglia-monitor. Unpacking ganglia-monitor (from .../ganglia-monitor_3.1.7-2ubuntu1_amd64.deb) ... Processing triggers for ureadahead ... ureadahead will be reprofiled on next reboot Processing triggers for man-db ... Setting up libconfuse-common (2.7-4) ... Setting up libconfuse0 (2.7-4) ... Setting up libapr1 (1.4.6-1) ... Setting up libganglia1 (3.1.7-2ubuntu1) ... Setting up ganglia-monitor (3.1.7-2ubuntu1) ... Adding system user: ganglia. Starting Ganglia Monitor Daemon: gmond. Processing triggers for libc-bin ... ldconfig deferred processing now taking place
起動するには、
$ sudo /etc/init.d/ganglia-monitor start
sysv-rc-confで見ると、ganglia-monitorが自動的に起動するようになっている。
ただし、NetworkManagerを使ってネットワークの設定をしているとなぜか、マシン起動時に起動してくれない。この場合、NetworkManagerを使わずに、/etc/network/interfacesと/etc/resolve.confを使ってネットワークの設定を行うとよい。それには、
/etc/NetworkManager/NetworkManager.conf内の
[ifupdown] managed=false
を
[ifupdown] managed=true
に書き換える。tureがNetworkManagerを使わない方なので、注意。
以上で、NetworkManagerは使われなくなる。
次に、/etc/network/interfacesを設定する。
書き方はこんな感じ
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 123.123.199.123 netmask 255.255.255.0 gateway 124.124.199.254 dns-nameservers 132.79.105.105 197.79.115.115
最後の行はDNSサーバを指定している。これで
/etc/resolve.conf
は自動的に設定されるので、/etc/resolve.confを手動で設定する必要はない。
gmond.confも/etc/に自動的に作成されている。
gmetadの設定で、データを収集するノードを設定するので、収集される側の設定はこれで終わりである。
さらにgmetad。これはapacheの動いている、データを表示するコンピュータにのみインストールすればよい。
$ sudo apt-get install gmetad Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: ganglia-webfrontend The following NEW packages will be installed: gmetad 0 upgraded, 1 newly installed, 0 to remove and 108 not upgraded. Need to get 31.2 kB of archives. After this operation, 168 kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu/ natty/universe gmetad amd64 3.1.7-1ubuntu1 [31.2 kB] Fetched 31.2 kB in 0s (39.4 kB/s) Selecting previously deselected package gmetad. (Reading database ... 135320 files and directories currently installed.) Unpacking gmetad (from .../gmetad_3.1.7-1ubuntu1_amd64.deb) ... Processing triggers for ureadahead ... Processing triggers for man-db ... Setting up gmetad (3.1.7-1ubuntu1) ... Starting Ganglia Monitor Meta-Daemon: gmetad.
起動するには、
$ sudo /etc/init.d/gmetad start
sysv-rc-confで見ると、gmetadが自動的に起動するようになっている。
$ sudo sysv-rc-conf --list gmetad gmetad 0:off 1:off 2:on 3:on 4:on 5:on 6:off
次のコマンドで、xmlデータが表示されるはずである。
$ telnet localhost 8649
なお、複数のコンピュータのデータを収集するには、/etc/ganglia/gmetad.conf(/etc/gmetad.confの場合もある)の中の、data_sourceの項にIPアドレスもしくはホスト名で追加していく。
data_source "my cluster" localhost node1.example.com 192.167.2.1
$ sudo apt-get install ganglia-webfrontend Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: apache2-mpm-prefork libapache2-mod-php5 php5 php5-cli php5-common php5-gd Suggested packages: php-pear php5-suhosin The following packages will be REMOVED: apache2-mpm-worker The following NEW packages will be installed: apache2-mpm-prefork ganglia-webfrontend libapache2-mod-php5 php5 php5-cli php5-common php5-gd 0 upgraded, 7 newly installed, 1 to remove and 108 not upgraded. Need to get 6,774 kB of archives. After this operation, 18.7 MB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://us.archive.ubuntu.com/ubuntu/ natty/main apache2-mpm-prefork amd64 2.2.17-1ubuntu1 [2,390 B] Get:2 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main php5-common amd64 5.3.5-1ubuntu7.2 [430 kB] Get:3 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main libapache2-mod-php5 amd64 5.3.5-1ubuntu7.2 [3,140 kB] Get:4 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main php5 all 5.3.5-1ubuntu7.2 [1,104 B] Get:5 http://us.archive.ubuntu.com/ubuntu/ natty/universe ganglia-webfrontend all 3.1.7-1ubuntu1 [109 kB] Get:6 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main php5-cli amd64 5.3.5-1ubuntu7.2 [3,053 kB] Get:7 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main php5-gd amd64 5.3.5-1ubuntu7.2 [38.8 kB] Fetched 6,774 kB in 5min 33s (20.3 kB/s) Preconfiguring packages ... Package configuration dpkg: apache2-mpm-worker: dependency problems, but removing anyway as you requested: apache2 depends on apache2-mpm-worker (= 2.2.17-1ubuntu1) | apache2-mpm-prefork (= 2.2.17-1ubuntu1) | apache2-mpm-event (= 2.2.17-1ubuntu1) | apache2-mpm-itk (= 2.2.17-1ubuntu1); however: Package apache2-mpm-worker is to be removed. Package apache2-mpm-prefork is not installed. Package apache2-mpm-event is not installed. Package apache2-mpm-itk is not installed. (Reading database ... 135453 files and directories currently installed.) Removing apache2-mpm-worker ... * Stopping web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ... waiting . ...done. Selecting previously deselected package apache2-mpm-prefork. (Reading database ... 135449 files and directories currently installed.) Unpacking apache2-mpm-prefork (from .../apache2-mpm-prefork_2.2.17-1ubuntu1_amd64.deb) ... Setting up apache2-mpm-prefork (2.2.17-1ubuntu1) ... * Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ...done. Selecting previously deselected package php5-common. (Reading database ... 135454 files and directories currently installed.) Unpacking php5-common (from .../php5-common_5.3.5-1ubuntu7.2_amd64.deb) ... Selecting previously deselected package libapache2-mod-php5. Unpacking libapache2-mod-php5 (from .../libapache2-mod-php5_5.3.5-1ubuntu7.2_amd64.deb) ... Selecting previously deselected package php5. Unpacking php5 (from .../php5_5.3.5-1ubuntu7.2_all.deb) ... Selecting previously deselected package ganglia-webfrontend. Unpacking ganglia-webfrontend (from .../ganglia-webfrontend_3.1.7-1ubuntu1_all.deb) ... Selecting previously deselected package php5-cli. Unpacking php5-cli (from .../php5-cli_5.3.5-1ubuntu7.2_amd64.deb) ... Selecting previously deselected package php5-gd. Unpacking php5-gd (from .../php5-gd_5.3.5-1ubuntu7.2_amd64.deb) ... Processing triggers for man-db ... Setting up php5-common (5.3.5-1ubuntu7.2) ... Setting up libapache2-mod-php5 (5.3.5-1ubuntu7.2) ... Creating config file /etc/php5/apache2/php.ini with new version * Reloading web server config apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ...done. Setting up php5 (5.3.5-1ubuntu7.2) ... Setting up ganglia-webfrontend (3.1.7-1ubuntu1) ... Package configuration Setting up php5-cli (5.3.5-1ubuntu7.2) ... Creating config file /etc/php5/cli/php.ini with new version update-alternatives: using /usr/bin/php5 to provide /usr/bin/php (php) in auto mode. Setting up php5-gd (5.3.5-1ubuntu7.2) ...
でインストールする。途中2度ほど、apacheを再起動するか聞いてくるが、基本的にYesでよい。
/etc/ganglia-webfrontendの中にapacheの設定ファイルがあるので、それを/etc/apache2/conf.d/内にコピーする。
$ sudo cp -p /etc/ganglia-webfrontend/apache.conf /etc/apache2/conf.d/ganglia.conf
そしてapacheを再起動する。
$ sudo /etc/init.d/apache2 restart
/etc/ganglia-webfrontend/apache.confのデフォルトの設定のままだと、http://example.com/gangliaにアクセスすると、見られるはずである。
デフォルトの設定では、CPUのloadが100%を少しでも超えると、とたんに、色が赤に変化する。
多少、load値が揺らいでも、色が変わらないようにするには、下記のphpを変更する。
/usr/share/ganglia-webfrontend/functions.php
具体的には、この中の
function load_image ($scope, $value) { global $load_scale; $scaled_load = $value / $load_scale; if ($scaled_load>1.00) { $image = template("images/${scope}_overloaded.jpg"); } else if ($scaled_load>=0.75) { $image = template("images/${scope}_75-100.jpg"); } else if ($scaled_load >= 0.50) { $image = template("images/${scope}_50-74.jpg"); } else if ($scaled_load>=0.25) { $image = template("images/${scope}_25-49.jpg"); } else { $image = template("images/${scope}_0-24.jpg"); } return $image; }
を
function load_image ($scope, $value) { global $load_scale; $scaled_load = $value / $load_scale; if ($scaled_load>1.01) { $image = template("images/${scope}_overloaded.jpg"); } else if ($scaled_load>=0.76) { $image = template("images/${scope}_75-100.jpg"); } else if ($scaled_load >= 0.51) { $image = template("images/${scope}_50-74.jpg"); } else if ($scaled_load>=0.26) { $image = template("images/${scope}_25-49.jpg"); } else { $image = template("images/${scope}_0-24.jpg"); } return $image; }
のように変更する。数値は、好みで。今回は、101、76、51、26パーセントになってはじめて変わるようにした。
Ubuntu12.04のgangliaにはバグがあり、NFSを使用していると、なぜか、gangliaが正常に機能しない。
正常に機能させるためには、
/etc/ganglia/gmond.conf
内のdiskパートをコメントアウトする必要がある。
ganglia-webfrontendをインストールする際、このページによると、ubuntu 8.04とganglia 3.0.7の組み合わせだと、そのパッケージが存在しないらしいので、その場合は、古い3.03のganglia-webfrontendをインストールする。ubuntu 9.04でも事情は同じである。ganglia-web-3.0.3-1.noarch.rpmをhttp://ganglia.info/よりダウンロードして、
$ sudo rpm --install ganglia-web-3.0.3-1.noarch.rpm
とする。
そうすると、/var/www/html/ganglia以下のディレクトリにindex.phpをはじめとしたファイルが作成されるはずである。
これで、あとはhttp://www.example.com/html/ganglia/にアクセスしてやればよいのだが、もしApacheでphpを適切に設定されていないと、きちんと表示されずに、例えばファイルがダウンロードされたりする。Apacheでphpを使えるようにするには、こちらを参照。
GDモジュールはganglia-webfrontendをインストールする際に、インストールされていなければ自動的にインストールされるが、古いUbuntuや一部のディストリビューションではインストールされない。php5のGDモジュールがインストールされていなければ、それもインストールする。
$ sudo apt-get install php5-gd
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5
libapr1 libaprutil1 libgd2-xpm libmysqlclient15off libpq5 libt1-5
mysql-common php5-common
Suggested packages:
apache2-doc apache2-suexec apache2-suexec-custom php-pear libgd-tools
The following packages will be REMOVED:
libgd2-noxpm
The following NEW packages will be installed:
apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5
libapr1 libaprutil1 libgd2-xpm libmysqlclient15off libpq5 libt1-5
mysql-common php5-common php5-gd
0 upgraded, 13 newly installed, 1 to remove and 12 not upgraded.
Need to get 7092kB of archives.
After this operation, 18.4MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://archive.ubuntu.com jaunty-updates/main libapr1 1.2.12-5ubuntu0.1 [114kB]
Get:2 http://archive.ubuntu.com jaunty-updates/main mysql-common 5.1.30really5.0.75-0ubuntu10.3 [63.4kB]
Get:3 http://archive.ubuntu.com jaunty-updates/main libmysqlclient15off 5.1.30really5.0.75-0ubuntu10.3 [1879kB]
Get:4 http://archive.ubuntu.com jaunty-updates/main libpq5 8.3.9-0ubuntu9.04 [314kB]
Get:5 http://archive.ubuntu.com jaunty-updates/main libaprutil1 1.2.12+dfsg-8ubuntu0.3 [79.1kB]
Get:6 http://archive.ubuntu.com jaunty-updates/main apache2-utils 2.2.11-2ubuntu2.5 [151kB]
Get:7 http://archive.ubuntu.com jaunty-updates/main apache2.2-common 2.2.11-2ubuntu2.5 [827kB]
Get:8 http://archive.ubuntu.com jaunty-updates/main apache2-mpm-prefork 2.2.11-2ubuntu2.5 [253kB]
Get:9 http://archive.ubuntu.com jaunty-updates/main php5-common 5.2.6.dfsg.1-3ubuntu4.5 [373kB]
Get:10 http://archive.ubuntu.com jaunty-updates/main libapache2-mod-php5 5.2.6.dfsg.1-3ubuntu4.5 [2616kB]
Get:11 http://archive.ubuntu.com jaunty-updates/main libgd2-xpm 2.0.36~rc1~dfsg-3ubuntu1.9.04.1 [215kB]
Get:12 http://archive.ubuntu.com jaunty/main libt1-5 5.1.2-3 [170kB]
Get:13 http://archive.ubuntu.com jaunty-updates/main php5-gd 5.2.6.dfsg.1-3ubuntu4.5 [37.2kB]
Fetched 7092kB in 6s (1133kB/s)
dpkg: libgd2-noxpm: dependency problems, but removing anyway as you request:
libgraphviz4 depends on libgd2-noxpm (>= 2.0.36~rc1~dfsg) | libgd2-xpm (>= 2.0.36~rc1~dfsg); however:
Package libgd2-noxpm is to be removed.
Package libgd2-xpm is not installed.
mrtg depends on libgd2-noxpm (>= 2.0.36~rc1~dfsg) | libgd2-xpm (>= 2.0.36~rc1~dfsg); however:
Package libgd2-noxpm is to be removed.
Package libgd2-xpm is not installed.
(Reading database ... 107789 files and directories currently installed.)
Removing libgd2-noxpm ...
Processing triggers for libc6 ...
ldconfig deferred processing now taking place
Selecting previously deselected package libapr1.
(Reading database ... 107781 files and directories currently installed.)
Unpacking libapr1 (from .../libapr1_1.2.12-5ubuntu0.1_amd64.deb) ...
Selecting previously deselected package mysql-common.
Unpacking mysql-common (from .../mysql-common_5.1.30really5.0.75-0ubuntu10.3_all.deb) ...
Selecting previously deselected package libmysqlclient15off.
Unpacking libmysqlclient15off (from .../libmysqlclient15off_5.1.30really5.0.75-0ubuntu10.3_amd64.deb) ...
Selecting previously deselected package libpq5.
Unpacking libpq5 (from .../libpq5_8.3.9-0ubuntu9.04_amd64.deb) ...
Selecting previously deselected package libaprutil1.
Unpacking libaprutil1 (from .../libaprutil1_1.2.12+dfsg-8ubuntu0.3_amd64.deb) ...
Selecting previously deselected package apache2-utils.
Unpacking apache2-utils (from .../apache2-utils_2.2.11-2ubuntu2.5_amd64.deb) ...
Selecting previously deselected package apache2.2-common.
Unpacking apache2.2-common (from .../apache2.2-common_2.2.11-2ubuntu2.5_amd64.deb) ...
Selecting previously deselected package apache2-mpm-prefork.
Unpacking apache2-mpm-prefork (from .../apache2-mpm-prefork_2.2.11-2ubuntu2.5_amd64.deb) ...
Selecting previously deselected package php5-common.
Unpacking php5-common (from .../php5-common_5.2.6.dfsg.1-3ubuntu4.5_amd64.deb) ...
Selecting previously deselected package libapache2-mod-php5.
Unpacking libapache2-mod-php5 (from .../libapache2-mod-php5_5.2.6.dfsg.1-3ubuntu4.5_amd64.deb) ...
Selecting previously deselected package libgd2-xpm.
Unpacking libgd2-xpm (from .../libgd2-xpm_2.0.36~rc1~dfsg-3ubuntu1.9.04.1_amd64.deb) ...
Selecting previously deselected package libt1-5.
Unpacking libt1-5 (from .../libt1-5_5.1.2-3_amd64.deb) ...
Selecting previously deselected package php5-gd.
Unpacking php5-gd (from .../php5-gd_5.2.6.dfsg.1-3ubuntu4.5_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for ufw ...
Setting up libapr1 (1.2.12-5ubuntu0.1) ...
Setting up mysql-common (5.1.30really5.0.75-0ubuntu10.3) ...
Setting up libmysqlclient15off (5.1.30really5.0.75-0ubuntu10.3) ...
Setting up libpq5 (8.3.9-0ubuntu9.04) ...
Setting up libaprutil1 (1.2.12+dfsg-8ubuntu0.3) ...
Setting up apache2-utils (2.2.11-2ubuntu2.5) ...
Setting up apache2.2-common (2.2.11-2ubuntu2.5) ...
Enabling site default.
Enabling module alias.
Enabling module autoindex.
Enabling module dir.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module status.
Enabling module auth_basic.
Enabling module deflate.
Enabling module authz_default.
Enabling module authz_user.
Enabling module authz_groupfile.
Enabling module authn_file.
Enabling module authz_host.
Setting up apache2-mpm-prefork (2.2.11-2ubuntu2.5) ...
* Starting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
...done.
Setting up php5-common (5.2.6.dfsg.1-3ubuntu4.5) ...
Setting up libapache2-mod-php5 (5.2.6.dfsg.1-3ubuntu4.5) ...
Creating config file /etc/php5/apache2/php.ini with new version
* Reloading web server config apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
...done.
Setting up libgd2-xpm (2.0.36~rc1~dfsg-3ubuntu1.9.04.1) ...
Setting up libt1-5 (5.1.2-3) ...
Setting up php5-gd (5.2.6.dfsg.1-3ubuntu4.5) ...
Processing triggers for libc6 ...
ldconfig deferred processing now taking place
まず、ubuntuの場合、lm-sensorsをインストールする。
$ sudo apt-get install lm-sensors
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
fancontrol sensord read-edid i2c-tools
The following NEW packages will be installed:
lm-sensors
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 101 kB of archives.
After this operation, 411 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/universe lm-sensors amd64 1:3.3.1-2ubuntu1 [101 kB]
Fetched 101 kB in 0s (140 kB/s)
Selecting previously unselected package lm-sensors.
(Reading database ... 169055 files and directories currently installed.)
Unpacking lm-sensors (from .../lm-sensors_1%3a3.3.1-2ubuntu1_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
Setting up lm-sensors (1:3.3.1-2ubuntu1) ...
sensor-detectでsensorsコマンドが使えるようにする。
$ sudo sensors-detect
いろいろ質問されるが、基本的にデフォルトの回答でよい。
そして最後の段階で次のように聞かれるのでyesを入力。
To load everything that is needed, add this to /etc/modules:
#----cut here----
# Chip drivers
adt7475
coretemp
it87
#----cut here----
If you have some drivers built into your kernel, the list above will
contain too many modules. Skip the appropriate ones!
Do you want to add these lines automatically to /etc/modules? (yes/NO)yes
すると、下記のように成功するはずである。
Successful!
Monitoring programs won't work until the needed modules are
loaded. You may want to run 'service module-init-tools start'
to load them.
Unloading i2c-dev... OK
Unloading i2c-i801... OK
Unloading cpuid... OK
再起動し、sensorsと打つと、
$ sensors
nouveau-pci-0100
Adapter: PCI adapter
temp1: +0.0 C (high = +100.0 C, crit = +110.0 C)
coretemp-isa-0000
Adapter: ISA adapter
Core 0: +34.0 C (high = +83.0 C, crit = +99.0 C)
coretemp-isa-0001
Adapter: ISA adapter
Core 1: +32.0 C (high = +83.0 C, crit = +99.0 C)
coretemp-isa-0002
Adapter: ISA adapter
Core 2: +37.0 C (high = +83.0 C, crit = +99.0 C)
coretemp-isa-0003
Adapter: ISA adapter
Core 3: +34.0 C (high = +83.0 C, crit = +99.0 C)
it8720-isa-0290
Adapter: ISA adapter
in0: +0.85 V (min = +0.00 V, max = +4.08 V)
in1: +1.54 V (min = +0.00 V, max = +4.08 V)
in2: +3.30 V (min = +0.00 V, max = +4.08 V)
+5V: +3.02 V (min = +0.00 V, max = +4.08 V)
in4: +0.02 V (min = +0.00 V, max = +4.08 V)
in5: +2.99 V (min = +0.00 V, max = +4.08 V)
in6: +0.00 V (min = +0.00 V, max = +4.08 V) ALARM
5VSB: +2.99 V (min = +0.00 V, max = +4.08 V)
Vbat: +3.26 V
fan1: 2115 RPM (min = 0 RPM)
fan2: 699 RPM (min = 0 RPM)
fan3: 0 RPM (min = 0 RPM)
fan4: 1762 RPM (min = 0 RPM)
temp1: +35.0 C (low = +127.0 C, high = +127.0 C) sensor = thermistor
temp2: +25.0 C (low = +127.0 C, high = +127.0 C) sensor = thermistor
temp3: +24.0 C (low = +127.0 C, high = +127.0 C) sensor = thermistor
の様に、表示される。
CPUの温度はこのマシンではtemp3であった。(tempが複数あるが、どれがCPUかはCPUを使用した時に上昇するものである。)
次にこの情報をgangliaに送る。下記のようなスクリプトcputempを作る。
#!/bin/bash GMETRIC=/usr/bin/gmetric SENSORS=/usr/bin/sensors `ps -e | grep gmond > /dev/null` if [ $? -eq 0 ]; then for temp in `${SENSORS} | grep emp3 | cut -b 13-16`; do $GMETRIC -t float -n "cpu_temp" -u "C" -v $temp done fi
そして、それを/usr/local/binあたりに置いて、cronで毎分ごとに呼び出す。
*/1 * * * * root /usr/local/bin/cputemp
これで、CPU温度が記録されるようになる。
GPUの温度を記録するのも、CPUの温度を記録する場合と大して変わらない。CUDAをインストールすると、nvidia-smiというコマンドが使えるようになっているはずである。このコマンドを実行すると、
$ nvidia-smi -a ==============NVSMI LOG============== Timestamp : Sat May 14 17:49:27 2011 Driver Version : 260.19.26 GPU 0: Product Name : GeForce GTX 285 PCI Device/Vendor ID : 5e310de PCI Location ID : 0:1:0 Board Serial : 213178571396269 Display : Connected Temperature : 51 C Fan Speed : 40% Utilization GPU : 0% Memory : 0%
のような情報が表示されるはずである。このコマンドの実行結果から温度情報を抜き出して、送るのである。
スクリプトgputempは下記のようになる。
#!/bin/bash GMETRIC=/usr/bin/gmetric SENSORS=/usr/bin/sensors `ps -e | grep gmond > /dev/null` if [ $? -eq 0 ]; then temp=`nvidia-smi -a | grep emp | cut -b 16-19` $GMETRIC -t float -n "gpu_temp" -u "C" -v $temp fi
そして、それを/usr/local/binあたりに置いて、cronで毎分ごとに呼び出す。
*/1 * * * * root /usr/local/bin/gputemp
これで、GPU温度が記録されるようになる。
なお、CPUとGPUの温度情報を同時に送るスクリプトは下記の通り。
#!/bin/bash GMETRIC=/usr/bin/gmetric SENSORS=/usr/bin/sensors # send cpu & gpu temps if gmond is running `ps -e | grep gmond > /dev/null` if [ $? -eq 0 ]; then # send cpu temperatures for temp in `${SENSORS} | grep emp3 | cut -b 13-16`; do $GMETRIC -t float -n "cpu_temp" -u "C" -v $temp done # send gpu temperatures temp=`nvidia-smi -a | grep emp | cut -b 16-19` $GMETRIC -t float -n "gpu_temp" -u "C" -v $temp fi
まず、hddtempをインストールする。ubuntuであれば、
$ sudo apt-get install hddtemp Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: ksensors The following NEW packages will be installed: hddtemp 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 52.0 kB of archives. After this operation, 250 kB of additional disk space will be used. Get:1 http://us.archive.ubuntu.com/ubuntu/ precise/universe hddtemp amd64 0.3-beta15-51 [52.0 kB] Fetched 52.0 kB in 0s (58.6 kB/s) Preconfiguring packages ... Package configuration Selecting previously unselected package hddtemp. (Reading database ... 169092 files and directories currently installed.) Unpacking hddtemp (from .../hddtemp_0.3-beta15-51_amd64.deb) ... Processing triggers for ureadahead ... ureadahead will be reprofiled on next reboot Processing triggers for man-db ... Setting up hddtemp (0.3-beta15-51) ...
でインストールできる。インストール中に、次のような設問がある。
lqqqqqqqqqqqqqqqqqqqqqqqqqqu Configuring hddtemp tqqqqqqqqqqqqqqqqqqqqqqqqqqk x x x The hddtemp program can be run as a daemon, listening on port 7634 for x x incoming connections. It is used by some software such as gkrellm to get x x the temperature of hard drives. x x x x You have the option of starting the hddtemp daemon automatically on x x system boot. If in doubt, it is suggested to not start it automatically x x on boot. x x x x This setting can be modified later by running 'dpkg-reconfigure x x hddtemp'. x x x x Should the hddtemp daemon be started at boot? x x x x <Yes> <No> x x x mqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqj
Noでも問題ない。
これで、下記のように打つと、ハードディスクの温度を調べることができる。
$ sudo hddtemp /dev/sda
/dev/sda: Hitachi HDT721025SLA380: 34 C
次に、この情報をgangliaに送る。
具体的には、下記のようなスクリプトを、cronで定期的に実行する。
#!/bin/bash GMETRIC=/usr/bin/gmetric # send cpu & gpu temps if gmond is running `ps -e | grep gmond > /dev/null` if [ $? -eq 0 ]; then # send HDD temperature $GMETRIC -t float -n "HDD Temp" --units Celcius -v `/usr/sbin/hddtemp /dev/sda | cut -b 36-37` fi
なお、スクリプト内ではhddtempは/usr/sbin/hddtempの様にフルパスで指定する。
なお、cutする位置は、ハードディスク名などによって微妙に変わってくる。上記スクリプトでは、36文字めから37文字目になっているが、適宜修正する。
Fedora10ではyumを使ってすべてインストールできる。
これは各ノードすべてにインストールする。
# yum install rrdtool
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package rrdtool.x86_64 0:1.3.4-2.fc10 set to be updated
--> Processing Dependency: dejavu-lgc-fonts for package: rrdtool
--> Running transaction check
---> Package dejavu-lgc-fonts.noarch 0:2.26-2.fc10 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
rrdtool x86_64 1.3.4-2.fc10 fedora 392 k
Installing for dependencies:
dejavu-lgc-fonts noarch 2.26-2.fc10 fedora 3.5 M
Transaction Summary
================================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 3.9 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): rrdtool-1.3.4-2.fc10.x86_64.rpm | 392 kB 00:06
(2/2): dejavu-lgc-fonts-2.26-2.fc10.noarch.rpm | 3.5 MB 00:49
--------------------------------------------------------------------------------
Total 71 kB/s | 3.9 MB 00:55
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : dejavu-lgc-fonts 1/2
Installing : rrdtool 2/2
Installed:
rrdtool.x86_64 0:1.3.4-2.fc10
Dependency Installed:
dejavu-lgc-fonts.noarch 0:2.26-2.fc10
Complete!
これも各ノードすべてにインストールする。
# yum install ganglia
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package ganglia.x86_64 0:3.1.1-1.fc10 set to be updated
--> Processing Dependency: libconfuse.so.0()(64bit) for package: ganglia
--> Running transaction check
---> Package libconfuse.x86_64 0:2.6-1.fc9 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ganglia x86_64 3.1.1-1.fc10 fedora 189 k
Installing for dependencies:
libconfuse x86_64 2.6-1.fc9 fedora 86 k
Transaction Summary
================================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 275 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): libconfuse-2.6-1.fc9.x86_64.rpm | 86 kB 00:01
(2/2): ganglia-3.1.1-1.fc10.x86_64.rpm | 189 kB 00:02
--------------------------------------------------------------------------------
Total 79 kB/s | 275 kB 00:03
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libconfuse 1/2
Installing : ganglia 2/2
Installed:
ganglia.x86_64 0:3.1.1-1.fc10
Dependency Installed:
libconfuse.x86_64 0:2.6-1.fc9
Complete!
これも各ノードすべてにインストールする。
# yum install ganglia-gmond
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package ganglia-gmond.x86_64 0:3.1.1-1.fc10 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ganglia-gmond x86_64 3.1.1-1.fc10 fedora 55 k
Transaction Summary
================================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 55 k
Is this ok [y/N]: y
Downloading Packages:
ganglia-gmond-3.1.1-1.fc10.x86_64.rpm | 55 kB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ganglia-gmond 1/1
Installed:
ganglia-gmond.x86_64 0:3.1.1-1.fc10
Complete!
自動起動するように、
# chkconfig gmond on
これは、データを表示するコンピュータにインストールする。
# yum install ganglia-gmetad
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package ganglia-gmetad.x86_64 0:3.1.1-1.fc10 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ganglia-gmetad x86_64 3.1.1-1.fc10 fedora 33 k
Transaction Summary
================================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 33 k
Is this ok [y/N]: y
Downloading Packages:
ganglia-gmetad-3.1.1-1.fc10.x86_64.rpm | 33 kB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : ganglia-gmetad 1/1
Installed:
ganglia-gmetad.x86_64 0:3.1.1-1.fc10
Complete!
自動起動するように、
# chkconfig gmetad on
ここまで来れば次のコマンドで、xmlデータが表示されるはずである。
$ telnet localhost 8649
これも、データを表示するコンピュータにインストールする。
# yum install ganglia-web
Loaded plugins: refresh-packagekit
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package ganglia-web.x86_64 0:3.1.1-1.fc10 set to be updated
--> Processing Dependency: php-gd for package: ganglia-web
--> Running transaction check
---> Package php-gd.x86_64 0:5.2.6-5 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
ganglia-web x86_64 3.1.1-1.fc10 fedora 113 k
Installing for dependencies:
php-gd x86_64 5.2.6-5 fedora 119 k
Transaction Summary
================================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 231 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): ganglia-web-3.1.1-1.fc10.x86_64.rpm | 113 kB 00:01
(2/2): php-gd-5.2.6-5.x86_64.rpm | 119 kB 00:01
--------------------------------------------------------------------------------
Total 84 kB/s | 231 kB 00:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : php-gd 1/2
Installing : ganglia-web 2/2
Installed:
ganglia-web.x86_64 0:3.1.1-1.fc10
Dependency Installed:
php-gd.x86_64 0:5.2.6-5
Complete!
ここで、/etc/httpd/conf.d/ganglia.confというファイルができる。内容は、
# # Ganglia monitoring system php web frontend # Alias /ganglia /usr/share/ganglia <Location /ganglia> Order deny,allow Deny from all Allow from 127.0.0.1 Allow from ::1 # Allow from .example.com </Location>
となっているが、これだと、localhostからしか、グラフを見ることができない。他のコンピュータからも見えるように次のようにコメントアウトする。
# # Ganglia monitoring system php web frontend # Alias /ganglia /usr/share/ganglia # <Location /ganglia> # Order deny,allow # Deny from all # Allow from 127.0.0.1 # Allow from ::1 # # Allow from .example.com # </Location>
これでhttpdを再起動する。
# /etc/ini.d/httpd restart
http://localhost/gangliaにアクセスする。
もし、ここでグラフが表示されずに、
There was an error collecting ganglia data (127.0.0.1:8652): fsockopen error: Permission denied
のようなエラーメッセージが出た場合は、SELinuxが有効になっている可能性がある。
手っ取り早い方法は、次のように打ってSELinuxをdisableにすることである。
# setenforce 0
もしくは、/etc/selinux/configファイル内で、
SELINUX=enforcing
となっているところを、
SELINUX=disabled
と書き換えて、OSを再起動する。
yumではインストールできないので、ソースファイルをここ(http://ganglia.sourceforge.net/)からダウンロードしてきて、手動でコンパイルしてインストールする必要がある。
ダウンロードサイトは、ここ(http://sourceforge.net/project/showfiles.php?group_id=43021&package_id=35280)。ダウンロードすべきファイルは、次の2つである。
ganglia-3.0.2.tar.gz ganglia-web-3.0.2-1.noarch.rpm
Gangliaを使用するには、Ganglia(gmond、gmetad、ganglia-web)の他に、rrdtool、php、apacheが必要である。ここでは、すでにapacheが稼働していて、かつ、apache上でphpが使用可能なものと仮定する。
まずあらかじめrrdtoolをインストールしておく。
# yum install rrdtool
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
core [1/3]
updates [2/3]
extras [3/3]
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Package rrdtool.x86_64 0:1.0.49-5.fc4 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
rrdtool x86_64 1.0.49-5.fc4 extras 435 k
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 435 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): rrdtool-1.0.49-5.f 100% |=========================| 435 kB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: rrdtool ######################### [1/1]
Installed: rrdtool.x86_64 0:1.0.49-5.fc4
Complete!
# yum install rrdtool-devel
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
core [1/3]
updates [2/3]
extras [3/3]
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for rrdtool-devel to pack into transaction set.
rrdtool-devel-1.0.49-5.fc 100% |=========================| 16 kB 00:00
---> Package rrdtool-devel.x86_64 0:1.0.49-5.fc4 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
rrdtool-devel x86_64 1.0.49-5.fc4 extras 168 k
Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 168 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): rrdtool-devel-1.0. 100% |=========================| 168 kB 00:00
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: rrdtool-devel ######################### [1/1]
Installed: rrdtool-devel.x86_64 0:1.0.49-5.fc4
Complete!
これでgangliaをコンパイルしても、次のようなエラーメッセージが出てうまくいかない。
The Ganglia Meta Daemon uses the Round-Robin Database Tool (rrdtool)
for storing historical information. You have chosen to compile the
monitoring core with gmetad but librrd.a could not be found. Please
visit http://www.rrdtool.org/, download rrdtool and then try again
NOTE: the rrdtool library (librrd) will NOT need to be installed on
every machine running gmetad only the machine you are compiling gmetad
on since librrd is statically linked.
しかたがないので、ここ(http://oss.oetiker.ch/rrdtool/)からrrdtoolのソースを取ってきてコンパイル
./configure
make
make install
これで/usr/local/rrdtool-1.2.12/にインストールされた。
つぎにGangliaを解凍し、そのディレクトリに行き
# ./configure LDFLAGS="-L/usr/local/rrdtool-1.2.12/lib" --with-gmetad
# make
# make install
gmondのデフォルト設定ファイルを作成し/etcにコピー
# cd gmond
# ./gmond --default_config > gmond.conf
# cp gmond.conf /etc/
起動スクリプトもコピー
# cp gmond.init /etc/rc.d/init.d/gmond
# /etc/init.d/gmond start
# chkconfig gmond on
次にgmetad。gmetadディレクトリに行き、設定ファイルと起動スクリプトをコピー。
# cp gmetad.conf /etc/
# cp gmetad.init /etc/rc.d/init.d/gmetad
gmetad.confの方を変更してもよいがここではデフォルト値を使うとして、/var/lib/ganglia/rrdsというフォルダを作り、所有者をnobody:nobodyに変更する。
# cd /var/lib
# mkdir ganglia
# cd ganglia
# mkdir rrds
# chown nobody:nobody rrds
そしてgmetadを起動する。
# /etc/init.d/gmetad start
# chkconfig gmetad on
ここまでくれば、次のコマンドで、xmlデータが表示されるはずである。
$ telnet localhost 8649
最後にwebからアクセスしてグラフを見られるようにするために、つぎのものをインストールする。
# rpm -Uvh ganglia-web-3.0.2-1.noarch.rpm
Preparing... ########################################### [100%]
1:ganglia-web ########################################### [100%]
今回は、/usr/local/rrdtool-1.2.12/にインストールしたので、conf.php内の
define("RRDTOOL", "/usr/bin/rrdtool");
を
define("RRDTOOL", "/usr/local/rrdtool-1.2.12/bin/rrdtool");
に変更する。
http://www.example.com/ganglia/でアクセスすると、グラフが表示される。
apacheも変更する必要があるかも
AddType application/x-httpd-php-source .phps必要?
最終更新日