1. 源码地址
https://github.com/net-snmp/net-snmp
https://sourceforge.net/projects/net-snmp/files/net-snmp
2. 环境介绍
使用的NET-SNMP版本为5.9.3
Linux 系统为 centos-release-7-6.1810.2.el7.centos.x86_64
3. 源码编译
3.1 首先配置编译参数
configure 选项参数 | 说明 |
---|---|
–prefix | net snmp 安装路径 |
–with-default-snmp-version | 默认使用版本 |
–with-sys-location | 设备位置 |
–with-logfile | 日志文件路径 |
-with-persistent-directory | 不变数据存储路径 |
–build | 交叉编译环境系统说明(编译平台) |
–host | 交叉编译目标环境(运行平台) |
–with-endianness | 指定大小端模式 |
–enable-mini-agent | 使用最小agent |
–with-cc --with-linkcc --with-ar | 交叉编译器使用的gcc |
–disable-applications | 不编译snmpget snmpset等应用 |
–disable-manuals | 不安装网管软件的说明手册 |
–disable-snmptrapd-subagent | 不支持snmptrapd的agent子代理 |
–disable-ipv6 | 不支持IPv6 |
–with-mib-modules | 添加具体模块(dlmod agentx …) |
–disable-embedded-perl | 不支持嵌入式perl |
–disable–perl-cc-checks | 不需要perl检查 |
–with-sys-contact | 设备的联系人 |
–with–sys-location | 设备地址 |
–disable-scripts | 不需要安装mib2c等工具 |
3.2 编写配置脚本
因为配置项过多,因此这里写一个 localBuild.sh 脚本文件进行configure参数配置。
# --prefix 指定安装目录当当前源文件的 out文件夹(需要我们自己创建)
# --disable-manuals 不安装网管软件的说明手册
# --disable-snmptrapd-subagent 不支持snmptrapd的agent子代理
# --disable-ipv6 不支持IPv6
# --disable-scripts 不需要安装mib2c等工具
# -enable-mini-agent 使用最小agent
# --with-mib-modules="notification agentx" 添加 notification agentx模块
# --disable-embedded-perl 不支持嵌入式perl
# --with-perl-modules 安装perl模块
# --with-default-snmp-version 指定默认使用版本
# --with--sys-location 指定设备位置
# --with-logfile 指定日志文件路径
# --with-persistent-directory 不变数据存储路径
./configure --prefix=/home/lijun/net-snmp-5.9.3/out --disable-manuals --disable-snmptrapd-subagent --disable-ipv6 --disable-scripts --enable-mini-agent --with-mib-modules="notification agentx" --disable-embedded-perl --with-perl-modules --with-default-snmp-version