Skip to content

SNMP

Query SNMP v1/v2c/v3 devices from SQL: GET, WALK and MIB tables as typed rows

Connector software
Free and open source
Service credentials
Required
Query Farm hosting
Not available yet
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/snmp/index.md to help me query SNMP with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Read a network device’s name and location

Replace the documentation address with the address of a device you manage.

Uses your connected account. Set up the connector and credentials to run it with your data.

SELECT object, value
FROM snmp.main.snmp_get('192.0.2.10', 'sysName.0', 'sysDescr.0', 'sysLocation.0')
ORDER BY object

Quick start

Choose where to run SNMP, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'snmp' AS snmp (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-snmp-worker'
);

3. Add service credentials

After attaching, create the secret for the service you want to query in the same SQL session. Replace the placeholders with your service settings.

snmp credentials

SNMP credentials: a v1/v2c community or SNMPv3 USM user. SCOPE is matched as a 'snmp://<host>' (every port on a host), 'snmp://<host>:<port>' (one agent) or 'snmp://' (all agents).

Get these credentials →
secret.sql
CREATE SECRET snmp (
    TYPE snmp,
    community     '<SNMP_COMMUNITY>',  -- secret
    user          '<user>',
    auth_protocol '<auth_protocol>',
    auth_key      '<AUTH_KEY>',  -- secret
    priv_protocol '<priv_protocol>',
    priv_key      '<PRIV_KEY>'  -- secret
);
Credential fields and requirements →

4. Run a query

query.sql
SELECT object, value
FROM snmp.main.snmp_get('192.0.2.10', 'sysName.0', 'sysDescr.0', 'sysLocation.0')
ORDER BY object
More example queries →
Technical details
Verified connector release
v0.2.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach with uvx

Needs uv. uvx builds the worker from its release tag on first attach and reuses the cached environment after that.

ATTACH 'snmp' AS snmp (
  TYPE vgi,
  LOCATION 'uvx --from git+https://github.com/Query-farm/[email protected] vgi-snmp-worker'
);

Overview

Queries SNMP v1, v2c and v3 network devices such as routers, switches, servers and printers, returning variable bindings and MIB tables as typed rows, with offline lookups over the bundled IETF and Net-SNMP MIB modules.

Catalog

Everything snmp exposes once attached — read straight from the worker's released build.

snmp 1 schema
main 6 functions

SNMP device queries (GET, walk, MIB tables) and offline MIB name and OID lookups.

Schema examples (16)
Examples (16)

Identify a device by its system group

SELECT object, value
FROM snmp.main.snmp_get('192.0.2.10', 'sysName.0', 'sysDescr.0', 'sysLocation.0')
ORDER BY object;

Uptime in days from sysUpTime (hundredths of a second)

SELECT round(value_int / 8640000.0, 1) AS uptime_days
FROM snmp.main.snmp_get('192.0.2.10', 'sysUpTime.0', community := 'monitor');

One row per device: its name and its platform, the sysObjectID OID named offline with snmp_oid_name (for example 'NET-SNMP-MIB::netSnmpAgentOIDs.10' for a Linux Net-SNMP agent)

SELECT max(value) FILTER (WHERE object = 'sysName') AS sys_name,
  snmp.main.snmp_oid_name(max(value) FILTER (WHERE object = 'sysObjectID')) AS platform
FROM snmp.main.snmp_get('192.0.2.20', 'sysName.0', 'sysObjectID.0');

List interface names by ifIndex

SELECT instance AS if_index, value AS interface
FROM snmp.main.snmp_walk('192.0.2.10', 'ifDescr')
ORDER BY instance::INTEGER;
12 more examples

Which MIB-2 objects does a device populate most?

SELECT object, count(*) AS instances
FROM snmp.main.snmp_walk('192.0.2.10', 'mib-2')
GROUP BY object
ORDER BY instances DESC
LIMIT 10;

Current values of the system-group objects an SNMP SET can change (sysContact, sysName, sysLocation), by joining the walk to the MIB's MAX-ACCESS

SELECT w.object, w.value, o.syntax
FROM snmp.main.snmp_walk('192.0.2.20', 'system') w
JOIN snmp.main.snmp_mib_objects(module := 'SNMPv2-MIB', kind := 'scalar') o ON o.name = w.object
WHERE o.access = 'read-write'
ORDER BY string_split(w.oid, '.')::INTEGER[];

The five busiest interfaces by received octets

SELECT ifName, ifHCInOctets, ifHCOutOctets
FROM snmp.main.snmp_table('192.0.2.10', 'ifXTable')
ORDER BY ifHCInOctets DESC
LIMIT 5;

Disk and memory utilisation from HOST-RESOURCES-MIB

SELECT hrStorageDescr,
  round(100.0 * hrStorageUsed / nullif(hrStorageSize, 0), 1) AS pct_used
FROM snmp.main.snmp_table('192.0.2.10', 'hrStorageTable')
ORDER BY pct_used DESC NULLS LAST;

Storage areas labelled by type (hrStorageRam, hrStorageFixedDisk, ...) by decoding the hrStorageType OID with snmp_oid_name, with used space in GB (used units times allocation units)

SELECT split_part(snmp.main.snmp_oid_name(hrStorageType), '::', 2) AS storage_type,
  hrStorageDescr,
  round(hrStorageUsed * hrStorageAllocationUnits / 1e9, 2) AS used_gb,
  round(100.0 * hrStorageUsed / nullif(hrStorageSize, 0), 1) AS pct_used
FROM snmp.main.snmp_table('192.0.2.20', 'hrStorageTable')
ORDER BY storage_type, hrStorageDescr;

The numeric OID of the 64-bit input octet counter column

SELECT snmp.main.snmp_oid('IF-MIB::ifHCInOctets') AS oid;

Resolve a column of names; unknown names give NULL

SELECT n, snmp.main.snmp_oid(n) AS oid
FROM (VALUES ('sysName.0'), ('hrStorageUsed'), ('notAnObject')) t(n)
ORDER BY n;

Name the sysUpTime instance

SELECT snmp.main.snmp_oid_name('1.3.6.1.2.1.1.3.0') AS name;

Name a column of OIDs, including an unknown vendor OID

SELECT oid, snmp.main.snmp_oid_name(oid) AS name
FROM (VALUES ('1.3.6.1.2.1.25.2.3.1.6.1'), ('1.3.6.1.4.1.9.1.1')) t(oid)
ORDER BY oid;

Decode numeric OIDs from a trap or log: name each with snmp_oid_name, then join snmp_mib_objects for the object's syntax and UNITS clause (NULL when the MIB declares none)

WITH named AS (SELECT oid, snmp.main.snmp_oid_name(oid) AS name FROM (VALUES ('1.3.6.1.2.1.31.1.1.1.15.3'), ('1.3.6.1.2.1.25.2.3.1.4.1'), ('1.3.6.1.2.1.31.1.1.1.6.3')) t(oid)) SELECT n.oid, n.name, o.syntax, o.units
FROM named n
JOIN snmp.main.snmp_mib_objects() o ON o.module = split_part(n.name, '::', 1) AND o.name = split_part(split_part(n.name, '::', 2), '.', 1)
ORDER BY string_split(n.oid, '.')::INTEGER[];

Which loaded MIB modules define the most tables?

SELECT module, count(*) AS tables
FROM snmp.main.snmp_mib_objects(kind := 'table')
GROUP BY module
ORDER BY tables DESC;

Net-SNMP memory statistics available with snmp_get

SELECT name, syntax, units
FROM snmp.main.snmp_mib_objects(module := 'UCD-SNMP-MIB', kind := 'scalar')
WHERE name LIKE 'mem%'
ORDER BY oid;
Scalar functions
snmp_oid (name VARCHAR) 4 examples

Resolve a MIB name such as 'IF-MIB::ifInOctets.3' to its numeric OID

Arguments
name VARCHAR
MIB name, optionally 'MODULE::' qualified with an instance suffix.
ReturnsVARCHAR
Examples (4)

The numeric OID of the 64-bit input octet counter column

SELECT snmp.main.snmp_oid('IF-MIB::ifHCInOctets') AS oid;

Resolve a column of names; unknown names give NULL

SELECT n, snmp.main.snmp_oid(n) AS oid
FROM (VALUES ('sysName.0'), ('hrStorageUsed'), ('notAnObject')) t(n)
ORDER BY n;
SELECT snmp.main.snmp_oid('IF-MIB::ifInOctets.3') AS oid;
1 more example
SELECT n, snmp.main.snmp_oid(n) AS oid
FROM (VALUES ('sysDescr.0'), ('sysUpTime.0')) t(n)
ORDER BY n;
Link
snmp_oid_name (oid VARCHAR) 4 examples

Name a numeric OID, e.g. '1.3.6.1.2.1.1.3.0' becomes 'SNMPv2-MIB::sysUpTime.0'

Arguments
oid VARCHAR
Numeric OID in dotted form, for example 1.3.6.1.2.1.1.3.0.
ReturnsVARCHAR
Examples (4)

Name the sysUpTime instance

SELECT snmp.main.snmp_oid_name('1.3.6.1.2.1.1.3.0') AS name;

Name a column of OIDs, including an unknown vendor OID

SELECT oid, snmp.main.snmp_oid_name(oid) AS name
FROM (VALUES ('1.3.6.1.2.1.25.2.3.1.6.1'), ('1.3.6.1.4.1.9.1.1')) t(oid)
ORDER BY oid;

Decode numeric OIDs from a trap or log: name each with snmp_oid_name, then join snmp_mib_objects for the object's syntax and UNITS clause (NULL when the MIB declares none)

WITH named AS (SELECT oid, snmp.main.snmp_oid_name(oid) AS name FROM (VALUES ('1.3.6.1.2.1.31.1.1.1.15.3'), ('1.3.6.1.2.1.25.2.3.1.4.1'), ('1.3.6.1.2.1.31.1.1.1.6.3')) t(oid)) SELECT n.oid, n.name, o.syntax, o.units
FROM named n
JOIN snmp.main.snmp_mib_objects() o ON o.module = split_part(n.name, '::', 1) AND o.name = split_part(split_part(n.name, '::', 2), '.', 1)
ORDER BY string_split(n.oid, '.')::INTEGER[];
1 more example
SELECT snmp.main.snmp_oid_name('1.3.6.1.2.1.2.2.1.10.3') AS name;
Link
Table functions
snmp_get (host VARCHAR, oids VARCHAR, community := VARCHAR, context := VARCHAR, port := BIGINT, retries := BIGINT, timeout := DOUBLE, version := VARCHAR) 3 examples

Read specific SNMP instances (GET) from an agent, one row per OID

Positional arguments
host VARCHAR
Agent address: 'host', 'host:port', an IPv4/IPv6 address or '[v6addr]:port'.
oids VARCHAR
Instance OIDs to read, each a dotted numeric OID or a MIB name with its instance suffix, for example sysUpTime.0 or IF-MIB::ifInOctets.2.
Named arguments
community := VARCHAR
v1/v2c community. Default: the snmp secret, then SNMP_COMMUNITY, then 'public'. · default null
context := VARCHAR
SNMPv3 context name; empty for the default context. · default ""
port := BIGINT
UDP port; default 161. · default null
retries := BIGINT
Retransmissions after a timeout, 0 to 10. · default 1
timeout := DOUBLE
Seconds to wait for each response, 0.1 to 60. · default 2.0
version := VARCHAR
SNMP version: '1', '2c' or '3'. Default: '3' when a v3 user is configured, else '2c'. · default null
Returns columns
host VARCHAR
The agent queried, as given in the host argument.
oid VARCHAR
Numeric OID of the returned instance.
name VARCHAR
Symbolic name from the loaded MIBs, e.g. 'SNMPv2-MIB::sysDescr.0'.
object VARCHAR
The MIB object the instance belongs to, e.g. 'ifInOctets'.
instance VARCHAR
Instance suffix after the object's OID, e.g. '3'.
type VARCHAR
SNMP type, or noSuchObject / noSuchInstance.
value VARCHAR
Display value formatted by the MIB.
value_int DECIMAL(20,0)
Exact value of integer types.
value_bytes BLOB
Raw octets of string-like values.
Examples (3)

Identify a device by its system group

SELECT object, value
FROM snmp.main.snmp_get('192.0.2.10', 'sysName.0', 'sysDescr.0', 'sysLocation.0')
ORDER BY object;

Uptime in days from sysUpTime (hundredths of a second)

SELECT round(value_int / 8640000.0, 1) AS uptime_days
FROM snmp.main.snmp_get('192.0.2.10', 'sysUpTime.0', community := 'monitor');

One row per device: its name and its platform, the sysObjectID OID named offline with snmp_oid_name (for example 'NET-SNMP-MIB::netSnmpAgentOIDs.10' for a Linux Net-SNMP agent)

SELECT max(value) FILTER (WHERE object = 'sysName') AS sys_name,
  snmp.main.snmp_oid_name(max(value) FILTER (WHERE object = 'sysObjectID')) AS platform
FROM snmp.main.snmp_get('192.0.2.20', 'sysName.0', 'sysObjectID.0');
Link
snmp_mib_objects (kind := VARCHAR, module := VARCHAR) 4 examples

List the objects (tables, columns, scalars) defined by the loaded MIB modules

Named arguments
kind := VARCHAR
Only this kind: scalar, table, row, column, notification or node. · default null
module := VARCHAR
Only objects of this MIB module, e.g. 'IF-MIB'. NULL: all. · default null
Returns columns
module VARCHAR
MIB module defining the object.
name VARCHAR
Object name.
oid VARCHAR
Numeric OID of the object.
kind VARCHAR
scalar, table, row, column, notification or node.
syntax VARCHAR
Syntax or textual convention.
access VARCHAR
MAX-ACCESS.
status VARCHAR
STATUS.
units VARCHAR
UNITS clause.
description VARCHAR
DESCRIPTION clause.
Examples (4)

Which loaded MIB modules define the most tables?

SELECT module, count(*) AS tables
FROM snmp.main.snmp_mib_objects(kind := 'table')
GROUP BY module
ORDER BY tables DESC;

Net-SNMP memory statistics available with snmp_get

SELECT name, syntax, units
FROM snmp.main.snmp_mib_objects(module := 'UCD-SNMP-MIB', kind := 'scalar')
WHERE name LIKE 'mem%'
ORDER BY oid;
SELECT name
FROM snmp.main.snmp_mib_objects(module := 'IF-MIB', kind := 'column')
WHERE syntax = 'Counter64'
ORDER BY name
LIMIT 3;
1 more example
SELECT count(*) AS columns
FROM snmp.main.snmp_mib_objects(module := 'HOST-RESOURCES-MIB', kind := 'column')
WHERE oid LIKE '1.3.6.1.2.1.25.2.3.1.%';
Link
snmp_table (host VARCHAR, mib_table VARCHAR, community := VARCHAR, context := VARCHAR, max_repetitions := BIGINT, port := BIGINT, retries := BIGINT, timeout := DOUBLE, version := VARCHAR) 3 examples

Read an SNMP MIB table (ifTable, hrStorageTable, ...) as typed rows, one per table row

Positional arguments
host VARCHAR
Agent address: 'host', 'host:port', an IPv4/IPv6 address or '[v6addr]:port'.
mib_table VARCHAR
MIB table to read, for example IF-MIB::ifXTable.
Named arguments
community := VARCHAR
v1/v2c community. Default: the snmp secret, then SNMP_COMMUNITY, then 'public'. · default null
context := VARCHAR
SNMPv3 context name; empty for the default context. · default ""
max_repetitions := BIGINT
Rows requested per GETBULK (v2c/v3), 1 to 200; ignored for v1. · default 25
port := BIGINT
UDP port; default 161. · default null
retries := BIGINT
Retransmissions after a timeout, 0 to 10. · default 1
timeout := DOUBLE
Seconds to wait for each response, 0.1 to 60. · default 2.0
version := VARCHAR
SNMP version: '1', '2c' or '3'. Default: '3' when a v3 user is configured, else '2c'. · default null
Returns columns
_index VARCHAR
Instance suffix
ifIndex BIGINT
InterfaceIndex
ifName VARCHAR
DisplayString
ifInMulticastPkts BIGINT
Counter32
ifInBroadcastPkts BIGINT
Counter32
ifOutMulticastPkts BIGINT
Counter32
ifOutBroadcastPkts BIGINT
Counter32
ifHCInOctets UBIGINT
Counter64
ifHCInUcastPkts UBIGINT
Counter64
ifHCInMulticastPkts UBIGINT
Counter64
ifHCInBroadcastPkts UBIGINT
Counter64
ifHCOutOctets UBIGINT
Counter64
ifHCOutUcastPkts UBIGINT
Counter64
ifHCOutMulticastPkts UBIGINT
Counter64
ifHCOutBroadcastPkts UBIGINT
Counter64
ifLinkUpDownTrapEnable VARCHAR
Integer32
ifHighSpeed BIGINT
Gauge32
ifPromiscuousMode VARCHAR
TruthValue
ifConnectorPresent VARCHAR
TruthValue
ifAlias VARCHAR
DisplayString
ifCounterDiscontinuityTime BIGINT
TimeStamp
_index VARCHAR
Instance suffix
hrStorageIndex BIGINT
Integer32
hrStorageType VARCHAR
AutonomousType
hrStorageDescr VARCHAR
DisplayString
hrStorageAllocationUnits BIGINT
Integer32
hrStorageSize BIGINT
Integer32
hrStorageUsed BIGINT
Integer32
hrStorageAllocationFailures BIGINT
Counter32
Returns columns · depends on the arguments
_index VARCHAR
Instance suffix
ifIndex BIGINT
InterfaceIndex
ifName VARCHAR
DisplayString
ifInMulticastPkts BIGINT
Counter32
ifInBroadcastPkts BIGINT
Counter32
ifOutMulticastPkts BIGINT
Counter32
ifOutBroadcastPkts BIGINT
Counter32
ifHCInOctets UBIGINT
Counter64
ifHCInUcastPkts UBIGINT
Counter64
ifHCInMulticastPkts UBIGINT
Counter64
ifHCInBroadcastPkts UBIGINT
Counter64
ifHCOutOctets UBIGINT
Counter64
ifHCOutUcastPkts UBIGINT
Counter64
ifHCOutMulticastPkts UBIGINT
Counter64
ifHCOutBroadcastPkts UBIGINT
Counter64
ifLinkUpDownTrapEnable VARCHAR
Integer32
ifHighSpeed BIGINT
Gauge32
ifPromiscuousMode VARCHAR
TruthValue
ifConnectorPresent VARCHAR
TruthValue
ifAlias VARCHAR
DisplayString
ifCounterDiscontinuityTime BIGINT
TimeStamp
_index VARCHAR
Instance suffix
hrStorageIndex BIGINT
Integer32
hrStorageType VARCHAR
AutonomousType
hrStorageDescr VARCHAR
DisplayString
hrStorageAllocationUnits BIGINT
Integer32
hrStorageSize BIGINT
Integer32
hrStorageUsed BIGINT
Integer32
hrStorageAllocationFailures BIGINT
Counter32
Examples (3)

The five busiest interfaces by received octets

SELECT ifName, ifHCInOctets, ifHCOutOctets
FROM snmp.main.snmp_table('192.0.2.10', 'ifXTable')
ORDER BY ifHCInOctets DESC
LIMIT 5;

Disk and memory utilisation from HOST-RESOURCES-MIB

SELECT hrStorageDescr,
  round(100.0 * hrStorageUsed / nullif(hrStorageSize, 0), 1) AS pct_used
FROM snmp.main.snmp_table('192.0.2.10', 'hrStorageTable')
ORDER BY pct_used DESC NULLS LAST;

Storage areas labelled by type (hrStorageRam, hrStorageFixedDisk, ...) by decoding the hrStorageType OID with snmp_oid_name, with used space in GB (used units times allocation units)

SELECT split_part(snmp.main.snmp_oid_name(hrStorageType), '::', 2) AS storage_type,
  hrStorageDescr,
  round(hrStorageUsed * hrStorageAllocationUnits / 1e9, 2) AS used_gb,
  round(100.0 * hrStorageUsed / nullif(hrStorageSize, 0), 1) AS pct_used
FROM snmp.main.snmp_table('192.0.2.20', 'hrStorageTable')
ORDER BY storage_type, hrStorageDescr;
Link
snmp_walk (host VARCHAR, oid VARCHAR, community := VARCHAR, context := VARCHAR, max_repetitions := BIGINT, port := BIGINT, retries := BIGINT, timeout := DOUBLE, version := VARCHAR) 3 examples

Walk an SNMP subtree (GETBULK/GETNEXT) and return every instance under it

Positional arguments
host VARCHAR
Agent address: 'host', 'host:port', an IPv4/IPv6 address or '[v6addr]:port'.
oid VARCHAR
Root of the subtree to walk: a MIB name such as IF-MIB::ifTable, or a dotted numeric OID.
Named arguments
community := VARCHAR
v1/v2c community. Default: the snmp secret, then SNMP_COMMUNITY, then 'public'. · default null
context := VARCHAR
SNMPv3 context name; empty for the default context. · default ""
max_repetitions := BIGINT
Instances requested per GETBULK (v2c/v3), 1 to 200; ignored for v1, which uses GETNEXT. · default 25
port := BIGINT
UDP port; default 161. · default null
retries := BIGINT
Retransmissions after a timeout, 0 to 10. · default 1
timeout := DOUBLE
Seconds to wait for each response, 0.1 to 60. · default 2.0
version := VARCHAR
SNMP version: '1', '2c' or '3'. Default: '3' when a v3 user is configured, else '2c'. · default null
Returns columns
host VARCHAR
The agent queried, as given in the host argument.
oid VARCHAR
Numeric OID of the returned instance.
name VARCHAR
Symbolic name from the loaded MIBs, e.g. 'SNMPv2-MIB::sysDescr.0'.
object VARCHAR
The MIB object the instance belongs to, e.g. 'ifInOctets'.
instance VARCHAR
Instance suffix after the object's OID, e.g. '3'.
type VARCHAR
SNMP type, or noSuchObject / noSuchInstance.
value VARCHAR
Display value formatted by the MIB.
value_int DECIMAL(20,0)
Exact value of integer types.
value_bytes BLOB
Raw octets of string-like values.
Examples (3)

List interface names by ifIndex

SELECT instance AS if_index, value AS interface
FROM snmp.main.snmp_walk('192.0.2.10', 'ifDescr')
ORDER BY instance::INTEGER;

Which MIB-2 objects does a device populate most?

SELECT object, count(*) AS instances
FROM snmp.main.snmp_walk('192.0.2.10', 'mib-2')
GROUP BY object
ORDER BY instances DESC
LIMIT 10;

Current values of the system-group objects an SNMP SET can change (sysContact, sysName, sysLocation), by joining the walk to the MIB's MAX-ACCESS

SELECT w.object, w.value, o.syntax
FROM snmp.main.snmp_walk('192.0.2.20', 'system') w
JOIN snmp.main.snmp_mib_objects(module := 'SNMPv2-MIB', kind := 'scalar') o ON o.name = w.object
WHERE o.access = 'read-write'
ORDER BY string_split(w.oid, '.')::INTEGER[];
Link

Credentials

The secret type snmp declares, as reported by the worker itself.

snmp

How to get these credentials

SNMP credentials: a v1/v2c community or SNMPv3 USM user. SCOPE is matched as a 'snmp://<host>' (every port on a host), 'snmp://<host>:<port>' (one agent) or 'snmp://' (all agents).

secret.sql
CREATE SECRET snmp (
    TYPE snmp,
    community     '<SNMP_COMMUNITY>',  -- secret
    user          '<user>',
    auth_protocol '<auth_protocol>',
    auth_key      '<AUTH_KEY>',  -- secret
    priv_protocol '<priv_protocol>',
    priv_key      '<PRIV_KEY>'  -- secret
);
Key Type Required Description
community secret VARCHAR — SNMPv1/v2c community string.
user VARCHAR — SNMPv3 USM user (security name).
auth_protocol VARCHAR — SNMPv3 auth protocol: none, md5, sha, sha224, sha256, sha384 or sha512.
auth_key secret VARCHAR — SNMPv3 authentication passphrase.
priv_protocol VARCHAR — SNMPv3 privacy protocol: none, des, 3des, aes (aes128), aes192 or aes256.
priv_key secret VARCHAR — SNMPv3 privacy (encryption) passphrase.

The worker doesn't mark which keys are required.

Create the secret in the same session, after attaching snmp — the worker registers its secret types at ATTACH. Keys marked secret are masked in duckdb_secrets(); angle-bracket values are placeholders. Read credentials from your environment or secret store in your application and pass them through your SQL client’s parameter bindings. Keep real values out of saved SQL and history. Native DuckDB and Haybarn do not provide a SQL getenv() function.

Try these queries

Uptime in days from sysUpTime (hundredths of a second)

SELECT round(value_int / 8640000.0, 1) AS uptime_days
FROM snmp.main.snmp_get('192.0.2.10', 'sysUpTime.0', community := 'monitor')

Uses snmp_get

One row per device: its name and its platform, the sysObjectID OID named offline with snmp_oid_name (for example 'NET-SNMP-MIB::netSnmpAgentOIDs.10' for a Linux Net-SNMP agent)

SELECT max(value) FILTER (WHERE object = 'sysName') AS sys_name,
  snmp.main.snmp_oid_name(max(value) FILTER (WHERE object = 'sysObjectID')) AS platform
FROM snmp.main.snmp_get('192.0.2.20', 'sysName.0', 'sysObjectID.0')

Uses snmp_oid_namesnmp_get

List interface names by ifIndex

SELECT instance AS if_index, value AS interface
FROM snmp.main.snmp_walk('192.0.2.10', 'ifDescr')
ORDER BY instance::INTEGER

Uses snmp_walk

The five busiest interfaces by received octets

SELECT ifName, ifHCInOctets, ifHCOutOctets
FROM snmp.main.snmp_table('192.0.2.10', 'ifXTable')
ORDER BY ifHCInOctets DESC
LIMIT 5

Uses snmp_table

The numeric OID of the 64-bit input octet counter column

SELECT snmp.main.snmp_oid('IF-MIB::ifHCInOctets') AS oid

Uses snmp_oid

Which loaded MIB modules define the most tables?

SELECT module, count(*) AS tables
FROM snmp.main.snmp_mib_objects(kind := 'table')
GROUP BY module
ORDER BY tables DESC

Uses snmp_mib_objects

14 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Using the snmp worker, what is the numeric OID of IF-MIB's ifHCInOctets column?
  • Which MIB object and instance does the OID 1.3.6.1.2.1.1.3.0 refer to?
  • How many columns does the IF-MIB ifTable define, according to the snmp worker's MIBs?
  • List the names of the IF-MIB columns whose syntax is Counter64, in OID order.
  • When the snmp worker reads IF-MIB's ifXTable from a device, what DuckDB type does the ifHCInOctets column have? Answer without contacting a device.
  • How many columns does the snmp worker's subtree walk return? Answer without contacting a device.

SNMP is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.