net-snmp 增加MIB库。mib2c 的agent 安装配置及常见问题

339 views
Skip to first unread message

stan8688

unread,
Mar 30, 2009, 11:45:30 PM3/30/09
to 嵌入式linux
net-snmp 经常出现 Cannot find module (UCD-SNMP-MIB): At line 0 in 错误。
下面是正常要注意的事项(192.168.48.128 agent ip)

1.建立自己的mib库的目录。(系统的默认mib库的目录在/usr/local/share/snmp/mibs下,一定不要将自己的mib文件放
在系统目录中。否则会出现使用不了的状况。)

2.编写自己的mib文件,并放到自己的mib库目录中。(本例中用 NET-SNMP-TUTORIAL-MIB.txt mib文件)

3.配置环境变量 MIBDIRS (查找mib文件的路径) 和 MIBS(扩展MIB模块名称。扩展mib需要重新编译并增加 --with-
mib-modules="module1 module2"),编辑系统配置文件/root/.basrc 增加

export PATH=$PATH:/usr/local/toolchains/arm-uclinux/bin
export MIBDIRS=$MIBDIRS:/usr/local/share/snmp/mibs:/root/stan_mibs
#export MIBS=+NET-SNMP-TURORIAL-MIB
export MIBS=ALL
(使用ALL. 可以方便mib2c的操作)

4. 在net-snmp-5.4.2.1/agent/mibgroup目录下(产生的源代码要放在 agent/mibgroup目录下)

mib2c -c mib2c.int_watch.conf NET-SNMP-TUTORIAL-
MIB::nstAgentModuleObject
生产nstAgentModuleObject.c nstAgentModuleObject.h

5. ./configure --with-mib-modules="nstAgentModuleObject"
make
make install

6. vi /usr/local/etc/snmp/snmpd.conf
com2sec local localhost public
com2sec mynetwork 192.168.48.0/24 public

group MyRWGroup v1 local
group MyRWGroup v2c local

group MyRWGroup v1 mynetwork
group MyRWGroup v2c mynetwork

# 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

7. 运行agent
snmpd -f -Le -d

8.client 测试

snmpwalk -v 2c -c public 192.168.48.128 system

snmpget -v 2c -c public 192.168.48.128 nstAgentModuleObject.0

snmpset -v 2c -c public 192.168.48.128 nstAgentModuleObject.0 = 26

snmpget -v 2c -c public 192.168.48.128 nstAgentModuleObject.0


下面是在论坛中找到注意事项和方法
# MIBDIRS=/home/mydir/mibs:/etc/sma/snmp/mibs
# export MIBDIRS
# MIBS=ALL;export MIBS
Setting MIBS to ALL ensures that mib2c finds all MIBs in the search
location for MIB files. Both the MIB files to be loaded and the MIB
file search location can also be configured in the snmp.conf file. See
the snmp.conf(4)man page for more information.

Note –
You should avoid copying your MIBs into the /etc/sma/snmp/mibs
directory. That directory should be reserved for the MIBs provided
with SMA.
Reply all
Reply to author
Forward
0 new messages