嵌入式设备snmpd 移植和测试(78K为例)

一、源码目录项内容
agent:编译snmpd程序所需的文件,mibs源文件;
apps:其他相关的程序:snmpwalk,snmptrap,snmptest,snmpget,snmpset;
mibs:mibs 接口配置文件
 
二、snmpd 编译方式
1、静态库方式
1)最小化编译:(-enable-mini-agent),编译出来的体积较小,但是很多接口都没有;
2)最大化编译:( -enable-mini-agent),几乎能用到的接口都会包含,体积较大;
2、动态库方式
    只需要把新引入的MIB模块的.c和.h文件编译成.so库,通过设置snmpd.conf由snmpd代理程序动态加载。需要snmpd代理程序支持dlmod或load命令,其次需要系统支持(unix);
3、子代理 编译方式
    新增mibs 作为独立的子代理,让snmpd在主代理的模式运行。对于snmpd不需要任何的更改和配置。把子代理编译生成的程序运行起来就可以扩展自定义MIB库。
 
三、snmpd 编译安装
1、编译、压缩程序
1)配置脚本
./configure --host=arm-marvell-linux-gnueabi --with-cc=arm-marvell-linux-gnueabi-gcc --with-ar=arm-marvell-linux-gnueabi-ar 
--disable-shared --disable-scripts --with-endianness=little -enable-mini-agent --disable-ipv6 --disable-manuals
--disable-ucd-snmp-compatibility --enable-as-needed --disable-embedded-perl

 

2)编译选项
--disable-agent Do not build the agent (snmpd).
--disable-applications Do not build the apps (snmpget, ...).
--disable-manuals Do not install the manuals.
--disable-scripts Do not install the scripts (mib2c, ...).
--disable-mibs Do not install the mib files.
--disable-mib-loading Do not include code that parses and
manipulates the mib files.
--enable-mini-agent 最小化构建agent,很多接口都没有(内存、网络等等和子代理模式),如果不选择这项,编译出来的snmpd体积较大,
但是几乎所有的mibs接口已经包含。
注意:注意:使用子代理模式,snmpd程序不能编译 mini-agent选项
 
3)选择版本,1 2 3 对应1 2c 3;
其他选择项,我们直接回车(后面这些选择项对应获取的信息,可以通过snmpd.conf修改);
4)make
编译完成后进入 agent目录,查看是否生成了snampd文件;
5)压缩可执行程序
arm-marvell-linux-gnueabi-strip snmpd
3、错误类型
错误A:/usr/lib/gcc-cross/arm-linux-gnueabi/4.9/../../../../arm-linux-gnueabi/bin/ld: cannot find -lperl
    collect2: error: ld returned 1 exit status
解决办法:configure配置的时候加上一个参数--disable-embedded-perl
 
 
四、配置文件设置和启动命令
1、配置文件(/etc 目录下)
# sec.name source community
com2sec notConfigUser default public
# groupName securityModel securityName
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
# name incl/excl subtree mask(optional)
view all included .1
# group context sec.model sec.level prefix read write notif
access notConfigGroup "" any noauth exact all none none
 
#snmpd 运行在子代理模式
master agentx
1)首先定义一个首共同体名称(community),这里是 public。以及可以访问这个 public 的用户名(sec name),这里是 notConfigUser 。public 相当于用户 notConfigUser 的密码。
 
2、启动
1)
snmpd -c /etc/snmpd/snmpd.conf -f -Le -d -M /etc/snmpd/mibs
2)启动参数
注:snmpd命令的有用选项
-c FILE 指定文件为配置文件
-C 不读取默认的配置文件
-d dump接收和发送SNMP数据包
-D TOKEN 对于给定的TOKEN(标志)打开调试信息 ( -Dmib_init)
-I [-]INITLIST 对于要初始化的MIB列表显示
-M DIRLIST 指定MIB库的路径
-V 显示详细信息
-Le 把错误信息输出到日志中
-Lf FILE 把错误信息输出到指定文件中
-m MIBLIST use MIBLIST instead of the default MIB list
-f                    do not fork from the shell

转载于:https://www.cnblogs.com/FarmPick/p/9155955.html

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值