![]() |
| ◆ | NET-SNMP のインストール |
|
[root@centos]# yum -y install net-snmp <--- 入力 [root@centos]# yum -y install net-snmp-utils <--- 入力 |
|
| ◆ | snmpd.conf の設定 |
|
[root@centos]# vi /etc/snmp/snmpd.conf <--- 入力 途中略 #### # First, map the community name "public" into a "security name" # sec.name source community com2sec notConfigUser default public <--- コメント化 ↓ #com2sec notConfigUser default public com2sec local localhost private <--- 追記 com2sec mynetwork 192.168.1.0/24 public <--- 追記(public は任意な名前) #### # Second, map the security name into a group name: # groupName securityModel securityName group notConfigGroup v1 notConfigUser <--- 書き換え ↓ group MyROGroup v1 mynetwork group notConfigGroup v2c notConfigUser <--- 書き換え ↓ group MyROGroup v2c mynetwork #### # Third, create a view for us to let the group have rights to: # Make at least snmpwalk -v 1 localhost -c public system fast again. # name incl/excl subtree mask(optional) view systemview included .1.3.6.1.2.1.1 <--- コメント化 ↓ #view systemview included .1.3.6.1.2.1.1 view systemview included .1.3.6.1.2.1.25.1.1 <--- コメント化 ↓ #view systemview included .1.3.6.1.2.1.25.1.1 view all included .1 80 <--- 追記 #### # Finally, grant the group read-only access to the systemview view. # group context sec.model sec.level prefix read write notif access notConfigGroup "" any noauth exact systemview none none <--- コメント化 ↓ #access notConfigGroup "" any noauth exact systemview none none access MyROGroup "" any noauth exact all none none <--- 追記 access MyRWGroup "" any noauth exact all all none <--- 追記 途中略 ############################################################################### # disk checks # # The agent can check the amount of available disk space, and make # sure it is above a set limit. # disk PATH [MIN=100000] # # PATH: mount path to the disk in question. # MIN: Disks with space below this value will have the Mib's errorFlag set. # Default value = 100000. <--- コメント解除 ↓ Default value = 100000. # Check the / partition and make sure it contains at least 10 megs. #disk / 10000 <--- コメント解除 ↓ disk / 10000 以下略 |
|
| ◆ | 起動 |
|
[root@centos]# /etc/rc.d/init.d/snmpd start <--- 入力 |
|
| 自動起動設定 | |
|
[root@centos]# chkconfig snmpd on <--- 入力 |
|
| 自動起動設定の確認 | |
|
[root@centos]# chkconfig --list snmpd <--- 入力 snmpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off <--- 2・3・4・5 が on になっていればOK |
|
| ◆ | MRTG のインストール |
|
[root@centos]# yum -y install mrtg <--- 入力 |
|
| ◆ | メモリの確認 |
| 設定の際に必要になるので緑字のメモリ数値を控えておく | |
|
[root@centos]# free <--- 入力 total used free shared buffers cached Mem: 502996 289760 213236 0 34620 185228 -/+ buffers/cache: 69912 433084 Swap: 1015800 0 1015800 |
|
| ◆ | MRTG 用ディレクトリ作成 |
|
[root@centos]# mkdir /home/***/mrtg <--- 入力 |
|
| アクセス権を変更 | |
|
[root@centos]# chmod 755 /home/***/mrtg <--- 入力 |
|
| 所有者変更 | |
|
[root@centos]# chown apache. /home/****/mrtg/ <--- 入力 |
|
| ◆ | MRTG 設定ファイル作成 |
|
[root@centos]# cfgmaker --ifref=descr --ifdesc=descr public@192.168.1.*** > /etc/mrtg/mrtg.cfg <--- 入力 |
|
| ※上記の public@192.168.1.*** は snmpd.conf で設定した任意な名前とサーバーのアドレス | |
| ◆ | MRTG の設定 |
|
[root@centos]# vi /etc/mrtg/mrtg.cfg # Created by # /usr/bin/cfgmaker --ifref=descr --ifdesc=descr public@192.168.1.*** ### Global Config Options # for UNIX # WorkDir: /home/http/mrtg <--- コメント解除して書き換え ↓ WorkDir: /home/****/mrtg <--- 上記で作成した MRTG 用ディレクトリを指定 # or for NT # WorkDir: c:\mrtgdata ### Global Defaults # to get bits instead of bytes and graphs growing to the right # Options[_]: growright, bits <--- コメント解除して書き換え ↓ Options[_]: growright, noinfo EnableIPv6: no Language:eucjp <--- 追記 文字コード指定 ###################################################################### # System: papa-net.info # Description: Linux papa-net.info 2.6.32-220.7.1.el6.i686 #1 SMP Tue Mar 6 21:21:22 GMT 2012 i686 # Contact: Root <root@localhost> (configure /etc/snmp/snmp.local.conf) # Location: Unknown (edit /etc/snmp/snmpd.conf) ###################################################################### 途中略 ### Interface 2 >> Descr: 'eth0' | Name: 'eth0' | Ip: '192.168.1.***' | Eth: '00-00-00-00-00-00' ### Target[192.168.1.***_eth0]: \eth0:public@192.168.1.***: <--- 書き換え ↓ Target[eth0]: \eth0:public@192.168.1.***: SetEnv[192.168.1.***_eth0]: MRTG_INT_IP="192.168.1.***" MRTG_INT_DESCR="eth0" <--- 書き換え ↓ SetEnv[eth0]: MRTG_INT_IP="192.168.1.***" MRTG_INT_DESCR="eth0" MaxBytes[192.168.1.***_eth0]: 12500000 <--- 書き換え ↓ MaxBytes[eth0]: 12500000 Title[192.168.1.***_eth0]: eth0 -- papa-net.info <--- 書き換え ↓ Title[eth0]: ネットワーク状況 PageTop[192.168.1.***_eth0]: <h1>eth0 -- papa-net.info</h1> <--- 書き換え ↓ PageTop[eth0]: <h1>ネットワーク状況</h1> 以下略 以下最終行に追記 #--- CPU --- Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:public@192.168.1.*** <--- サーバー MaxBytes[cpu]: 100 のアドレス Unscaled[cpu]: dwmy Options[cpu]: gauge, absolute, growright, noinfo, nopercent YLegend[cpu]: CPU Load(%) ShortLegend[cpu]: (%) LegendI[cpu]: 1分間平均 LegendO[cpu]: 5分間平均 Legend1[cpu]: 1分間平均(%) Legend2[cpu]: 5分間平均(%) Title[cpu]: CPU使用率 PageTop[cpu]: <H1>CPU使用率</H1> #--- Memory --- Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@192.168.1.*** <--- サーバーの MaxBytes1[mem]: 502996 <--- メモリ確認で表示された men の total 値 アドレス MaxBytes2[mem]: 1015800 <--- メモリ確認で表示された Swap の total 値 Unscaled[mem]: dwmy Options[mem]: gauge, absolute, growright, noinfo YLegend[mem]: Mem Free(Bytes) ShortLegend[mem]: Bytes kilo[mem]: 1024 kMG[mem]: k,M,G,T,P LegendI[mem]: Real LegendO[mem]: Swap Legend1[mem]: 空き物理メモリ[MBytes] Legend2[mem]: 空きスワップメモリ[MBytes] Title[mem]: 空きメモリ量 PageTop[mem]: <H1>空きメモリ量</H1> #--- Disk --- Target[disk]: .1.3.6.1.4.1.2021.9.1.9.1&.1.3.6.1.4.1.2021.9.1.9.1:public@192.168.1.*** <--- サーバー MaxBytes[disk]: 100 Unscaled[disk]: dwmy のアドレス Options[disk]: gauge, absolute, growright, nopercent, noinfo YLegend[disk]: Disk Used(%)ShortLegend[disk]: (%) LegendI[disk]: / Disk used LegendO[disk]: / Disk UsedLegend1[disk]: / Disk used Legend2[disk]: / Disk used Title[disk]: ディスク使用率 PageTop[disk]: <H1>ディスク使用率</H1> |
|
| ◆ | 文字コードの変更(文字化け対策) |
|
[root@centos]# yum -y install nkf <--- 入力(文字コード変換ツールのインストール) [root@centos]# cp /etc/mrtg/mrtg.cfg /etc/mrtg/mrtg.cfg.org <--- 入力 [root@centos]# nkf -e /etc/mrtg/mrtg.cfg <--- 入力 |
|
| ※元のファイルをコピーし mrtg.cfg.org と言う名前で保存 | |
| ※元のファイルを EUC コードに変換 | |
| ◆ | Apache 用 MRTG の設定 |
|
[root@centos]# vi /etc/httpd/conf.d/mrtg.conf <--- 入力 # # This configuration file maps the mrtg output (generated daily) # into the URL space. By default these results are only accessible # from the local host. # Alias /mrtg /var/www/mrtg <--- 書き換え 作成した MRTG 用ディレクトリを指定 ↓ Alias /mrtg /home/***/mrtg <Location /mrtg> Order deny,allow Deny from all Allow from 127.0.0.1 Allow from 192.168.1.0/24 <--- 追記(LAN 内から MRTG へのアクセスを許可) Allow from ::1 # Allow from .example.com </Location> |
|
| ◆ | Apache の再読込み |
|
[root@centos]# /etc/rc.d/init.d/httpd reload <--- 入力 |
|
| ◆ | MRTG の実行 |
|
[root@centos]# LANG=C mrtg /etc/mrtg/mrtg.cfg <--- 入力 |
|
| ※起動時に過去2回のログを使用するため mrtg.cfg の修正後は上記コマンドを3回実行 | |
| ※CentOS のデフォルト文字コードがUTF-8のため LANG=C と指定して実行 | |
| ◆ | インデックスページの作成 |
|
[root@centos]# indexmaker --columns=1 /etc/mrtg/mrtg.cfg > /home/***/mrtg/index.html <--- 入力 |
|
| ◆ | MRTG の自動実行の確認 |
|
[root@centos]# cat /etc/cron.d/mrtg <--- 入力 */5 * * * * root LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok |
|
| ※上記のように cron で5分毎に実行されるようになっている事を確認 | |
| ◆ | ブラウザ確認 |
| http://<サーバーのアドレス>/mrtg | |
|
|
|
| 各グラフをクリックする事により詳細が表示される | |