Ubuntu编译文件安装SNMP服务

2023-12-13 06:20:53

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就可以了。

文章来源:https://blog.csdn.net/qq_44534541/article/details/134888804
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。