← 返回命令列表

Linux command

snmpget 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Get a single OID value

snmpget -v 2c -c [community] [host] [OID]

Get system description

snmpget -v 2c -c [public] [192.168.1.1] sysDescr.0

Get multiple OID values

snmpget -v 2c -c [community] [host] [OID1] [OID2] [OID3]

Query using SNMPv3

snmpget -v 3 -u [username] -l authNoPriv -a MD5 -A [password] [host] [OID]

Query using SNMPv3

snmpget -v 3 -u [username] -l authPriv -a SHA -A [authpass] -x AES -X [privpass] [host] [OID]

Set timeout and retries

snmpget -v 2c -c [community] -t [5] -r [3] [host] [OID]

说明

snmpget communicates with a network entity using SNMP GET requests to retrieve specific management information. It queries one or more Object Identifiers (OIDs) and returns their current values from the SNMP agent. The tool supports SNMPv1, SNMPv2c, and SNMPv3. SNMPv1 and v2c use community strings for simple authentication, while SNMPv3 provides robust security with authentication (MD5/SHA) and encryption (DES/AES) options. OIDs can be specified numerically (e.g., .1.3.6.1.2.1.1.1.0) or using MIB names (e.g., sysDescr.0). Scalar values require a .0 index suffix. Without it, snmpget will return an error.

参数

-v _version_
SNMP version: 1, 2c, or 3.
-c _community_
Community string for SNMPv1/v2c authentication.
-u _username_
SNMPv3 security name (username).
-l _level_
SNMPv3 security level: noAuthNoPriv, authNoPriv, or authPriv.
-a _protocol_
SNMPv3 authentication protocol: MD5 or SHA.
-A _passphrase_
SNMPv3 authentication passphrase.
-x _protocol_
SNMPv3 privacy protocol: DES or AES.
-X _passphrase_
SNMPv3 privacy passphrase.
-t _timeout_
Timeout in seconds before retransmitting. Default: 1.
-r _retries_
Number of retries before giving up. Default: 5.
-p _port_
UDP port of the SNMP agent. Default: 161.
-m _MIBLIST_
Colon-separated list of MIB modules to load. Use ALL for all MIBs.
-M _PATHLIST_
Colon-separated list of directories to search for MIBs.
-O _options_
Output format options (e.g., n for numeric OIDs, q for quick print).

FAQ

What is the snmpget command used for?

snmpget communicates with a network entity using SNMP GET requests to retrieve specific management information. It queries one or more Object Identifiers (OIDs) and returns their current values from the SNMP agent. The tool supports SNMPv1, SNMPv2c, and SNMPv3. SNMPv1 and v2c use community strings for simple authentication, while SNMPv3 provides robust security with authentication (MD5/SHA) and encryption (DES/AES) options. OIDs can be specified numerically (e.g., .1.3.6.1.2.1.1.1.0) or using MIB names (e.g., sysDescr.0). Scalar values require a .0 index suffix. Without it, snmpget will return an error.

How do I run a basic snmpget example?

Run `snmpget -v 2c -c [community] [host] [OID]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -v _version_ do in snmpget?

SNMP version: 1, 2c, or 3.