专注系统运维、网络架构,研究技术解决方案,记录我的思想轨迹、工作学习、生活和关注的领域
分类: 系统运维
2011-08-08 12:03:50
# tar -zxvf net-snmp-5.3.0.1.tar.gz
# cd net-snmp-5.3.0.1
# ./configure –prefix=/usr/local/snmpd –enable-mfd-rewrites
注意:snmp协议选择v2c
# make && make install
启动snmpd服务:
mkdir /usr/local/snmpd/etc/
touch /usr/local/snmpd/etc/snmpd.conf
vi /usr/local/snmpd/etc/snmpd.conf
com2sec notConfigUser default auto
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
view all included .1 80
access notConfigGroup "" any noauth exact all none none
/usr/local/snmpd/sbin/snmpd -c /usr/local/snmpd/etc/snmpd.conf
测试是否安装成功:
netstat -na |grep 161
udp 0 0 0.0.0.0:161 0.0.0.0:*
执行: snmpwalk -v2c -c auto 127.0.0.1 system
SNMPv2-MIB::sysDescr.0 = STRING: Linux bitauto 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.10
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (102673) 0:17:06.73
SNMPv2-MIB::sysContact.0 = STRING: Root
SNMPv2-MIB::sysName.0 = STRING: bitauto
.......................................................
制作snmpd 开机启动脚本
cd /etc/rc.d/init.d
touch snmpd
vi snmpd
########## 这里我偷懒,拷贝直接在之前的snmp rpm包安装完后系统制作的启动脚本,然后修改完成,并非我写的。
#!/bin/bash
# ucd-snmp init file for snmpd
#
# chkconfig: - 50 50
# description: Simple Network Management Protocol (SNMP) Daemon
#
#processname: /usr/local/snmpd/sbin/snmpd
#config: /usr/local/snmpd/etc/snmpd.conf
#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.pid -a -c /usr/local/snmpd/etc/snmpd.conf"
if [ -e /etc/sysconfig/snmpd.options ]; then
. /etc/sysconfig/snmpd.options
fi
RETVAL=0
prog="snmpd"
start() {
echo -n $"Starting $prog: "
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
daemon /usr/local/snmpd/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/snmpd/sbin/snmpd
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/snmpd
fi;
echo
return $RETVAL
}
reload(){
echo -n $"Reloading $prog: "
killproc /usr/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
###############################################
chmod +x snmpd
chkconfig --level 3 snmpd on
然后就可以使用如下命令重启snmpd 服务了。
service snmpd restart
同时,服务器在重启后,snmpd 会自动重启