FreeBSD に munin をインストールする
munin をインストールする
ports から munin をインストールする。
% cd /usr/ports/sysutils/munin-master % sudo make install clean ******************************************************************** Unless this file already existed, a sample configuration file has been placed in /usr/local/etc/munin/munin.conf. Please edit it according to your needs. The Munin server will be run from cron under the user 'munin'. ******************************************************************** ===> Correct pkg-plist sequence to create group(s) and user(s) % cd ../munin-node/ % sudo make install clean Initializing new plugins..# FATAL: version '1.4.7' was not found in the plugin history file done. Cannot 'start' munin_node. Set munin_node_enable to YES in /etc/rc.conf or use 'onestart' instead of 'start'. Would you like me to set up log rotation [y]? y ******************************************************************** Unless this file already existed, a sample configuration file has been placed in /usr/local/etc/munin/munin-node.conf. Please edit it according to your needs. ******************************************************************** The Munin client will *not* be started automatically. To allow it to start, put this line in /etc/rc.conf: munin_node_enable="YES" Then, it will be started on the next boot. If this line is already present, the client will be started now. Otherwise, edit /etc/rc.conf and execute this command: /usr/local/etc/rc.d/munin-node start ******************************************************************** ===> Correct pkg-plist sequence to create group(s) and user(s)
インストール後のメッセージに表示されているように、munin をデーモンとして起動させるために、rc.conf に「munin_node_enable="YES"」を追記する。
% sudo echo 'munin_node_enable="YES"' >> /etc/rc.conf Password:
munin で監視するプラグインの設定をする
古い記述だと「ln」コマンドでひとつひとつのプラグインからシムリンクを張って利用するように書かれているが、今はコマンドで利用できるプラグインの一覧、設定が必要なプラグインなどを表示して、各プラグインの設定をして、稼働させるところまでやれるようになっている。
% munin-node-configure --suggest Plugin | Used | Suggestions ------ | ---- | ----------- amavis | no | no apache_accesses | no | no [apache server-status not found. check if mod_status is enabled] apache_processes | no | no [apache server-status not found. check if mod_status is enabled] apache_volume | no | no [apache server-status not found. check if mod_status is enabled] apc_envunit_ | no | no [no units to monitor] courier_mta_mailqueue | no | no [spooldir not found] courier_mta_mailstats | no | no [could not find executable] courier_mta_mailvolume | no | no [could not find executable] cpu | no | yes cupsys_pages | no | no [could not find logdir] dev_cpu_ | no | no [function not supported by kernel] df | no | yes df_inode | no | yes exim_mailqueue | no | no [no exiqgrep] exim_mailstats | no | no ['/usr/local/sbin/exim -bP log_file_path' returned an error] fail2ban | no | no [/usr/bin/fail2ban-client not found] hddtemp_smartctl | no | no http_loadtime | no | no [need time and wget programs] if_ | no | yes (+em0 +usbus) if_errcoll_ | no | yes (+em0 +usbus) iostat | no | yes jmx_ | no | no [java runtime not found at /usr/bin/java] load | no | yes lpstat | no | no [lpstat not found] memory | no | yes munin_stats | no | yes mysql_ | no | no [DBI connect('mysql;mysql_connect_timeout=5','root',...) failed: Access denied for user 'root'@'localhost' (using password: NO)] netstat | no | yes nginx_request | no | no [no nginx status on http://www.example.com/nginx_status] nginx_status | no | no [no nginx status on http://localhost/nginx_status] ntp_kernel_err | no | yes ntp_kernel_pll_freq | no | yes ntp_kernel_pll_off | no | yes ntp_offset | no | yes nvidia_ | no | no [no nvclock executable at /usr/bin/nvclock, please configure] open_files | no | yes postfix_mailqueue | no | no [spooldir not found] postfix_mailvolume | no | no [postfix not found] postgres_bgwriter | no | no [DBD::Pg not found, and cannot do psql yet] postgres_cache_ | no | no [DBD::Pg not found, and cannot do psql yet] postgres_checkpoints | no | no [DBD::Pg not found, and cannot do psql yet] postgres_connections_ | no | no [DBD::Pg not found, and cannot do psql yet] postgres_connections_db | no | no [DBD::Pg not found, and cannot do psql yet] postgres_locks_ | no | no [DBD::Pg not found, and cannot do psql yet] postgres_querylength_ | no | no [DBD::Pg not found, and cannot do psql yet] postgres_scans_ | no | no [DBD::Pg not found, and cannot do psql yet] postgres_size_ | no | no [DBD::Pg not found, and cannot do psql yet] postgres_transactions_ | no | no [DBD::Pg not found, and cannot do psql yet] postgres_tuples_ | no | no [DBD::Pg not found, and cannot do psql yet] postgres_users | no | no [DBD::Pg not found, and cannot do psql yet] postgres_xlog | no | no [DBD::Pg not found, and cannot do psql yet] processes | no | yes ps_ | no | no qmailqstat | no | no sendmail_mailqueue | no | yes sendmail_mailstats | no | yes sendmail_mailtraffic | no | yes slapd_ | no | no [Net::LDAP not found] slapd_bdb_cache_ | no | no [Can't execute db_stat file '/usr/bin/db4.6_stat'] slony_lag_ | no | no [DBD::Pg not found, and cannot do psql yet] smart_ | no | no [smartmontools not found] snort_alerts | no | no [/var/snort/snort.stats not readable] snort_bytes_pkt | no | no [/var/snort/snort.stats not readable] snort_drop_rate | no | no [/var/snort/snort.stats not readable] snort_pattern_match | no | no [/var/snort/snort.stats not readable] snort_pkts | no | no [/var/snort/snort.stats not readable] snort_traffic | no | no [/var/snort/snort.stats not readable] squeezebox_ | no | no [no connection on localhost port 9090] squid_cache | no | no [could not connect: Invalid argument] squid_objectsize | no | no [could not connect: Connection refused] squid_requests | no | no [could not connect: Invalid argument] squid_traffic | no | no [could not connect: Invalid argument] swap | no | yes systat | no | yes tomcat_ | no | no users | no | yes varnish_ | no | no [which varnishstat returns blank] vmstat | no | yes zimbra_ | no | no [No Text::CSV_XS]
「Used」の項目で「yes」なら動作中、「Suggestions」が「no」ならプラグインごとに設定をしないと動かないことを示している。
例えば、「mysql_」プラグインの場合だと、MySQL へ接続するユーザー権限が未設定であると表示されている。設定を記述するファイルは、munin の plugins.conf に記述する。設定の記述方法は、プラグインごとに異なるので、注意する。
% sudo cp /usr/local/etc/munin/plugin-conf.d/plugins.conf /usr/local/etc/munin/plugin-conf.d/plugins.conf.orig % cd /usr/local/etc/munin/plugin-conf.d/ % sudo chmod 0664 plugins.conf % sudo vi plugins.conf [mysql_*] env.mysqlconnection DBI:mysql:mysql;host=127.0.0.1;port=3306 env.mysqluser root env.mysqlpassword yourpassword
また、「nginx_request」や「nginx_status」の場合だと、nginx.conf に nginx_status の設定が有効になっていないのと、割り当てているドメイン名に nginx_status の設定が有効になっていないことがわかる。
利用したいプラグインの「Suggestions」が「yes」になるように、ひとつひとつを設定する。各プラグインには設定方法や設定項目が記載されているので、プラグインの中身を確認するとよい。
nginx_status の場合ならば、プラグインと HttpStubStatusModule を読み、nginx.conf を下記のように設定する。
server { listen 80; server_name localhost www.example.com; location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; allow 192.168.xxx.xxx; deny all; }
利用したいプラグインの設定方法は、直接プラグインのファイルに記述されているので確認すること。
% munin-node-configure --suggest
設定が終わったら、使いたいプラグインの「Suggestions」が「yes」になるまで修正をする。
プラグインを所定のディレクトリに配置して、munin を稼働させる
設定が終了したら、プラグインを設置して munin を稼働させる。この際、root になって作業を進める。
# munin-node-configure --shell | sh -x # /usr/local/etc/rc.d/munin-node start Starting munin_node.
起動したら、munin-node.conf で設定したポート番号を指定(初期状態ならば、4949番)して、munin が稼働しているか確認する。稼働していない場合は、「/var/log/munin/」下にある各ログファイルをメッセージ内容を読んで、どこでエラーが発生しているのか把握して修正を重ねる。