Linux net-snmp-5.7.2安装配置

Linux net-snmp-5.7.2安装配置

安装包

软件名称:net-snmp-5.7.2.tar.gz

下载地址http://sourceforge.net/projects/net-snmp/files/net-snmp/5.7.2/net-snmp-5.7.2.tar.gz/download

安装

拷贝net-snmp-5.7.2.tar.gz到目录 /downloads下

解压缩

# tar -xzvf  net-snmp-5.7.2.tar.gz

# cd net-snmp-5.7.2

执行配置命令

# ./configure --prefix=/usr/local/net-snmp

                        --with-default-snmp-version="3"

                        --with-sys-contact="brusezhu9@gmail.com"

                        --with-sys-location="China"

                        --with-logfile="/var/log/snmpd.log"

                        --with-persistent-directory="/var/net-snmp"

                        --enable-mfd-rewrites

解释:

prefix:net-snmp将要安装的路径
enable-mfd-rewrites:允许用新的MFD重写可用的mid模块
with-default-snmp-version:默认的SNMP版本
with-sys-contact:可以配置该设备的联系人
with-sys-location:该设备的位置
with-logfile:日志文件路径
with-persistent-directory:不变数据存储目录

编译

# make

安装

# make install


配置snmpd.conf

首先:进入/usr/local/net-snmp/share/snmp

# cd /usr/local/net-snmp/share/snmp

接着:使用配置向导创建snmpd.conf

# ../../bin/snmpconf -g basic_setup

The following installed configuration files were found:

   1:  /usr/local/net-snmp/share/snmp/snmpd.conf

Would you like me to read them in?  Their content will be merged with the
output files created by this session.

Valid answer examples: "all", "none","3","1,2,5"

Read in which (default = all): none
************************************************ 
*** Beginning basic system information setup ***
************************************************ 
Do you want to configure the information returned in the system MIB group (contact info, etc)? (default = y): y

Configuring: syslocation
Description:
  The [typically physical] location of the system.
    Note that setting this value here means that when trying to
    perform an snmp SET operation to the sysLocation.0 variable will make
    the agent return the "notWritable" error code.  IE, including
    this token in the snmpd.conf file will disable write access to
    the variable.
    arguments:  location_string

The location of the system: tianjin

Finished Output: syslocation  tianjin

Configuring: syscontact
Description:
  The contact information for the administrator
    Note that setting this value here means that when trying to
    perform an snmp SET operation to the sysContact.0 variable will make
    the agent return the "notWritable" error code.  IE, including
    this token in the snmpd.conf file will disable write access to
    the variable.
    arguments:  contact_string

The contact information: brusezhu9@gmail.com

Finished Output: syscontact  brusezhu9@gmail.com
Do you want to properly set the value of the sysServices.0 OID (if you don't know, just say no)? (default = y): no
************************************** 
*** BEGINNING ACCESS CONTROL SETUP ***
************************************** 
Do you want to configure the agent's access control? (default = y): 
Do you want to allow SNMPv3 read-write user based access (default = y): n
Do you want to allow SNMPv3 read-only user based access (default = y): n
Do you want to allow SNMPv1/v2c read-write community access (default = y): n
Do you want to allow SNMPv1/v2c read-only community access (default = y): y

Configuring: rocommunity
Description:
  a SNMPv1/SNMPv2c read-only access community name
    arguments:  community [default|hostname|network/bits] [oid]

The community name to add read-only access for: public
The hostname or network address to accept this community name from [RETURN for all]: 
The OID that this community should be restricted to [RETURN for no-restriction]: 

Finished Output: rocommunity  public  
Do another rocommunity line? (default = y): n
**************************************** 
*** Beginning trap destination setup ***
**************************************** 
Do you want to configure where and if the agent will send traps? (default = y): n
**************************************** 
*** Beginning monitoring setup ***
**************************************** 
Do you want to configure the agent's ability to monitor various aspects of your system? (default = y): n


The following files were created:
snmpd.conf /usr/local/net-snmp/share/snmp/
  snmpd.conf  

These files should be moved to /usr/local/net-snmp/share/snmp if you
want them used by everyone on the system.  In the future, if you add 
the -i option to the command line I'll copy them there automatically for you.

Or, if you want them for your personal use only, copy them to
/root/.snmp .  In the future, if you add the -p option to the
command line I'll copy them there automatically for you.
继续:拷贝新创建的snmpd.conf到提示的目录“/usr/local/net-snmp/share/snmp/”

# snmpd.conf    /usr/local/net-snmp/share/snmp/

启动服务

# cd /usr/local/net-snmp/sbin

# ./snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf &

检查服务

# ps -ef | grep snmpd

root      9244     1  0 15:38 ?        00:00:00 ./snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf
root      9247 27939  0 15:39 pts/1    00:00:00 grep snmpd

说明服务已经正常启动

检测161端口

# lsof -i:161

COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
snmpd   9244 root    6u  IPv4 445768      0t0  UDP *:snmp

注意:*表示允许所有主机的访问161端口


设置net-snmp自启动

在/etc/rc.local文件的末尾加上如下所示代码

/usr/local/net-snmp/sbin/snmpd -c /usr/local/net-snmp/share/snmp/snmpd.conf &

设置环境变量

在/etc/profile文件中export前面添加如下代码

PATH=/usr/local/net-snmp/sbin:/usr/local/net-snmp/bin:$PATH

LD_LIBRARY_PATH=/usr/local/net-snmp/lib:$LD_LIBRARY_PATH


测试

localhost测试

# snmpwalk -v 2c -c public localhost if

出现如下信息

IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: eth0
IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
IF-MIB::ifType.2 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifMtu.1 = INTEGER: 16436
IF-MIB::ifMtu.2 = INTEGER: 1500
IF-MIB::ifSpeed.1 = Gauge32: 10000000
IF-MIB::ifSpeed.2 = Gauge32: 100000000
IF-MIB::ifPhysAddress.1 = STRING:
IF-MIB::ifPhysAddress.2 = STRING: d4:3d:7e:24:17:5a
IF-MIB::ifAdminStatus.1 = INTEGER: up(1)
IF-MIB::ifAdminStatus.2 = INTEGER: up(1)
IF-MIB::ifOperStatus.1 = INTEGER: up(1)
IF-MIB::ifOperStatus.2 = INTEGER: up(1)
IF-MIB::ifLastChange.1 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.2 = Timeticks: (0) 0:00:00.00
IF-MIB::ifInOctets.1 = Counter32: 872801
IF-MIB::ifInOctets.2 = Counter32: 27205892
IF-MIB::ifInUcastPkts.1 = Counter32: 15809
IF-MIB::ifInUcastPkts.2 = Counter32: 145137
IF-MIB::ifInNUcastPkts.1 = Counter32: 0
IF-MIB::ifInNUcastPkts.2 = Counter32: 0
IF-MIB::ifInDiscards.1 = Counter32: 0
IF-MIB::ifInDiscards.2 = Counter32: 0
IF-MIB::ifInErrors.1 = Counter32: 0
IF-MIB::ifInErrors.2 = Counter32: 0
IF-MIB::ifInUnknownProtos.1 = Counter32: 0
IF-MIB::ifInUnknownProtos.2 = Counter32: 0
IF-MIB::ifOutOctets.1 = Counter32: 872801
IF-MIB::ifOutOctets.2 = Counter32: 86801071
IF-MIB::ifOutUcastPkts.1 = Counter32: 15809
IF-MIB::ifOutUcastPkts.2 = Counter32: 121285
IF-MIB::ifOutNUcastPkts.1 = Counter32: 0
IF-MIB::ifOutNUcastPkts.2 = Counter32: 0
IF-MIB::ifOutDiscards.1 = Counter32: 0
IF-MIB::ifOutDiscards.2 = Counter32: 0
IF-MIB::ifOutErrors.1 = Counter32: 0
IF-MIB::ifOutErrors.2 = Counter32: 0
IF-MIB::ifOutQLen.1 = Gauge32: 0
IF-MIB::ifOutQLen.2 = Gauge32: 0
IF-MIB::ifSpecific.1 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.2 = OID: SNMPv2-SMI::zeroDotZero

远程测试

使用工具mibbrowser查看,这里就不说明了,大家可以google一下


  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
要在CentOS 7.9上安装net-snmp,您可以按照以下步骤进行操作: 1. 首先,检查您的系统是否已安装net-snmp-libs包。在终端中运行以下命令: ``` rpm -qa | grep net-snmp-libs ``` 如果输出结果为空,则表示未安装该包。 2. 如果已安装了旧版本的net-snmp-libs包,并且您希望安装新版本的net-snmp-libs包,您需要先卸载旧版本。运行以下命令: ``` rpm -e --allmatches --nodeps net-snmp-libs-1:5.7.2-49.el7.x86_64 ``` 3. 下载新版本的net-snmp-libs包(net-snmp-libs-5.7.2-49.el7_9.2.x86_64.rpm)。您可以从网络上找到可用的下载链接。 4. 运行以下命令来安装新版本的net-snmp-libs包: ``` rpm -ivh net-snmp-libs-5.7.2-49.el7_9.2.x86_64.rpm ``` 5. 安装完成后,您可以通过运行以下命令验证net-snmp是否正确安装: ``` snmpwalk -v 2c -c public localhost ``` 如果没有报错并且输出了一些信息,则表示安装成功。 请注意,还有其他与net-snmp相关的软件包,如net-snmp-agent-libs、net-snmpnet-snmp-utils,您可以根据需要进行安装。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [CentOS7.9 安装开启snmp监控](https://blog.csdn.net/kungfuIT/article/details/131105018)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值