# cd /etc/snmp # cp snmpd.conf snmpd.conf.org
#### # First, map the community name "public" into a "security name" # sec.name source community #com2sec notConfigUser default public com2sec local localhost private com2sec mynetwork 192.168.0.0/24 public #### # 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.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 MyROGroup "" any noauth exact all none none access MyRWGroup "" any noauth exact all all none #### # Second, map the security name into a group name: # groupName securityModel securityName #group notConfigGroup v1 notConfigUser #group notConfigGroup v2c notConfigUser group MyROGroup v1 mynetwork group MyROGroup v2c mynetwork group MyROGroup usm mynetwork # Check the / partition and make sure it contains at least 10 megs. disk / 10000
# /etc/init.d/snmpd start # /sbin/chkconfig snmpd on
WorkDir: /var/www/mrtg Options[_]: growright, noinfo EnableIPv6: no Language:eucjp
### Interface eth0 / ns ### Target[eth0]: \eth0:public@192.168.0.xxx: SetEnv[eth0]: MRTG_INT_IP="192.168.0.xxx" MRTG_INT_DESCR="eth0" MaxBytes[eth0]: 12500000 Title[eth0]: eth0 -- ns PageTop[eth0]: <H1>eth0 -- ns</H1>
### CPU Load Average / ns ### 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.0.xxx 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使用率 -- ns PageTop[cpu]: <H1>CPU使用率 -- ns</H1>
### Memory Free / ns #### 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.0.xxx MaxBytes1[mem]: 483228 ← freeコマンドによる実メモリ合計値 MaxBytes2[mem]: 983032 ← freeコマンドによるスワップ合計値 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]: 空きメモリ量 -- ns PageTop[mem]: <H1>空きメモリ量 -- ns</H1>
### Disk Used / ns #### 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.0.xxx 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 Used Legend1[disk]: / Disk used Legend2[disk]: / Disk used Title[disk]: ディスク使用率 -- ns PageTop[disk]: <H1>ディスク使用率 -- ns</H1>
# mrtg /etc/mrtg/mrtg.cfg # mrtg /etc/mrtg/mrtg.cfg # mrtg /etc/mrtg/mrtg.cfg
# vi /etc/httpd/conf.d/mrtg.conf
# /etc/init.d/httpd restart
http://サーバIPアドレス/mrtg/eth0.html http://サーバIPアドレス/mrtg/cpu.html http://サーバIPアドレス/mrtg/mem.html http://サーバIPアドレス/mrtg/disk.html
Target[xxx]: .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.0.xxx xxx には、mrtgで管理する単位を指定します。この xxx がmrtgコマンドによって、xxx.htmlと作成されます。 .1.3.6.1.4.1.2021.9.1.9.1 は、snmpのMIB情報を指定します。 :public@192.168.0.xxx は、どのアドレス、コミニティを指定します。
Target[xxx]: `/home/script/hoge.pl`` グラフ化に使用するのは、第1,2パラメタしか実際は使用しないので下記のような プログラムでグラフ化することができます。実際には処理結果の値を設定しますよね(w #!/usr/bin/perl printf "20\n5\n\n\n";
Title[xxx]: ディスク使用率 -- ns xxx には、mrtgで管理する単位を指定します。この xxx がmrtgコマンドによって、xxx.htmlと作成されます。 ディスク使用率 -- ns は、タイトルです。
indexmaker --columns=1 \ --addhead="<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=euc-jp\">" \ /etc/mrtg/mrtg.cfg > /var/www/mrtg/index.html
http://サーバIPアドレス/mrtg
exec .1.3.6.1.4.1.2021.50 shelltest /bin/sh /tmp/shtest
% snmpwalk -v 1 localhost public .1.3.6.1.4.1.2021.50 enterprises.ucdavis.50.1.1 = 1 enterprises.ucdavis.50.2.1 = "shelltest" enterprises.ucdavis.50.3.1 = "/bin/sh /tmp/shtest" enterprises.ucdavis.50.100.1 = 35 enterprises.ucdavis.50.101.1 = "hello world." enterprises.ucdavis.50.101.2 = "hi there." enterprises.ucdavis.50.102.1 = 0
Target[xxx]: .1.3.6.1.4.1.2021.50.101.1&.1.3.6.1.4.1.2021.50.101.2:public@192.168.0.xxx