Providing row data from a table in a notification

105 Views Asked by At

I have an SNMP MIB that provides tabular data. If possible, I'd like to add an SNMP notification that provides the same data as one row of the table.

As an example, I'll use the following table from the NET-SNMP-EXAMPLES-MIB:

netSnmpHostsTable OBJECT-TYPE
    SYNTAX      SEQUENCE OF NetSnmpHostsEntry
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
        "An example table that implements a wrapper around the
        /etc/hosts file on a machine using the iterator helper API."
    ::= { netSnmpExampleTables 2 }

netSnmpHostsEntry OBJECT-TYPE
    SYNTAX      NetSnmpHostsEntry
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
        "A host name mapped to an ip address"
    INDEX   { netSnmpHostName }
    ::= { netSnmpHostsTable 1 }

NetSnmpHostsEntry ::= SEQUENCE {
    netSnmpHostName         OCTET STRING,
    netSnmpHostAddressType  InetAddressType,
    netSnmpHostAddress      InetAddress,
    netSnmpHostStorage      StorageType,
    netSnmpHostRowStatus    RowStatus
}

--- Definitions of objects in the sequence omitted

Ideally, I'd like to add a new notification which provides the data associated with a single NetSnmpHostsEntry.

My initial attempt was this:

netSnmpHostsEntryNotification NOTIFICATION-TYPE
    OBJECTS     { netSnmpHostsEntry }
    STATUS      current
    DESCRIPTION
        "First crack at the notification."
    ::= { netSnmpExampleNotificationPrefix 2 }

However, smilint reports these errors:

object `netSnmpHostsEntry' of notification `netSnmpHostsEntryNotification' must be a scalar or column
object `netSnmpHostsEntry' of notification `netSnmpHostsEntryNotification' must not be `not-accessible'

I roughly understand these errors. There are restrictions on what objects you can bind to a notification, and an object representing a row of a table is neither a scalar or a column and isn't valid.

I then tried changing that notification to this:

netSnmpHostWithEvent OBJECT-TYPE
    SYNTAX      NetSnmpHostsEntry
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION
        "Host associated with the notification"
    ::= { netSnmpExampleNotificationPrefix 3 }

netSnmpHostsEntryNotification NOTIFICATION-TYPE
    OBJECTS     { netSnmpHostWithEvent }
    STATUS      current
    DESCRIPTION
        "Second crack at the notification."
    ::= { netSnmpExampleNotificationPrefix 2 }

The linter gives a different error for this:

type `NetSnmpHostsEntry' of node `netSnmpHostWithEvent' does not resolve to a known base type

Again, I think this error makes sense. NetSnmpHostsEntry is declared as a SEQUENCE, not as a normal object. The items in that sequence are all defined as their own objects that link up to the netSnmpHostsEntry object, which itself links up to the netSnmpHostsTable object. In this example, the NetSnmpHostsEntry sequence is explicitly linked to the netSnmpHostsTable table, so the sequence isn't "usable" outside the context of the table.

This is mostly intuitive, and if I redefine the sequence in the notification, this gets through the linter without any errors1:

netSnmpHostsEntryNotification NOTIFICATION-TYPE
    OBJECTS {
        netSnmpHostName, netSnmpHostAddressType, netSnmpHostAddress,
        netSnmpHostStorage, netSnmpHostRowStatus
    }
    STATUS      current
    DESCRIPTION
        "Third crack at the notification."
    ::= { netSnmpExampleNotificationPrefix 2 }

I think this would work fine for the MIB I'm creating, but it does leave me with a few questions:

  1. Is there any way to reuse a SEQUENCE in a notification?
  2. Are there any issues with the final implementation of the notification that weren't caught by the linter?

1. I did need to change MAX-ACCESS of netSnmpHostName from not-accessible to read-create to make this work, but I don't think that's relevant to the general form of this question

0

There are 0 best solutions below