だぁやま的 Fedora8 に Munin インストール

準備

  • rrdtool install
     
     tar xvfz rrdtool-1.2.27.tar.gz 
     cd rrdtool-1.2.27
     ./configure --prefix=/usr/local/rrdtool
     make
     sudo make install
     sudo make site-perl-install
    
  • Perl Modules
    1. Crypt-CBC-2.29
    2. Crypt-DES-2.05
    3. Digest-SHA1-2.11
    4. Digest-HMAC-1.01
    5. Net-SNMP-5.2.0
    6. Test-Simple-0.80
    7. HTML-Template-2.9
    8. Net-Server-0.97
    9. Date-Manip-5.54
      • 以下DateManipのための努力
      • Pod-Escapes-1.04
      • Pod-Simple-3.05
      • Test-Pod-1.26
      • Devel-Symdump-2.08
      • Pod-Coverage-0.19
      • Test-Pod-Coverage-1.08
  • Munin Install
    1. /usr/sbin/groupadd -g 600 munin
    2. /usr/sbin/useradd -u 600 -g 600 munin
    3. cd munin-1.2.6/
    4. vi Makefile.config
      #
      # the base of the Munin installation.
      # 
      #PREFIX     = $(DESTDIR)/opt/munin
      PREFIX     = /usr/local/munin
      
    5. make install-main
    6. make install-node install-node-plugins
    7. /usr/local/munin/sbin/munin-node-configure –shell | sh
      • これをしないとmunin-nodeは何もしない=グラフが表示されない。

Setup

  • このままじゃRRD-Toolが見つからないので、各種ファイルを変更。
    • 変更対象
    1. /usr/local/munin/lib/munin-graph
    2. /usr/local/munin/lib/munin-update
    3. [追記] 最近のは munin-html / munin-limits にも書く必要がある
      • use lib でrrdの場所を記述
        use lib '/usr/local/rrdtool/lib/perl';
        
        use RRDs;
        use Munin;
        
  • 画像ファイルが /usr/local/munin/var/www/ にできた。
    1. あまりにも深いので、 ApacheからAliasでショートカット。
      # Munin
      Alias /munin/ "/usr/local/munin/var/www/"
      
      <Directory "/usr/local/munin/var/www">
          Options Indexes MultiViews FollowSymLinks
          AllowOverride All
          Order allow,deny
          Allow from all
      </Directory>
      
  • munin-cron をcronに追加
    # vi /etc/crontab
    */5 * * * *  munin /usr/local/munin/bin/munin-cron 2>&1
    
  • Nodeの起動用ファイルの配置
    • srcディレクトリの dist/redhat/munin-node.rc を /etc/rc.d/init.d/ にコピー。

DEBUG

  • 動かねーよって場合の対応
    • munin-node にtelnet してみる。
    • telnet で ディスク状態を見てみる。
      $ telnet localhost 4949
      Trying 127.0.0.1...
      Connected to localhost.
      Escape character is '^]'.
      # munin node at RX-93
      fetch df
      _dev_sda3.value 12
      _dev_sda6.value 1
      _dev_sda2.value 36
      _dev_sda1.value 19
      tmpfs.value 1
      .
      quit
      Connection closed by foreign host.
      
  • 動いていない場合には、munin-node.conf や Pluginsがあることを確認する。
    • なお、confやpluginsを変更した場合には、munin-nodeをrestartすることを忘れずに。

Munin-node インストール

  • ユーザ作成
    # /usr/sbin/groupadd -g 6000 munin
    # /usr/sbin/useradd -u 6000 -g 6000 -s /sbin/nologin munin
    
  • ディレクトリ整備
    # mkdir /home/munin
    # mkdir /home/munin/dbdir
    # chown -R munin.munin /home/munin
    # chmod 755 /home/munin
    # mkdir /var/log/munin
    # chown -R munin.munin /var/log/munin
    
  • 必要なもの
    1. Net-SNMP-5.2.0
      1. Crypt-DES-2.05
      2. Digest-SHA1-2.11
        1. Digest-HMAC-1.01
    2. Net-Server-0.9
  • 展開
    1. tar xvfz munin_1.6.2rc2.tar.gz
    2. cd munin-1.6.2~rc2
  • Munin-node の Makefile.config の変更箇所
    PREFIX=/usr/local/munin
    CONFDIR=$(PREFIX)/etc
    DBDIR=/home/munin/dbdir
    LOGDIR=/var/log/munin
    STATEDIR=/var/run/munin
    
  • make
    # make install-node
    # make install-node-plugins
    
  • 起動ファイルの配置
    1. vi dist/redhat/munin-node.rc
      1. munin-node のディレクトリPATHを確認、変更
    2. sudo cp dist/redhat/munin-node.rc /etc/rc.d/init.d
    3. sudo /sbin/chkconfig –level 3 munin-node.rc on
  • Pluginの自動配置
    # /usr/local/munin/sbin/munin-node-configure --shell | sh
    
  • munin-node 起動
    1. /etc/rc.d/init.d/munin-node.rc start
  • Debug
    1. telnet localhost 4949
      1. fetch df でディスク情報がとれることを確認。
  • munin-node.conf で許可IP追加
    1. vi /usr/local/munin/etc/munin-node.conf
      • allow を正規表現で追加
      • 変更後は munin-node を restartする。

マイプラグイン作成

  1. 今回はDB2のコネクション数をとってみる
  2. でも、5分毎のCronに出力する必要がなかったので、30分毎のデータを集めることにした。
  • データ出力
    • db2inst1権限のcrontabで30分毎にコネクション数を出力するように設定。
      • cron用のShell作成
        # su - db2inst1
        $ vi DB2connection.sh
        #!/bin/bash
        
        /opt/ibm/db2/V9.1/bin/db2  list  applications  2>&1 | wc -l  >  /var/tmp/db2connectoins
        
      • crontab 設定
        $ crontab -e
        */30 * * * * sh /home/db2inst1/DB2connection.sh
        
  • プラグイン作成
    • code
      # cd /usr/local/munin/lib/plugins
      # vi db2_connect
      #!/bin/sh
      
      case $1 in
          config)
              cat <<'EOM'
      graph_order  connection
      graph_title  DB2 connections
      graph_vlabel connection
      graph_category  DB2
      connection.label  DB2 connections
      EOM
              exit 0;;
      esac
      
      echo -n 'connection.value '
      cat /var/tmp/db2connections
      
    • chmod 755 するのを忘れずに。
  • テスト
    • Symlink作成
      # cd /usr/local/munin/etc/plugins
      # ln -s /usr/local/munin/lib/plugins/db2_connect ./
      
    • munin-run テスト
      # /usr/local/munin/sbin/munin-run db2_connect
      connection.value 77
      # /usr/local/munin/sbin/munin-run db2_connect config
      graph_order  connection
      graph_title  DB2 connections
      graph_vlabel connection
      graph_category  DB2
      connection.label  DB2 connections
      
    • 問題なければmunin-nodeを再起動し、反映する。
      # /etc/rc.d/init.d/munin-node.rc restart
      
    • 念のためmuninサーバからtelnet してみる
      $ telnet db2server  4949
      fetch db2_connect
      connection.value 77
      .
      fetch db2_connect config
      graph_order  connection
      graph_title  DB2 connections
      graph_vlabel connection
      graph_category  DB2
      connection.label  DB2 connections
      .
      quit
      
    • グラフオプション
      1. 1000 を越える数字の場合、1kなどと表示されてしまう。この単位を指定する。例は1k=1024。
        graph_args --base 1024
        
      2. 1000 を越える数字の場合、1kなどと表示されてしまう。これをやめる。
        graph_scale  no
        

ALERT設定してみる

munin.conf

  • munin.conf に下記を追記
    contact.email.command       /usr/local/bin/email -s "SDLAB ALERT - ${var:group}::${var:host}"  daxayama@sdlab.org
    contact.email.max_messages  3
    contact.email.always_send   warning critical
    
  • なお、/usr/local/bin/email は 普通のmailコマンドに置き換えてください。
  • max_messages 3 は 3回まで(15分間)はメール送るという意味。見逃さないように3回にした。
  • Alert対象から外したい場合は、対象.contacts no でOK
    [GROUPS;servername]
        address xx.xx.xx.xx
        df.contacts no
    
  • サーバ単位でAlertを止める場合には、contacts noと記述
  • その他にこんな値も出せるよ。
    ${var:worst}  WARNING / CRITICAL
    ${var:graph_title} グラフタイトル
    詳しくは、munin-limit のsourceみちゃえ
    

plugin 設定を変更

  • さっき作成したdb2を例にする。
  • code
    #!/bin/sh
    
    case $1 in
        config)
            cat <<'EOM'
    graph_order  connection
    graph_title  DB2 connections
    graph_vlabel connection
    graph_category  DB2
    connection.label  DB2 connections
    connection.warning  200:
    connection.critical 250:
    EOM
            exit 0;;
    esac
    
    echo -n 'connection.value '
    cat /var/tmp/db2connections
    
  • 2行追加しました。
    • connection.warning 200: は 200を越えたらALERT。 200を下回ったらALERTは:200。10以上200未満が正常値なら、 10:200。これから外れるとALERT。

ALERT SAMPLE

  • サンプル
    Subject: SDLAB ALERT - DB::db2m
    
    DB :: db2m :: DB2 connections
    	CRITICALs: DB2 connections is 252.00 (outside range [:250]).
    
  • 正常値にもどる
    Subject: SDLAB ALERT - DB::db2m
    
    DB :: db2m :: DB2 connections
    	OKs: DB2 connections is 202.00 
    

TIPS

画像サイズを変更

  • デフォルトで表示される画像は、「495 x 276」くらいの大きめなので、HTMLで表示させると横1024をやや越えて気持ち悪い。#br これをmunin.confで一括指定可能。
  • 全体適応 munin.confうまく動いてくれない?
    # Make graphs show values per minute. instead of per second
    #graph_period minute
    の下あたりに追記
    graph_height 220
    graph_width  400
    
    
  • 個別適応 munin.conf
    # a simple host tree
    [DB2;db2server]
        address 192.168.0.100
        use_node_name  yes
        graph_height 220
        graph_width  400
    ※上記は80%縮小、ホストツリーに書いてあげればOK
    

グラフの指定。最大値とか

  • 使っていると、「あれ?muninってどーやって最大値していするの?」という疑問がでてくる。
    • Pluginでrrdtoolに引数を渡すパラメータを指定すればOK
      graph_args --base 1000 -r --lower-limit 0 --upper-limit 1500
      
      • ちなみに、Kとかで丸めたくない人は、graph_scaleを指定すればよい。
        graph_scale  no
        
    • –baseは 1K の単位指定。byteなどを扱う場合には1024で指定する。
    • –lower-limit 0 はグラフの下限の値を0にする。
    • –upper-limit 1500 はグラフの上限を1500にする。
    • -r は自動スケールを許可する。
  • 他には、こんなのあるけど試してない。
 
fedora8-munin.txt · 最終更新: 2009/11/04 19:20 by kojiyamada
 
Recent changes RSS feed
© だぁやま