snmpwalk 命令_Snmpwalk命令行示例

SNMPwalk是SNMP协议的一个实用工具,用于批量获取远程网络设备或服务器的性能指标。本文介绍了如何使用SNMPwalk进行基本操作,如获取所有OID、特定OID以及设置超时和重试计数。此外,还展示了如何指定外部MIB库路径以处理非默认MIB。这些技巧对于网络管理员进行远程监控和故障排查至关重要。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

snmpwalk 命令

snmpwalk 命令

SNMP protocol provides useful features to monitor and configure network and server systems remotely. Monitoring features are much popular than configuration. snmpwalk is a function provided by SNMP protocol to get metrics of remote system in bulk.

SNMP协议提供了有用的功能,可以远程监视和配置网络和服务器系统。 监视功能比配置功能流行得多。 snmpwalk是SNMP协议提供的一项功能,用于批量获取远程系统的指标。

获取所有OIDS (Get All OIDS)

We will first look the simplest usage of the snmpwalk command. We just provide minimum options to the snmpwalk. We will provide following options as minimum

我们首先来看一下snmpwalk命令的最简单用法。 我们仅提供snmpwalk最少选项。 我们将至少提供以下选项

  • `-v 2c` version information 2 community

    `-v 2c`版本信息2社区
  • `-c`the public or private secret

    -c公共或私人秘密
  • `IP ADDRESS`

    IP地址
$ snmpwalk -v 2c -c public localhost
Get All OIDS
Get All OIDS
获取所有OIDS

获取特定的OIDS (Get Specific OIDS)

In previous example we have listed all existing and configured OIDs. But this is not useful for all cases. We may need to filter and specify only OIDS we need. We will add to the end of the command the OIDs we want to get. In this example we only want OID of contact information.

在前面的示例中,我们列出了所有现有的和配置的OID。 但这并不是对所有情况都有用。 我们可能只需要过滤和指定我们需要的OIDS。 我们将在命令末尾添加我们要获取的OID。 在此示例中,我们仅需要联系信息的OID。

$ snmpwalk -v 2c -c public localhost iso.3.6.1.2.1.1.6.0
Get Specific OIDS
Get Specific OIDS
获取特定的OIDS

为外部MIB指定MIB库路径 (Specify MIB Library Path For External MIBs)

Normally Linux provide a lot of default MIBs but in some cases the remote system vendor may provide 3rd party MIBs. We can use these MIBs in order to get OIDs of remote system. We will specify the MIBs location with -M option.

通常,Linux提供许多默认的MIB,但在某些情况下,远程系统供应商可能会提供第三方MIB。 我们可以使用这些MIB来获取远程系统的OID。 我们将使用-M选项指定MIB的位置。

$ snmpwalk -v 2c -c public -M /root/ismail/ciscoMIB localhost iso.3.6.1.2.1.1.6.0

更改默认超时或设置新超时 (Change Default Timeout or Set New Timeout)

While running snmpwalk there is default timeout where the command will wait for a response from remote systems. We can change this default timeout value and set whatever we want the -t option by providing the value of timeout. In this example we will set timeout as 10 seconds.

在运行snmpwalk存在默认超时,该命令将等待远程系统的响应。 我们可以更改此默认超时值,并通过提供超时值来设置-t选项。 在此示例中,我们将超时设置为10秒。

$ snmpwalk -t 10 -v 2c -c public -M /root/ismail/ciscoMIB localhost iso.3.6.1.2.1.1.6.0

设置默认重试计数 (Set Default Retry Count)

If there are network related problem and packet loss we may require to retry snmpwalk command. This will resend request after specified timout value. We will use -r option in order to set retry count. In this example we will retry 1 time. So the total timeout for single host will be 20 seconds .

如果存在与网络相关的问题和数据包丢失,我们可能需要重试snmpwalk命令。 指定的超时值后,它将重新发送请求。 我们将使用-r选项来设置重试计数。 在此示例中,我们将重试1次。 因此,单个主机的总超时将为20秒。

$ snmpwalk -r 1 -t 10 -v 2c -c public -M /root/ismail/ciscoMIB localhost iso.3.6.1.2.1.1.6.0
LEARN MORE  Linux ps Command Tutorial
了解更多Linux ps命令教程

翻译自: https://www.poftut.com/snmpwalk-command-line-examples/

snmpwalk 命令

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值