zoukankan      html  css  js  c++  java
  • 嵌入式设备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
  • 相关阅读:
    CCF CSP 题解
    CCF CSP 2019032 二十四点
    CCF CSP 2018121 小明上学
    CCF CSP 2019092 小明种苹果(续)
    CCF CSP 2019091 小明种苹果
    CCF CSP 2019121 报数
    CCF CSP 2019031 小中大
    CCF CSP 2020061 线性分类器
    CCF CSP 2020062 稀疏向量
    利用国家气象局的webservice查询天气预报(转载)
  • 原文地址:https://www.cnblogs.com/FarmPick/p/9155955.html
Copyright © 2011-2022 走看看