<?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/category/watch/net-snmp-watch/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>Nagios-nrpe インストール</title>
		<link>http://www.ststyle.net/weblog/archives/372</link>
		<comments>http://www.ststyle.net/weblog/archives/372#comments</comments>
		<pubDate>Wed, 21 Oct 2009 00:46:56 +0000</pubDate>
		<dc:creator>ststyle</dc:creator>
				<category><![CDATA[Nagios]]></category>
		<category><![CDATA[net-snmp]]></category>
		<category><![CDATA[nrpe]]></category>

		<guid isPermaLink="false">http://www.ststyle.net/weblog/?p=372</guid>
		<description><![CDATA[NRPE（Nagios Remote Plugin Executor）とは、
Nagiosにてリモート監視を行うためのプラグインで、
リモートサーバのリソース監視を行いたい場合などに用います。
（ローカルのみ監視をする場 [...]]]></description>
			<content:encoded><![CDATA[<p>NRPE（Nagios Remote Plugin Executor）とは、</p>
<p>Nagiosにてリモート監視を行うためのプラグインで、</p>
<p>リモートサーバのリソース監視を行いたい場合などに用います。</p>
<p>（ローカルのみ監視をする場合は必要ありません）</p>
<p>仕組み的には</p>
<p>NagiosサーバからリモートサーバへNRPEを経由し監視したいコマンドを送信し、</p>
<p>コマンドを受け取ったリモートサーバ側のNRPEエージェントが監視コマンドを発行し、</p>
<p>その結果をNagiosサーバへNRPEを経由し送信する模様。</p>
<p>（このときの使用するポート番号は5666である。リモートサーバ側は開放する必要がある）</p>
<p>→まずはnetstat -lnにて確認.</p>
<h3>■Nagiosサーバ側■</h3>
<h3 style="padding-left: 30px;">Nrpeの取得&amp;展開</h3>
<pre class="brush: bash; auto-links: false;">

$cd /usr/local/src/

$ wget http://downloads.sourceforge.net/nagios/nrpe-2.12.tar.gz
$ tar zxvf nrpe-2.12.tar.gz
$ cd nrpe-2.12
</pre>
<h3>コンパイル&amp;インストール</h3>
<pre class="brush: bash; auto-links: false;">

$ ./configure

*** Configuration summary for nrpe 2.12 03-10-2008 ***:

General Options:
-------------------------
NRPE port:&nbsp;&nbsp;&nbsp; 5666
NRPE user:&nbsp;&nbsp;&nbsp; nagios
NRPE group:&nbsp;&nbsp; nagios
Nagios user:&nbsp; nagios
Nagios group: nagios

Review the options above for accuracy.&nbsp; If they look okay,
type &#039;make all&#039; to compile the NRPE daemon and client.

$ make check_nrpe
$ make install-plugin

# NagiosにNRPEプラグインを登録(無い場合は)

<pre class="brush: bash; auto-links: false;"></pre>



$ cp ./src/check_nrpe /usr/local/nagios/libexec
</pre>
<p>○nagiosQLにてコマンドとサービスを作成する</p>
<p># Nagios再起動</p>
<pre class="brush: bash; auto-links: false;">

$ service nagios restart
</pre>
<h3>リモートホスト側（あらかじめNagiosサーバ側からのポートを開放しておく）</h3>
<h3>準備</h3>
<pre class="brush: bash; auto-links: false;">

$ /usr/sbin/useradd nagios
$ mkdir /usr/local/nagios /usr/local/nagios/bin /usr/local/nagios/libexec /usr/local/nagios/etc
</pre>
<h3>最新版をダウンロード</h3>
<pre class="brush: bash; auto-links: false;">

$ cd /usr/local/src/
$ wget http://downloads.sourceforge.net/nagios/nrpe-2.12.tar.gz
$ tar zxvf nrpe-2.12.tar.gz
$ cd nrpe-2.12
</pre>
<h3>コンパイル</h3>
<pre class="brush: bash; auto-links: false;">

$ ./configure --prefix=/usr/local/nagios
$ make
</pre>
<h3>プログラム・設定ファイルのコピー</h3>
<pre class="brush: bash; auto-links: false;">

$ cp ./src/nrpe /usr/local/nagios/bin
$ cp ./sample-config/nrpe.cfg /usr/local/nagios/etc
</pre>
<h3>インストールファイルの削除</h3>
<pre class="brush: bash; auto-links: false;">

$ cd ../
$ rm -rf nrpe-2.12.tar.gz nrpe-2.12
</pre>
<h3>NagiosPluginのインストール</h3>
<p>最新版をダウンロード</p>
<pre class="brush: bash; auto-links: false;">

$ wget http://downloads.sourceforge.net/nagiosplug/nagios-plugins-1.4.13.tar.gz?modtime=1222335829&amp;amp;big_mirror=0
$ tar zxvf nagios-plugins-1.4.13.tar.gz
$ cd nagios-plugins-1.4.13
</pre>
<p>コンパイル</p>
<pre class="brush: bash; auto-links: false;">

$ ./configure --prefix=/usr/local/nagios
$ make
$ make install
</pre>
<pre class="brush: bash; auto-links: false;">

# スタンドアロンのプラグインをコピー
$ cp contrib/* /usr/local/nagios/libexec/

$ chmod 705 /usr/local/nagios/libexec/*
</pre>
<p>インストールファイルの削除</p>
<pre class="brush: bash; auto-links: false;">

$ cd ../
$ rm -rf nagios-plugins-1.4.13 nagios-plugins-1.4.13.tar.gz
</pre>
<p>メモリ監視プラグインの改変</p>
<pre class="brush: bash; auto-links: false;">

$ vi /usr/local/nagios/libexec/check_mem.pl
// この一行をコメントアウトして、
$command_line = `vmstat | tail -1 | awk &#039;{print \$4,\$5}&#039;`;
// この一行を追加
$command_line = `free |head -3|tail -1|awk &#039;{print \$3,\$4}&#039;`;
</pre>
<p>NRPEの設定</p>
<p># コマンドの登録</p>
<pre class="brush: bash; auto-links: false;">

$ vi /usr/local/nagios/etc/nrpe.cfg
// 任意のサービスを登録（しきい値やHDDのパーティションは環境に合わせて変える）
command[check_load]=/usr/local/nagios/libexec/check_load -w 9.0,7.0,6.0 -c 10.0,8.0,7.0
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
command[check_mem]=/usr/local/nagios/libexec/check_mem.pl -f -w 20 -c 10
$ chmod 644 /usr/local/nagios/etc/nrpe.cfg
</pre>
<p>起動設定（xinetに登録）</p>
<pre class="brush: bash; auto-links: false;">

$ vi /etc/services
// 以下を追記
nrpe&nbsp; 5666/tcp&nbsp; # NRPE
</pre>
<p>xinetdへ登録する</p>
<pre class="brush: bash; auto-links: false;">

$ vi /etc/xinetd.d/nrpe
// 以下を記述

service nrpe
{
flags&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = REUSE
socket_type&nbsp;&nbsp;&nbsp;&nbsp; = stream
port&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 5666
wait&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = no
user&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = nagios
group&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = nagios
server&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = /usr/local/nagios/bin/nrpe
server_args&nbsp;&nbsp;&nbsp;&nbsp; = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure&nbsp; += USERID
disable&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = no
only_from&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = 127.0.0.1
only_from&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = (NAGIOSサーバのIPアドレス)
}
</pre>
<p># xinetの再起動（NRPEの起動）</p>
<pre class="brush: bash; auto-links: false;">

$ /etc/rc.d/init.d/xinetd restart
</pre>
<p>それでは早速、Nagiosの画面で確認です</p>
<p>無事うまくいきました。</p>
<p>画像が小さいですが</p>
<p>サービス名&#8221;NRPE&#8221;の箇所で</p>
<p>リモートサーバをNRPE経由で監視できています。</p>
<p>またサーバ設定事態はnagiosQLにて行っており、</p>
<p>以前作成した定義ファイルのインポート機能もあるので楽チンです。</p>
<p><img class="alignnone size-full wp-image-381" title="nrpe" src="http://www.ststyle.net/weblog/wp-content/uploads/2009/10/nrpe.jpg" alt="nrpe" width="640" height="400" /></p>
<h3>補足:</h3>
<p>ここでの環境では</p>
<p>NRPE経由にて実行できるコマンド群は以下となります。</p>
<p>（もちろん追加可能）</p>
<pre class="brush: bash; auto-links: false;">

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
</pre>
<h3>以下のメッセージが表示された場合</h3>
<p><span style="color: #ff00ff;">CHECK_NRPE: Error &#8211; Could not complete SSL handshake.</span></p>
<p>リモートサーバ側のnrpe.cfgのオーナー・権限を確認</p>
<p>ちょっとコレではまってしまいました&#8230;</p>
<pre class="brush: bash; auto-links: false;">

chown nagios:nagios /usr/local/nagios/etc/nrpe.cfg
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.ststyle.net/weblog/archives/372/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
