2019独角兽企业重金招聘Python工程师标准>>> hot3.png

对net-snmp5.2.4静态交叉编译(arm-linux-gcc)后得到的各文件大小如下:

Snmpd  735k

Snmpset, snmpget, snmptrap, snmpusm 分别约为360k。

总计约2.2M。

5.2.4版本默认为静态编译,使用libtools的makefile工具编译。后要修改成动态编译,对libtools不熟,没有成功。

后来发现5.4.1版本同时存在静态与动态编译。5.4.1的交叉编译有一个bug,就是已经在配置中去掉了perl模块(使用./configure --without-perl-modules),但实际编译时还会去编译perl,我的arm-linux-交叉编译器没有perl库,所以编不过去。解决办法:去掉5.4.1版本的两个makefile中的libperl库,在apps/Makefile,agent/Makefile,vi中冒号模式下查找“/lperl”,删掉-lperl, 编译通过。

使用—enable-mini-agent选项,得到各个文件大小如下:

Libs:

Libnetsnmpagent.so    131k

Libnetsnmphelpers.so  118k

Libnetsnmp.so          53k

Libnetsnmpmibs.so     71k

Bin/Sbin:

Snmpd                 21k

Snmpusm              24.5k

Snmpvacm             20.7k

Snmpset               7.7k

Snmpget               6.3k

snmptrap              9k

总计大小为453K

在pc上试运行Miniagent之后(使用gcc编译),通过mibbrowser观察发现支持的mib很少,只有部分rfc1213-mib。

默认编译各个模块,得到各个文件大小如下:

Libs:

Libnetsnmpagent.so    127k

Libnetsnmphelpers.so   81k

Libnetsnmp.so         366k

Libnetsnmpmibs.so     509k

Bin/Sbin:

Snmpd                 18k

Snmpusm              24.5k

Snmpvacm             20.7k

Snmpset               7.7k

Snmpget               6.3k

snmptrap              9k

总计大小为1186K。默认的模块和mibs包括mibII,ucd_snmp, snmpv3mibs, notification, target, agent_mibs, agentx, utilities.

以上大小都为strip之后的值。如果去掉部分mibs,大小估计能缩小到1M以内。

2007.7.31

-----------------------------------------------------------------

使用选项 --with-out-mib-modules="agentx", 编译之后,libnetsnmpagent.so变为94k,其它不变,缩小33k。

使用选项 --with-out-mib-modules="agentx host",编译之后,libnetsnmpmibs.so变为470k,其它不变,缩小72k。

使用选项 --with-out-mib-modules="agentx host disman/event disman/schedule",编译之后,libnetsnmpmibs.so变为408k,其它不变,缩小134。

使用选项 --with-out-mib-modules="agentx host disman/event disman/schedule ucd_snmp",编译之后,libnetsnmpmibs.so变为338k,其它不变,缩小204k。 目前netsnmp总体大小为964k。

添加选项--disable-mib-loading,则libnetsnmphelpers.so为78k,libnetsnmp.so为288k。缩小285k。目前总体大小为883k。但是对于这个选项是否可用,具体情况还不知道。该选项好像是去除对mibfiles的解析的代码。

net-snmp的配置脚本及其他

在配置之前先设置一下环境变量:

source /home/peter/WP701/environment.linux.sh

主要是设置交叉编译器的路径和工程中某些模块的路径。

net-snmp的配置脚本:

-----------------------------------------------------

#!/bin/bash
target=net-snmp5.4_v3_arm_almost
prefix_path=`pwd`/tmp/${target}
exec_prefix_path=${prefix_path}/exec

./configure --host=arm-linux /
            --with-endianness=little  /
            --without-perl-modules /
            --disable-perl-cc-checks /
            --disable-ipv6        /
            --without-rpm        /
            --prefix=${prefix_path}   /
            --exec-prefix=${exec_prefix_path}   /
            --disable-manuals      /
            --disable-scripts      /
            --disable-debugging   /
            #--enable-mini-agent    /
            #--disable-applications  /
            #--disable-mib-loading 
            #!--with-mib-modules="mibII snmpv3mibs ucd_snmp agent_mibs notification target agentx utilities"

#! if don't want to build some modules add:

#--with-out-mib-modules="agentx utilities ***"  /

#!default setup modules: mibII snmpv3mibs ucd_snmp agent_mibs notification target agentx utilities

-----------------------------------------------------------------------

有非常多的配置选项,上面只用到了一点点,具体得看configure.in这个配置文件,不过内容相当多,有3千多行。运行该脚本之后,就生成了各个Makefile,然后make,makeinstall, 就安装好了net-snmp,安装在${prefix_path}指定的目录下,包括lib,bin,sbin,share,include目录。mibs的txt文件在share/snmp/mibs/下面,在运行时好像是没有用的,是为了开发才放在那里的,好像是...^^,有待证实。

FAQ中有这么一个问题:Do I actually need the MIB files?
--------------------------------

Probably not.
  The MIB files play two main roles - they are used to translate
  between numeric OIDs and the corresponding textual names, and
  they define the structure and syntax of the relevant MIB objects.

This second role is perhaps best thought of in terms of a design
  document.  It's vital while developing an application (typically
  the MIB module or handler within the agent), since it defines
  what the application (MIB) must actually do.  But once the code
  has been written, the design document becomes redundent.
  The agent then has the same information hardcoded into it
  (literally!), and no longer needs the MIB file.

The translation task is not strictly necessary - SNMP will
  operate fine without any MIB files at all, as long as you're
  happy to work with numeric OIDs throughout, and know which MIB
  objects you're interested in.  But it's much easier to work with
  the (hopefully) meaningful names, enumeration tags and the like,
  and to view the description of a particular object.
  This requires having the relevant MIB files installed and loaded.

---------------------------------------------------------------

对于减小占用资源,FAQ中的下面两个问题可能会有帮助:

How can I reduce the memory footprint?
--------------------------------------

In order to reduce the memory footprint (for instance, to
  embed the snmpd into a device), the following configure options
  could be used.

'--disable-debugging'
     This turns off the compilation of all debugging statements.

'--enable-mini-agent' '--with-out-mib-modules=examples/ucdDemoPublic'
     This creates an agent with just the essential MIB modules included.
     NOTE: If you need additional MIB modules, then simply add them
     using the option '--with-mib-modules=...' but this will of course
     increase the memory footprint.

'--with-transports=UDP'
     This option specifies the transport domains to include.
     For a simple standalone agent, just UDP should be sufficient.
     (Although the 'disman' and 'agentx' modules may require the
      Callback, TCP and/or Unix transport domains as well).

'--without-kmem-usage'
     This can be used in order to omit the code that operates on the
     /dev/kmem interface. Clearly, this option cannot be used when
     one of the configured MIB modules depends on it.

'--with-mibdirs=' and '--with-mibs='
     These options tell the agent not to load any MIB modules. 
     This doesn't affect the size of libraries or application
     binaries, but will reduce the memory footprint during runtime.

'--disable-mib-loading'
     This can be used in order to omit the code that loads and
     parses the MIB files altogether.  This will reduce both the
     runtime memory footprint, and the binary sizes.

Once the agent (snmpd) has been linked, you might also try running
  'strip snmpd' to remove un-necessary debug/symbol information.

How can I reduce the installation footprint or speed up compilation?
-------------------------------------------------------------------

If you are using net-snmp v5.1 or above, then the following
  configure options may be useful to you:
                                                                                
  --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.

转载于:https://my.oschina.net/u/249511/blog/51012

net-snmp的定制编译相关推荐

  1. Linux下编译snmp失败,解决编译snmp++出错

    从www.agentpp.com/snmp_pp3_x/download_snmp_ppv3/download_snmp_ppv3.html下载的SNMP++v3.2.25 将src里的Makefil ...

  2. driftnet定制编译,去掉显示功能,解决bug

    安装依赖: sudo apt install git autoconf libpcap-dev 下载源码 修改configure.ac: 每个AC_ARG_ENABLE部分 enable_http_d ...

  3. linux as 4 内核版本,Linux Redhat AS 4中编译内核与以往版本的区别(转载)

    曾经被问及为何在Redhat AS4中找不到内核源代码目录,开始时回答对方在安装时漏选了源码包,对方回答我已经重装过四遍,一个包一个包找过来眼都对起来了也没找到.真见鬼,我在电话里说要不你先到/usr ...

  4. linux 内核 编译详解

    一.内核简介  内核,是一个操作系统的核心.它负责管理系统的进程.内存.设备驱动程序.文件和网络系统,决定着系统的性能和稳定性.  Linux的一个重要的特点就是其源代码的公开性,所有的内核源程序都可 ...

  5. 深入剖析 iOS 编译 Clang LLVM(编译流程)

    2019独角兽企业重金招聘Python工程师标准>>> 前言 iOS 开发中 Objective-C 和 Swift 都用的是 Clang / LLVM 来编译的.LLVM是一个模块 ...

  6. python numba.jit(该装饰器用于将Python函数编译为本机代码、python运算加速器)

    from decorators.py def jit(signature_or_function=None, locals={}, target='cpu', cache=False,pipeline ...

  7. Linux | 编译原理、gcc的命令参数、自动化构建工具 make/Makefile

    文章目录 编译原理 预处理 编译 汇编 链接 gcc的常用命令参数 make 和 Makefile 的概念 make的运行 通配符 自动化变量 伪目标.PHONE:[命令] 编译原理 在解释 make ...

  8. devc++源文件未编译_iOS 编译知识小结

    简介 源码到可执行文件流程 编译器 编译流程 预处理(preprocessor) 词法分析(lexical anaysis) 语法分析(semantic analysis) CodeGen 生成汇编代 ...

  9. linux 编译3g驱动_linux重新编译内核

    1.内容简介 linux内核简介 linux内核版本号 linux为什么重新编译内核 linux内核编译模式 linux内核功能划分 linux内核编译步骤 2linux内核简介 内核,是一个操作系统 ...

  10. linux内核2.6.35编译过程

    一.实验目的 学习重新编译Linux内核,理解.掌握Linux内核和发行版本的区别. 二.实验内容 在Linux操作系统环境下重新编译内核.实验主要内容: A. 查找并且下载一份内核源代码,本实验使用 ...

最新文章

  1. java.io.File中mkdir()和mkdirs()的区别
  2. 俄罗斯黑客收到500万美元赎金!美国燃油管道商认怂,民众为抢汽油大打出手...
  3. 【python基础】list操作相关:扩充、条件查找【IndexError: list assignment index out of range】...
  4. html自动执行的事件,js自执行事件
  5. alias中后面的命令不执行的问题(没有解决 )
  6. pandas内置绘图_使用Pandas内置功能探索数据集
  7. 服务中没有telnet_win7 服务中没有 prints pooler
  8. 海南省月降水量分布数据
  9. 一招教你如何使用.Net Core 3.0正式版创建Winform程序
  10. 深入浅出 NXLog (二)
  11. 2022-06-14 QThread CPU压力测试
  12. 阿里云loT物联网学习
  13. 大胖子走迷宫【第十届】【决赛】
  14. 163-H桥电机驱动电路
  15. 用Java写的连连看小游戏——步骤分析
  16. 安装Java并配置环境,安装eclipse,在GitHub中上传代码
  17. Mac系统如何取消自动播放视频和实况照片?
  18. 4种预测市场表现的方法
  19. 列出叶节点 (二叉树的建立和BFS)
  20. Metric评价指标-Embedding Similarity

热门文章

  1. “SecureCRT遇到一个致命的错误且必须关闭”处理办法
  2. Java web切面编程
  3. Android 第3方控件一览表
  4. 利用 Google API 调用谷歌地图 演示1
  5. 2019程序媛面试之高频题型汇总(二)
  6. 流式布局和viewport
  7. 网络应用瑞士军刀——Zentyal(4 常用命令)
  8. 独角兽复活:Twilio上市预示IPO市场起死回生
  9. SELECT INTO 和 replace into SELECT
  10. Android Makefile and build system 分析