Permalink
Browse files

Add a second example table to demonstrate different index types

  • Loading branch information...
1 parent 305d024 commit 628cb7b9a5d4dce83e9938806b28947a2dc62380 @pief committed Jan 10, 2013
Showing with 131 additions and 50 deletions.
  1. +94 −35 EXAMPLE-MIB.txt
  2. +36 −14 example_agent.py
  3. +1 −1 run_example_agent.sh
View
@@ -148,65 +148,122 @@ exampleDisplayString OBJECT-TYPE
::= { exampleScalars 10 }
------------------------------------------------------------------------
--- Table
+-- Tables
------------------------------------------------------------------------
-exampleTableNumber OBJECT-TYPE
+firstTableNumber OBJECT-TYPE
SYNTAX Unsigned32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
- "The number of entries in the exampleTable."
+ "The number of entries in firstTable."
::= { exampleTables 1 }
-exampleTable OBJECT-TYPE
- SYNTAX SEQUENCE OF ExampleTableEntry
+firstTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF FirstTableEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
- "An example table"
+ "The first example table"
::= { exampleTables 2 }
-ExampleTableEntry ::=
+FirstTableEntry ::=
SEQUENCE {
- exampleTableEntryIndex DisplayString,
- exampleTableEntryDesc DisplayString,
- exampleTableEntryValue Integer32
+ firstTableEntryIndex DisplayString,
+ firstTableEntryDesc DisplayString,
+ firstTableEntryValue Integer32
}
-exampleTableEntry OBJECT-TYPE
- SYNTAX ExampleTableEntry
+firstTableEntry OBJECT-TYPE
+ SYNTAX FirstTableEntry
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
- "A particular exampleTable row."
- INDEX { exampleTableEntryIndex }
- ::= { exampleTable 1 }
+ "A particular firstTable row."
+ INDEX { firstTableEntryIndex }
+ ::= { firstTable 1 }
-exampleTableEntryIndex OBJECT-TYPE
+firstTableEntryIndex OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS not-accessible
STATUS current
DESCRIPTION
- "The index column used to generate numerical indices into
- exampleTable."
- ::= { exampleTableEntry 1 }
+ "The index column used to generate string indices into
+ firstTable."
+ ::= { firstTableEntry 1 }
-exampleTableEntryDesc OBJECT-TYPE
+firstTableEntryDesc OBJECT-TYPE
SYNTAX DisplayString
MAX-ACCESS read-only
STATUS current
DESCRIPTION
- "An exampleTableEntry's description."
- ::= { exampleTableEntry 2 }
+ "A firstTableEntry's description."
+ ::= { firstTableEntry 2 }
-exampleTableEntryValue OBJECT-TYPE
+firstTableEntryValue OBJECT-TYPE
SYNTAX Integer32
MAX-ACCESS read-only
STATUS current
DESCRIPTION
- "An exampleTableEntry's value."
- ::= { exampleTableEntry 3 }
+ "A firstTableEntry's value."
+ ::= { firstTableEntry 3 }
+
+secondTableNumber OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "The number of entries in secondTable."
+ ::= { exampleTables 3 }
+
+secondTable OBJECT-TYPE
+ SYNTAX SEQUENCE OF SecondTableEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "The first example table"
+ ::= { exampleTables 4 }
+
+SecondTableEntry ::=
+ SEQUENCE {
+ secondTableEntryIndex Integer32,
+ secondTableEntryDesc DisplayString,
+ secondTableEntryValue Unsigned32
+ }
+
+secondTableEntry OBJECT-TYPE
+ SYNTAX SecondTableEntry
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "A particular secondTable row."
+ INDEX { secondTableEntryIndex }
+ ::= { secondTable 1 }
+
+secondTableEntryIndex OBJECT-TYPE
+ SYNTAX Integer32 (0..2147483647)
+ MAX-ACCESS not-accessible
+ STATUS current
+ DESCRIPTION
+ "The index column used to generate numerical indices into
+ secondTable."
+ ::= { secondTableEntry 1 }
+
+secondTableEntryDesc OBJECT-TYPE
+ SYNTAX DisplayString
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "An secondTableEntry's description."
+ ::= { secondTableEntry 2 }
+
+secondTableEntryValue OBJECT-TYPE
+ SYNTAX Unsigned32
+ MAX-ACCESS read-only
+ STATUS current
+ DESCRIPTION
+ "An secondTableEntry's value."
+ ::= { secondTableEntry 3 }
------------------------------------------------------------------------
-- Notifications
@@ -225,14 +282,14 @@ exampleUnsignedROChange NOTIFICATION-TYPE
been a change to the value of exampleUnsignedRO."
::= { events 1 }
-exampleTableChange NOTIFICATION-TYPE
+firstTableChange NOTIFICATION-TYPE
OBJECTS {
- exampleTableEntryDesc, exampleTableEntryValue
+ firstTableEntryDesc, firstTableEntryValue
}
STATUS current
DESCRIPTION
- "An exampleTableChange notification signifies that there has
- been a change to an exampleTableEntry."
+ "An firstTableChange notification signifies that there has
+ been a change to an firstTableEntry."
::= { events 2 }
exampleUnsignedROChangeNotificationsEnabled OBJECT-TYPE
@@ -244,12 +301,12 @@ exampleUnsignedROChangeNotificationsEnabled OBJECT-TYPE
enabled or disabled."
::= { operation 1 }
-exampleTableChangeNotificationsEnabled OBJECT-TYPE
+firstTableChangeNotificationsEnabled OBJECT-TYPE
SYNTAX ExampleNotificationStatus
MAX-ACCESS read-write
STATUS current
DESCRIPTION
- "Controls whether exampleTableChange notifications are
+ "Controls whether firstTableChange notifications are
enabled or disabled."
::= { operation 2 }
@@ -277,9 +334,11 @@ exampleMIBScalarsGroup OBJECT-GROUP
exampleMIBTablesGroup OBJECT-GROUP
OBJECTS {
- exampleTableNumber,
- exampleTableEntryDesc, exampleTableEntryValue,
- exampleTableChangeNotificationsEnabled
+ firstTableNumber,
+ firstTableEntryDesc, firstTableEntryValue,
+ firstTableChangeNotificationsEnabled,
+ secondTableNumber,
+ secondTableEntryDesc, secondTableEntryValue
}
STATUS current
DESCRIPTION
@@ -298,7 +357,7 @@ exampleMIBScalarsNotificationsGroup NOTIFICATION-GROUP
exampleMIBTablesNotificationsGroup NOTIFICATION-GROUP
NOTIFICATIONS {
- exampleTableChange
+ firstTableChange
}
STATUS current
DESCRIPTION
View
@@ -105,9 +105,9 @@
initval = "Nice to meet you"
)
-# Create a table
-exampleTable = agent.Table(
- oidstr = "EXAMPLE-MIB::exampleTable",
+# Create the first table
+firstTable = agent.Table(
+ oidstr = "EXAMPLE-MIB::firstTable",
indexes = [
agent.DisplayString()
],
@@ -117,19 +117,41 @@
]
)
-# First table row
-exampleRow1 = exampleTable.addRow([agent.DisplayString(initval="aa")])
-exampleRow1.setRowCell(2, agent.DisplayString(initval="Prague"))
-exampleRow1.setRowCell(3, agent.Integer32(initval=20))
+# Add the first table row
+firstTableRow1 = firstTable.addRow([agent.DisplayString(initval="aa")])
+firstTableRow1.setRowCell(2, agent.DisplayString(initval="Prague"))
+firstTableRow1.setRowCell(3, agent.Integer32(initval=20))
-# Second table row
-exampleRow2 = exampleTable.addRow([agent.DisplayString(initval="ab")])
-exampleRow2.setRowCell(2, agent.DisplayString(initval="Barcelona"))
-exampleRow2.setRowCell(3, agent.Integer32(initval=28))
+# Add the second table row
+firstTableRow2 = firstTable.addRow([agent.DisplayString(initval="ab")])
+firstTableRow2.setRowCell(2, agent.DisplayString(initval="Barcelona"))
+firstTableRow2.setRowCell(3, agent.Integer32(initval=28))
-# Third table row
-exampleRow3 = exampleTable.addRow([agent.DisplayString(initval="bb")])
-exampleRow3.setRowCell(3, agent.Integer32(initval=18))
+# Add the third table row
+firstTableRow3 = firstTable.addRow([agent.DisplayString(initval="bb")])
+firstTableRow3.setRowCell(3, agent.Integer32(initval=18))
+
+# Create the second table
+secondTable = agent.Table(
+ oidstr = "EXAMPLE-MIB::secondTable",
+ indexes = [
+ agent.Integer32()
+ ],
+ columns = [
+ (2, agent.DisplayString(initval="Unknown interface")),
+ (3, agent.Unsigned32(initval=0))
+ ]
+)
+
+# Add the first table row
+secondTableRow1 = secondTable.addRow([agent.Integer32(initval=1)])
+secondTableRow1.setRowCell(2, agent.DisplayString(initval="foo0"))
+secondTableRow1.setRowCell(3, agent.Unsigned32(initval=5030))
+
+# Add the second table row
+secondTableRow2 = secondTable.addRow([agent.Integer32(initval=2)])
+secondTableRow2.setRowCell(2, agent.DisplayString(initval="foo1"))
+secondTableRow2.setRowCell(3, agent.Unsigned32(initval=12842))
# Finally, we tell the agent to "start". This actually connects the
# agent to the master agent.
View
@@ -83,7 +83,7 @@ echo " From a second console, use snmpwalk, snmpget etc. like this:"
echo ""
echo " cd `pwd`"
echo " snmpwalk -v 2c -c public -M+. localhost:5555 EXAMPLE-MIB::exampleMIB"
-echo " snmptable -v 2c -c public -M+. -Ci localhost:5555 EXAMPLE-MIB::exampleTable"
+echo " snmptable -v 2c -c public -M+. -Ci localhost:5555 EXAMPLE-MIB::firstTable"
echo " snmpset -v 2c -c example -M+. localhost:5555 EXAMPLE-MIB::exampleInteger i 123"
echo ""

0 comments on commit 628cb7b

Please sign in to comment.