安装snmp

test# cd /usr/ports/net-mgmt/net-snmp

test# make install clean

去掉ipv6选项,其他保持默认即可...

test# vi /usr/local/etc/snmpd.conf

内容如下:

com2sec mynetwork  115.182.59.26/32     publicly

com2sec mynetwork  60.195.249.83/32     publicly

com2sec mynetwork  58.83.219.249/32     publicly

group MyRWGroup v1         local

group MyRWGroup v2c        local

group MyRWGroup usm        local

group MyROGroup v1         mynetwork

group MyROGroup v2c        mynetwork

group MyROGroup usm        mynetwork

view all    included  .1                               80

access MyROGroup ""      any       noauth    exact  all    none   none

access MyRWGroup ""      any       noauth    exact  all    all    none

syslocation Right here, right now.

syscontact Me

proc mountd

proc ntalkd 4

proc sendmail 10 1

exec echotest /bin/echo hello world

disk / 10000

load 12 14 14

test# echo 'snmpd_enable="YES"' >> /etc/rc.conf

test# echo 'snmpd_conffile="/usr/local/etc/snmpd.conf"' >> /etc/rc.conf

test# cat /etc/rc.conf 

启动snmp

test# /usr/local/etc/rc.d/snmpd start|stop|restart

test# sockstat -4l | grep snmpd