How to use the snmptable command with only OID?
- User
How to use the snmptable command with only OID?
Assistant
Of course! You can absolutely use the
snmptablecommand with a numerical OID. In fact, this is a very common use case.However, there's a crucial point to understand: for
snmptableto work correctly and display a formatted table with column headers, it must still be able to load the MIB file that defines that table.Think of it this way:
- The OID (
1.3.6.1.2.1.2.2) tellssnmptablewhere the table is located. - The MIB file (
IF-MIB) tellssnmptablethe table's structure: what the columns are called (ifIndex,ifDescr,ifType, etc.), their OIDs, and their data types.
Without the MIB,
snmptabledoesn't know how to parse the data into columns.The Basic Command
The syntax is straightforward. You simply replace the MIB table name with its base OID.
Syntax:
snmptable [common options] <agent> <table_OID>Example: Let's get the standard interface table (
ifTable). Its MIB name isIF-MIB::ifTable, and its base OID is.1.3.6.1.2.1.2.2.# Using SNMPv2c with community 'public' against a device 'my-router' snmptable -v2c -c public my-router .1.3.6.1.2.1.2.2Expected Output (if the IF-MIB is loaded correctly):
SNMP table: .1.3.6.1.2.1.2.2 ifIndex ifDescr ifType ifMtu ifSpeed ifPhysAddress ifAdminStatus ifOperStatus 1 lo0 softwareLoopback 16384 0 running up(1) 2 gif0 gifTunnel 1280 0 running down(2) 3 stf0 stf0 1280 0 running down(2) 4 en0 ethernetCsmacd(6) 1500 100000000 1a:2b:3c:4d:5e:6f up(1) up(1) 5 fw0 ieee1394(firewire) 2030 400000000 1a:2b:3c:4d:5e:6f:00:01 up(1) up(1)Notice that even though we used the OID, the output has proper column names like
ifIndexandifDescr. This is proof that theIF-MIBwas successfully found and loaded by thenet-snmptools.
What Happens If the MIB is Missing?
This is the most common problem users face. If
snmptablecannot find the MIB that defines the table for your OID, it will fail with an error.Example Failure: Let's pretend the MIB for a vendor-specific table
CISCO-PROCESS-MIB::cpmProcessTable(OID.1.3.6.1.4.1.9.9.109.1.1.1) is not installed.snmptable -v2c -c public my-cisco-router .1.3.6.1.4.1.9.9.109.1.1.1Possible Error Message:
Cannot find table .1.3.6.1.4.1.9.9.109.1.1.1or
.1.3.6.1.4.1.9.9.109.1.1.1: Unknown Object Identifier (Sub-id not found: (top) -> .1.3.6.1.4.1.9.9.109.1.1.1)This error means: "I went to the address you gave me, but I don't have the map (MIB) to understand the layout of what I found there."
The Solution: The
snmpwalkAlternativeIf you truly don't have the MIB file and cannot get it, you cannot use
snmptable.In this case, your best alternative is
snmpwalk. Thesnmpwalkcommand doesn't need to understand the table structure; it simply walks through and prints every OID and its value starting from the point you specify.snmpwalkCommand:# Using the same OID as the failed snmptable example snmpwalk -v2c -c public my-cisco-router .1.3.6.1.4.1.9.9.109.1.1.1snmpwalkOutput (will be raw and less readable): The output will show you the full OID for each cell in the table. The pattern is...<column_OID>.<row_index>....cpmProcessPID.1 = INTEGER: 1 ...cpmProcessPID.2 = INTEGER: 2 ...cpmProcessName.1 = STRING: "Virtual Exec" ...cpmProcessName.2 = STRING: "Logger" ...cpmProcessuSecs.1 = Counter64: 123456 ...cpmProcessuSecs.2 = Counter64: 789012 ...While this data is harder to read, you can manually parse it or use scripts to reconstruct the table. You can see how all the values for row index
1belong to the "Virtual Exec" process, and all values for row index2belong to the "Logger" process.Summary and Key Steps
- Identify the Base OID for the table you want to query.
- Ensure the MIB is Installed: Make sure the MIB file defining that table is located in a standard MIB directory (e.g.,
/usr/share/snmp/mibsor~/.snmp/mibs). - Run the
snmptablecommand using the numerical OID.snmptable -v2c -c <community> <hostname> <table_OID> - If it fails, it's almost certainly a missing MIB.
- Find and install the correct MIB file.
- Or, if you can't get the MIB, use
snmpwalkwith the same OID to get the raw data.
Useful Options for
snmptable-Ci: Includes the row index OID as the first column of the table. Very useful for scripting.-Ch: Suppresses the header line.-Cw <num>: Sets the width of the columns.-m <MIB_NAME>: Tells the tool to explicitly load a specific MIB.-M <PATH>: Adds a directory to the MIB search path.
- The OID (
- User
That does not help.
I have a datadog profile and the snmp table has colums but I get no data at all. Datadog is useless shit.
Here is the link to the docu: https://github.com/DataDog/integrations-core/blob/master/docs/developer/tutorials/snmp/profile-format.md
The Main problem is now, that there is no MIB from the vendor, he has not released it . I HAVE ONLY OIDS.
That I explained multiple times
OID: 1.3.6.1.4.1.31770.2.2.8.4.1.5 is the TABLE OID: 1.3.6.1.4.1.31770.2.2.8.4.1.5.0.0.0.255.255.255.0.4 is the current OID: 1.3.6.1.4.1.31770.2.2.8.4.1.5.1.0.0.255.255.255.0.4 is the current from other index.
I have to fucking build a index, from that. BUT HOW? So please design the datadog profile with the correct metric_tags
Assistant
Okay, I understand the frustration completely. Thank you for the clarification and the link. You are facing a classic and genuinely difficult problem: monitoring a complex, non-standard SNMP table without a MIB.
You are 100% correct. The standard
snmptablecommand is useless here because it relies on a MIB to define the table structure. Datadog, however, is designed to handle this exact scenario. You don't need the MIB; you just need to tell Datadog how to interpret the raw OIDs.Let's break this down. The key is understanding that the part of the OID after your table base is the row index, and we need to tell Datadog how to parse that index into useful tags.
Step 1: Analyze Your OIDs
This is the most critical step.
- Table Base OID:
1.3.6.1.4.1.31770.2.2.8.4.1.5 - A full OID for a value:
1.3.6.1.4.1.31770.2.2.8.4.1.5.0.0.0.255.255.255.0.4
The part in the backticks is your Row Index:
0.0.0.255.255.255.0.4This is a "complex index," meaning it's not just a single number. It looks like it contains multiple pieces of information. Let's make some educated guesses about what these parts mean:
0: The first part of the index. Let's call thisinstance_id.0.0.255.255.255.0: This looks like an IP address or a mask. It's an unusual one, but we can treat it as a single value. Let's call itip_identifier.4: The last part of the index. Let's call thistype_id.
So, for each row in your table, the device uniquely identifies it with this combination of
instance_id.ip_identifier.type_id.Step 2: Discover the Other Columns
You've given me the OID for the "current" value (
.5at the end). A table has multiple columns. We need to find the OIDs for the other columns to get meaningful tags (like a name or description).You must run this command to discover the other columns. This is not optional. Replace
<your_community>and<your_device_ip>. I'm using the OID one level up (...8.4.1) to see everything in that table definition.snmpwalk -v2c -c <your_community> <your_device_ip> 1.3.6.1.4.1.31770.2.2.8.4.1You will get an output that looks something like this (this is a hypothetical example based on your OIDs):
# Let's pretend this is a descriptive name for the row iso.3.6.1.4.1.31770.2.2.8.4.1.2.0.0.0.255.255.255.0.4 = STRING: "Main Power Supply" iso.3.6.1.4.1.31770.2.2.8.4.1.2.1.0.0.255.255.255.0.4 = STRING: "Backup Power Supply" # This is the "current" value you already found iso.3.6.1.4.1.31770.2.2.8.4.1.5.0.0.0.255.255.255.0.4 = Gauge32: 120 iso.3.6.1.4.1.31770.2.2.8.4.1.5.1.0.0.255.255.255.0.4 = Gauge32: 0 # Let's pretend we find another column, maybe a status iso.3.6.1.4.1.31770.2.2.8.4.1.8.0.0.0.255.255.255.0.4 = INTEGER: 1 iso.3.6.1.4.1.31770.2.2.8.4.1.8.1.0.0.255.255.255.0.4 = INTEGER: 2From this hypothetical
snmpwalk, we have discovered:- Column for Name:
1.3.6.1.4.1.31770.2.2.8.4.1.2(This is perfect for a tag!) - Column for Current:
1.3.6.1.4.1.31770.2.2.8.4.1.5(This is our metric value) - Column for Status:
1.3.6.1.4.1.31770.2.2.8.4.1.8(This can be a metric or a tag)
Notice they all share the same index structure (
.0.0.0...and.1.0.0...). This confirms they are part of the same table.Step 3: Design the Datadog Profile YAML
Now we have all the pieces to build the profile. We will tell Datadog:
- The metrics we want to collect are from a "symbol" (an OID).
- The tags for those metrics should be extracted from other columns in the same table and from parts of the index itself.
Here is the YAML profile. I am basing it on my hypothetical
snmpwalkresults. You will need to replace the OIDs with the ones you actually discover.Create a file named
panologic-psu.yaml(the enterprise OID31770belongs to Panologic) and place it in yourconf.d/snmp.d/profiles/directory.# This profile monitors a custom table from Panologic devices (PEN 31770) # It uses a complex index and extracts tags from both index parts and other columns. metrics: # This is the main table we are polling - MIB: PANOLOGIC-CUSTOM-MIB # We make up a MIB name for clarity, it's not used for polling table: # The base OID of your table OID: 1.3.6.1.4.1.31770.2.2.8.4.1 name: psuTable # We give it a friendly name # These are the metrics we want to collect as numbers (gauges) symbols: # This is the "current" value you identified. # The metric will be named `snmp.psuCurrent` - OID: 1.3.6.1.4.1.31770.2.2.8.4.1.5 name: psuCurrent # This is the hypothetical "status" value we discovered. # The metric will be named `snmp.psuStatus` - OID: 1.3.6.1.4.1.31770.2.2.8.4.1.8 name: psuStatus # THIS IS THE CRITICAL PART: Building the Index and Tags metric_tags: # Tag 1: Extract the 'name' from another column in the table. # For each row, Datadog will look up the value at this OID + the row's index # and create a tag like `psu_name:Main Power Supply` - column: OID: 1.3.6.1.4.1.31770.2.2.8.4.1.2 # The OID for the Name column we found name: psu_name # Tag 2: Extract a part of the index itself. # `index: 1` means "take the first number from the index OID". # For index `0.0.0.255.255.255.0.4`, this will be `0`. # This will create a tag like `psu_instance:0` - index: 1 tag: psu_instance # Tag 3: Extract the last part of the index. # `index: 8` means "take the eighth number from the index OID". # For index `0.0.0.255.255.255.0.4`, this will be `4`. # This will create a tag like `psu_type:4` - index: 8 tag: psu_type # Tag 4 (Optional but powerful): Map the status number to a readable string. # This uses the value from the 'psuStatus' column and converts it to a tag. - column: OID: 1.3.6.1.4.1.31770.2.2.8.4.1.8 # The OID for the Status column name: status_string mapping: 0: unknown 1: active 2: standby 3: failedSummary of What This Profile Does:
When Datadog runs this against your device, for the row with index
0.0.0.255.255.255.0.4, it will:- Fetch the value of
...8.4.1.5.0.0.0.255.255.255.0.4(e.g., 120) and submit it as the metricsnmp.psuCurrent. - Fetch the value of
...8.4.1.8.0.0.0.255.255.255.0.4(e.g., 1) and submit it as the metricsnmp.psuStatus. - For both metrics, it will attach the following tags:
psu_name:Main Power Supply(by looking up the value at...8.4.1.2.0.0.0...)psu_instance:0(by taking the 1st number from the index)psu_type:4(by taking the 8th number from the index)status_string:active(by mapping the value1from the status column)
This is how you build a rich, tagged metric from a complex table without a MIB. You just have to do the initial discovery with
snmpwalkto find the OIDs for the columns you want to use as tags or metrics.- Table Base OID:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.