SNMPのインストール
「SNMP」とは「Simple Network Management Protocol」の略でルータやコンピュータなどの
様々な機器を監視、制御するためのプロトコルです。
SourceForgetから
net-snmp-5.1.2.tar.gzをDLします
http://sourceforge.net/project/showfiles.php?group_id=12694
$ tar xvzf net-snmp-5.4.1.2.tar.gz $ cd net-snmp-5.4.1.2 $ ./configure $ make $ su # make install
./configureの途中でSNMPのバージョンを
一番最初に問われるので ” v2 “ と入力し、(Enterでも良いです)
あとは全てEnterですっ飛ばします。
SNMP設定
デーモンの設定を行います
デフォルトの設定をコピーして、編集します。
編集すべき部分を矢印で示しますので、変更してください。
# 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 → com2sec local localhost private → #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 "" any noauth exact all none none access MyRWGroup "" 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. → syscontact admin <admin@server.jp>
一番下に書いたsyscontactは各自、管理用のユーザ・アドレスに置き換えてください。
起動スクリプトの作成
「/etc/init.d/snmpd」として保存してください。
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="-Lsd -Lf /dev/null -p /var/run/snmpd -a"
RETVAL=0
prog="snmpd"
start() {
echo -n $"Starting $prog: "
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
daemon /usr/local/sbin/snmpd $OPTIONS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/snmpd
fi;
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
killproc /usr/local/sbin/snmpd
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/snmpd
fi;
echo
return $RETVAL
}
reload(){
echo -n $"Reloading $prog: "
killproc /usr/local/sbin/snmpd -HUP
RETVAL=$?
echo
return $RETVAL
}
restart(){
stop
start
}
condrestart(){
[ -e /var/lock/subsys/snmpd ] && restart
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
condrestart)
condrestart
;;
status)
status snmpd
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
RETVAL=1
esac
exit $RETVAL
(アンパサンド書き換えて三箇所)
権限付与と自動起動の設定
# cd /etc/init.d # chmod 755 snmpd # chkconfig --add snmpd # chkconfig --level 2345 snmpd on
SNMPの実行
/etc/init.d/snmpd start

