Ubuntu编译文件安装SNMP服务

   2024-04-02 15:54:51  

net-snmp源码下载

http://www.net-snmp.org/download.html

编译步骤

指定参数编译

./configure --prefix=/root/snmpd --with-default-snmp-version="2" --with-logfile="/var/log/snmpd.log" --with-persistent-directory="/var/net-snmp" --with-sys-contact="contact" --with-sys-location="location"
 
make 

make install
 

编译环境

apt-get install make

apt-get install gcc

apt-get install cmake

apt-get install perl-ExtUtils-Embed

apt-get install libperl-dev 
---------------------------------------------------------

            Net-SNMP configuration summary:

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



  SNMP Versions Supported:    1 2c 3

  Building for:               linux

  Net-SNMP Version:           5.9.4.pre2

  Network transport support:  Callback Unix Alias TCP UDP TCPIPv6 UDPIPv6 IPv4Base SocketBase TCPBase UDPIPv4Base UDPBase IPBase IPv6Base

  SNMPv3 Security Modules:     usm

  Agent MIB code:            default\_modules =>  snmpv3mibs mibII ucd\_snmp notification notification-log-mib target agent\_mibs agentx disman/event disman/schedule utilities host

  MYSQL Trap Logging:         unavailable

  Embedded Perl support:      disabled

  SNMP Perl modules:          building -- not embeddable

  SNMP Python modules:        disabled

  Crypto support from:        internal

  Authentication support:     MD5 SHA1

  Encryption support:         DES AES AES128

  Local DNSSEC validation:    disabled



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

编译完成

gcc -E -I./include -I. -DDONT\_INC\_STRUCTS -DBINDIR=/root/snmpd/bin -x c -I. -Iinclude ./sedscript.in | /bin/grep -E '^s[/#]' | sed 's/REMOVEME//g;s# \*/#/#g;s/ \*#/#/g;s#/ \*#/#g;s/# g/#g/;' > sedscript

echo 's/VERSIONINFO/5.9.4.pre2/g' >> sedscript

echo 's#DATADIR#/root/snmpd/share#g' >> sedscript

echo 's#LIBDIR#/root/snmpd/lib#g' >> sedscript

echo 's#BINDIR#/root/snmpd/bin#g' >> sedscript

echo 's#PERSISTENT\_DIRECTORY#/var/net-snmp#g' >> sedscript

echo 's#SYSCONFDIR#/root/snmpd/etc#g' >> sedscript

/bin/sed -f sedscript ./EXAMPLE.conf.def > EXAMPLE.conf

making all in /root/net-snmp-5.9.4/snmplib

make[1]: Entering directory '/root/net-snmp-5.9.4/snmplib'
 

编译报错

# 编译报错



collect2: error: ld returned 1 exit status

Makefile:1008: recipe for target 'libnetsnmpagent.la' failed

make[1]: \*\*\* [libnetsnmpagent.la] Error 1

make[1]: Leaving directory '/root/net-snmp-5.9.4/agent'

Makefile:671: recipe for target 'subdirs' failed

make: \*\*\* [subdirs] Error 1
 

编译的时候出现找不到perl库的问题,这个问题其实也好解决,编译一个就是嘛。但是呢,没有这个必要,麻烦。解决办法 其实很简单,将之前configure配置的时候加上一个参数--disable-embedded-perl,然后再次make就可以了。



声明:本文系互联网搜索百度而收集整理,不以盈利性为目的,文字、图文资料源于互联网且共享于互联网。
如有侵权,请联系 hzy98999#qq.com (#改@) 删除。