<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ststyle.net &#187; net-snmp</title>
	<atom:link href="http://www.ststyle.net/weblog/archives/tag/net-snmp/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ststyle.net/weblog</link>
	<description>Just another ststyle techlog</description>
	<lastBuildDate>Mon, 19 Jul 2010 13:53:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>net-snmp インストール</title>
		<link>http://www.ststyle.net/weblog/archives/410</link>
		<comments>http://www.ststyle.net/weblog/archives/410#comments</comments>
		<pubDate>Thu, 22 Oct 2009 04:18:41 +0000</pubDate>
		<dc:creator>ststyle</dc:creator>
				<category><![CDATA[Watch]]></category>
		<category><![CDATA[net-snmp]]></category>

		<guid isPermaLink="false">http://www.ststyle.net/weblog/?p=410</guid>
		<description><![CDATA[SNMPのインストール
「SNMP」とは「Simple Network Management Protocol」の略でルータやコンピュータなどの
様々な機器を監視、制御するためのプロトコルです。
SourceForget [...]]]></description>
			<content:encoded><![CDATA[<h3>SNMPのインストール</h3>
<p style="padding-left: 30px;">「SNMP」とは「Simple Network Management Protocol」の略でルータやコンピュータなどの<br />
様々な機器を監視、制御するためのプロトコルです。</p>
<p style="padding-left: 30px;">SourceForgetから<br />
net-snmp-5.1.2.tar.gzをDLします</p>
<p>http://sourceforge.net/project/showfiles.php?group_id=12694</p>
<pre class="brush: bash; auto-links: false;">

$ tar xvzf net-snmp-5.4.1.2.tar.gz
$ cd net-snmp-5.4.1.2
$ ./configure
$ make
$ su
# make install
</pre>
<p style="padding-left: 30px;">./configureの途中でSNMPのバージョンを</p>
<p style="padding-left: 30px;">一番最初に問われるので <span style="color: #3366ff;">&#8221; v2 &#8220;</span> と入力し、（Enterでも良いです）<br />
あとは全てEnterですっ飛ばします。</p>
<h3>SNMP設定</h3>
<p style="padding-left: 30px;">デーモンの設定を行います</p>
<p>デフォルトの設定をコピーして、編集します。<br />
編集すべき部分を矢印で示しますので、変更してください。</p>
<pre class="brush: bash; auto-links: false;">

# cp EXAMPLE.conf /usr/local/share/snmp/snmpd.conf
# vi /usr/local/share/snmp/snmpd.conf

####
# First, map the community name (COMMUNITY) into a security name
# (local and mynetwork, depending on where the request is coming
# from):

# sec.name source community
&rarr;&nbsp; com2sec local localhost private
&rarr;&nbsp; #com2sec mynetwork XXX.XXX.XXX.0/24 public

####
# Second, map the security names into group names:

# sec.model sec.name
group MyRWGroup v1 local
group MyRWGroup v2c local
group MyRWGroup usm local
group MyROGroup v1 local
group MyROGroup v2c local
group MyROGroup usm local

####
# Third, create a view for us to let the groups have rights to:

# incl/excl subtree mask
view all included .1 80

####
# Finally, grant the 2 groups access to the 1 view with different
# write permissions:

# context sec.model sec.level match read write notif
access MyROGroup &quot;&quot; any noauth exact all none none
access MyRWGroup &quot;&quot; any noauth exact all all none

###################################
# System contact information
#

# It is also possible to set the sysContact and sysLocation system
# variables through the snmpd.conf file. **PLEASE NOTE** that setting
# the value of these objects here makes these objects READ-ONLY
# (regardless of any access control settings). Any attempt to set the
# value of an object whose value is given here will fail with an error
# status of notWritable.

syslocation Right here, right now.
&rarr;&nbsp; syscontact admin &amp;lt;admin@server.jp&amp;gt;
</pre>
<p>一番下に書いたsyscontactは各自、管理用のユーザ・アドレスに置き換えてください。</p>
<h3>起動スクリプトの作成</h3>
<p>「/etc/init.d/snmpd」として保存してください。</p>
<pre class="brush: bash; auto-links: false;">

vi /etc/init.d/snmpd

#!/bin/bash
# ucd-snmp init file for snmpd
#
# chkconfig: - 50 50
# description: Simple Network Management Protocol (SNMP) Daemon
#
# processname: /usr/local/sbin/snmpd
# config: /usr/local/share/snmp/snmpd.conf
# pidfile: /var/run/snmpd

# source function library
. /etc/init.d/functions

OPTIONS=&quot;-Lsd -Lf /dev/null -p /var/run/snmpd -a&quot;
RETVAL=0
prog=&quot;snmpd&quot;

start() {
echo -n $&quot;Starting $prog: &quot;
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
daemon /usr/local/sbin/snmpd $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] &amp;amp;&amp;amp; touch /var/lock/subsys/snmpd
fi;
echo
return $RETVAL
}

stop() {
echo -n $&quot;Stopping $prog: &quot;
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
killproc /usr/local/sbin/snmpd
RETVAL=$?
[ $RETVAL -eq 0 ] &amp;amp;&amp;amp; rm -f /var/lock/subsys/snmpd
fi;
echo
return $RETVAL
}

reload(){
echo -n $&quot;Reloading $prog: &quot;
killproc /usr/local/sbin/snmpd -HUP
RETVAL=$?
echo
return $RETVAL
}

restart(){
stop
start
}

condrestart(){
[ -e /var/lock/subsys/snmpd ] &amp;amp;&amp;amp; restart
return 0
}

case &quot;$1&quot; in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
condrestart)
condrestart
;;
status)
status snmpd
RETVAL=$?
;;
*)
echo $&quot;Usage: $0 {start|stop|status|restart|condrestart|reload}&quot;
RETVAL=1
esac

exit $RETVAL
</pre>
<p>(アンパサンド書き換えて三箇所)</p>
<p>権限付与と自動起動の設定</p>
<pre class="brush: bash; auto-links: false;">
# cd /etc/init.d
# chmod 755 snmpd
# chkconfig --add snmpd
# chkconfig --level 2345 snmpd on
</pre>
<p>SNMPの実行</p>
<pre class="brush: bash; auto-links: false;">

/etc/init.d/snmpd start
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ststyle.net/weblog/archives/410/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MRTG インストール</title>
		<link>http://www.ststyle.net/weblog/archives/387</link>
		<comments>http://www.ststyle.net/weblog/archives/387#comments</comments>
		<pubDate>Wed, 21 Oct 2009 06:26:34 +0000</pubDate>
		<dc:creator>ststyle</dc:creator>
				<category><![CDATA[MRTG]]></category>
		<category><![CDATA[Watch]]></category>
		<category><![CDATA[net-snmp]]></category>

		<guid isPermaLink="false">http://www.ststyle.net/weblog/?p=387</guid>
		<description><![CDATA[MRTGについて
CPU、ネットワーク、メモリ、HDD空き容量などの状態をグラフで視覚的に表すもの。
どれくらいの負荷がかかっているかの統計を取ることが出来ます。
ここではCPU、ネットワーク、メモリの3通り。
事前にn [...]]]></description>
			<content:encoded><![CDATA[<p style="padding-left: 30px;">MRTGについて</p>
<p>CPU、ネットワーク、メモリ、HDD空き容量などの状態をグラフで視覚的に表すもの。<br />
どれくらいの負荷がかかっているかの統計を取ることが出来ます。<br />
ここではCPU、ネットワーク、メモリの3通り。</p>
<p><span style="color: #3366ff;">事前にnet-snmpをインストールする事</span></p>
<h3>MRTGのインストール</h3>
<p>ここから本体をDLします。</p>
<p>http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/</p>
<p>このまま、普段の要領でインストールする訳ですが、</p>
<p>ちょこっと環境変数を指定してあげます</p>
<pre class="brush: bash; auto-links: false;">

$ cd /usr/local/src
$ tar xzvf mrtg-2.16.2.tar.gz
$ cd mrtg-2.16.2
$ LDFLAGS=-lVFlib2
./configure
$ make ($ su)
# make install
</pre>
<h3>MRTGの設定</h3>
<p>ネット上にいろいろありましたが環境のあわないものもありますので<br />
ネットワーク、CPU、メモリを表示する設定ファイルのサンプルを書きます。<br />
また、表示に使う画像類を出すために以下のコマンドを。</p>
<pre class="brush: bash; auto-links: false;">

# mkdir /home/XXXX/htdocs/mrtg
# cp -r images/ /home/XXXX/htdocs/mrtg/
</pre>
<p>基本的にそのままコピーして使えます。<br />
主な変更箇所は<br />
・「SetEnv」の192.168.0.2をサーバのIPに<br />
・MaxBytes1[memory]: 45808<br />
MaxBytes2[memory]: 196552<br />
実メモリとSWAPは「free」とコマンドをうつと出てくるので当てはめてください</p>
<p>ページタイトルなどは自由に変更してOKです。</p>
<p>257460<br />
530104</p>
<pre class="brush: bash; auto-links: false;">

vi /usr/local/bin/mrtg.cfg

# MRTG configuration
# Template file made by SCN, http://www.scne.jp/

Imagedir: /home/XXXX/htdocs/mrtg/images
IconDir: images

# 300秒、つまり5分ごとに自動でリロード
Refresh: 300
# 日本語出力
Language: eucjp

# 統計グラフを設置する場所
WorkDir: /home/XXXXX/htdocs/mrtg

# Traffic status
Target[traffic]: 2:private@localhost:
SetEnv[traffic]: MRTG_INT_IP=&quot;10.0.21.111&quot; MRTG_INT_DESCR=&quot;eth0&quot;
MaxBytes[traffic]: 1250000
Title[traffic]: Traffic Analysis
PageTop[traffic]: &amp;lt;H1&amp;gt;Traffic Analysist&amp;lt;/H1&amp;gt;

# CPU Load
Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&amp;amp;.1.3.6.1.4.1.2021.10.1.5.2:private@localhost
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 Load
PageTop[cpu]: &amp;lt;H1&amp;gt;CPU Load Average&amp;lt;/H1&amp;gt;

#Memory free
Target[memory]: .1.3.6.1.4.1.2021.4.6.0&amp;amp;.1.3.6.1.4.1.2021.4.4.0:private@localhost
MaxBytes1[memory]: 958668
MaxBytes2[memory]: 2097144
Unscaled[memory]: dwmy
Options[memory]: gauge, absolute, growright, noinfo
YLegend[memory]: Mem Free(Bytes)
ShortLegend[memory]: Bytes
kilo[memory]: 1024
kMG[memory]: k,M,G,T,P
LegendI[memory]: Real
LegendO[memory]: Swap
Legend1[memory]: 空き物理メモリ[MBytes]
Legend2[memory]: 空きスワップメモリ[MBytes]
Title[memory]: Memory Free
PageTop[memory]: &amp;lt;H1&amp;gt;Memory Free&amp;lt;/H1&amp;gt;

#Disk Used
Target[disk]: .1.3.6.1.4.1.2021.9.1.9.1&amp;amp;.1.3.6.1.4.1.2021.9.1.9.1:private@localhost
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]: ディスク使用率
PageTop[disk]: &amp;lt;H1&amp;gt;Disk Used&amp;lt;/H1&amp;gt;
</pre>
<p>試しに実行してみます</p>
<pre class="brush: bash; auto-links: false;">

# /usr/local/mrtg-2/bin/mrtg /usr/local/bin/mrtg.cfg
</pre>
<p>3回ほどWARNINGで「リネームできない」とか「過去の結果を読み込めない」とか言われますが無視してください。</p>
<p>次に、1個1個に参照がめんどいのでindex化します</p>
<pre class="brush: bash; auto-links: false;">

# cd /usr/local/bin/
# /usr/local/mrtg-2/bin/indexmaker mrtg.cfg &amp;gt;&amp;gt; /home/XXXXX/htdocs/mrtg/index.html
</pre>
<p>これで http://localhost/mrtgですべての情報を一括で見れるようになります。</p>
<p>ページタイトルとかの編集</p>
<pre class="brush: bash; auto-links: false;">

vi /home/sv01/htdocs/mrtg/index.html

&amp;lt;title&amp;gt;**********&amp;lt;/title&amp;gt;
&amp;lt;H1&amp;gt;**********&amp;lt;/H1&amp;gt;
</pre>
<p>あとは、定期的にデータを収集するようにCronに追記して完成！</p>
<pre class="brush: bash; auto-links: false;">

# crontab -e

#-------------------
### Traffic MRTG ###
#-------------------
0-59/5 * * * * /usr/local/mrtg-2/bin/mrtg /usr/local/bin/mrtg.cfg
</pre>
<p>ブラウザへアクセスするとこんな感じでモニターできます。</p>
<p><img class="alignnone size-full wp-image-388" title="mrtg" src="http://www.ststyle.net/weblog/wp-content/uploads/2009/10/mrtg.jpg" alt="mrtg" width="728" height="455" /></p>
<p><img class="alignnone size-full wp-image-389" title="mrtg-02" src="http://www.ststyle.net/weblog/wp-content/uploads/2009/10/mrtg-02.jpg" alt="mrtg-02" width="800" height="500" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ststyle.net/weblog/archives/387/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
