diff --git a/examples/SIMPLE-MIB.txt b/examples/SIMPLE-MIB.txt index a3c1045..3573fce 100644 --- a/examples/SIMPLE-MIB.txt +++ b/examples/SIMPLE-MIB.txt @@ -155,6 +155,20 @@ simpleDisplayString OBJECT-TYPE "An ASCII string value." ::= { simpleScalars 11 } +SimpleEnumVal ::= TEXTUAL-CONVENTION + STATUS current + DESCRIPTION + "A EnumValue" + SYNTAX Integer32 { Release(0), Debue(1), Testing(2), Stable(3) } + +simpleEnumVal OBJECT-TYPE + SYNTAX SimpleEnumVal + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "An ASCII string value." + ::= { simpleScalars 12 } + ------------------------------------------------------------------------ -- Tables ------------------------------------------------------------------------ @@ -216,6 +230,14 @@ firstTableRowValue OBJECT-TYPE "A firstTableRow's value." ::= { firstTableRow 3 } +firstTableEnumVale OBJECT-TYPE + SYNTAX SimpleEnumVal + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "A firstTableEnumVale's value." + ::= { firstTableRow 4 } + secondTableNumber OBJECT-TYPE SYNTAX Unsigned32 MAX-ACCESS read-only @@ -330,6 +352,62 @@ thirdTableRowValue OBJECT-TYPE "A thirdTableRow's value." ::= { thirdTableRow 3 } +fourthTableNumber OBJECT-TYPE + SYNTAX Unsigned32 + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "The number of rows in fourthTable." + ::= { simpleTables 7 } + +fourthTable OBJECT-TYPE + SYNTAX SEQUENCE OF FourthTableRow + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The fourth simple table" + ::= { simpleTables 8 } + +fourthTableRow OBJECT-TYPE + SYNTAX FourthTableRow + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "A particular fourthTable row." + INDEX { fourthTableRowIndex } + ::= { fourthTable 1 } + +FourthTableRow ::= + SEQUENCE { + fourthTableRowIndex SimpleEnumVal, + fourthTableRowDesc DisplayString, + fourthTableRowValue IpAddress + } + +fourthTableRowIndex OBJECT-TYPE + SYNTAX SimpleEnumVal + MAX-ACCESS not-accessible + STATUS current + DESCRIPTION + "The index column used to generate IpAddress indices into + fourthTable." + ::= { fourthTableRow 1 } + +fourthTableRowDesc OBJECT-TYPE + SYNTAX DisplayString + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "A fourthTableRow's description." + ::= { fourthTableRow 2 } + +fourthTableRowValue OBJECT-TYPE + SYNTAX IpAddress + MAX-ACCESS read-only + STATUS current + DESCRIPTION + "A fourthTableRow's value." + ::= { fourthTableRow 3 } ------------------------------------------------------------------------ -- Notifications ------------------------------------------------------------------------ diff --git a/examples/run_simple_agent.sh b/examples/run_simple_agent.sh index 61f0e95..20dafe5 100755 --- a/examples/run_simple_agent.sh +++ b/examples/run_simple_agent.sh @@ -86,6 +86,10 @@ echo " snmpwalk -v 2c -c public -M+. localhost:5555 SIMPLE-MIB::simpleMIB" echo " snmptable -v 2c -c public -M+. -Ci localhost:5555 SIMPLE-MIB::firstTable" echo " snmpget -v 2c -c public -M+. localhost:5555 SIMPLE-MIB::simpleInteger.0" echo " snmpset -v 2c -c simple -M+. localhost:5555 SIMPLE-MIB::simpleInteger.0 i 123" +echo " snmpset -v 2c -c simple -M+. localhost:5555 SIMPLE-MIB::simpleEnumVal.0 = Testing" +echo " snmpset -v 2c -c simple -M+. localhost:5555 SIMPLE-MIB::firstTableEnumVale.\\\"bb\\\" = Testing" +echo " snmpset -v 2c -c simple -M+. localhost:5555 SIMPLE-MIB::fourthTableRowValue.Testing = 192.168.1.118" + echo "" # Workaround to have CTRL-C not generate any visual feedback (we don't do any diff --git a/examples/simple_agent.py b/examples/simple_agent.py index d29210c..4acd3ff 100755 --- a/examples/simple_agent.py +++ b/examples/simple_agent.py @@ -140,6 +140,11 @@ initval = "Nice to meet you" ) +simpleEnumVal = agent.Integer32( + oidstr = "SIMPLE-MIB::simpleEnumVal", + initval = 1 +) + # Create the first table firstTable = agent.Table( oidstr = "SIMPLE-MIB::firstTable", @@ -151,7 +156,8 @@ # used for the single index column above. # We must explicitly specify that the columns should be SNMPSETable. (2, agent.DisplayString("Unknown place"), True), - (3, agent.Integer32(0), True) + (3, agent.Integer32(0), True), + (4, agent.Integer32(0), True) ], counterobj = agent.Unsigned32( oidstr = "SIMPLE-MIB::firstTableNumber" @@ -164,6 +170,7 @@ firstTableRow1 = firstTable.addRow([agent.DisplayString("aa")]) firstTableRow1.setRowCell(2, agent.DisplayString("Prague")) firstTableRow1.setRowCell(3, agent.Integer32(20)) +firstTableRow1.setRowCell(4, agent.Integer32(0)) # Add the second table row firstTableRow2 = firstTable.addRow([agent.DisplayString("ab")]) @@ -227,6 +234,38 @@ # Add the third table row thirdTableRow3 = thirdTable.addRow([agent.IpAddress("192.168.0.3")]) +# Create the fourth table +fourthTable = agent.Table( + oidstr = "SIMPLE-MIB::fourthTable", + indexes = [ + agent.Integer32() + ], + columns = [ + (2, agent.DisplayString("Broadcast"), True), + (3, agent.IpAddress("192.168.0.255"), True) + ], + counterobj = agent.Unsigned32( + oidstr = "SIMPLE-MIB::fourthTableNumber" + ), + # Allow adding new records + extendable = True +) + +# Add the first table row +fourthTableRow1 = fourthTable.addRow([agent.Integer32(0)]) +fourthTableRow1.setRowCell(2, agent.DisplayString("Host 1")) +fourthTableRow1.setRowCell(3, agent.IpAddress("192.168.0.1")) + +# Add the second table row +fourthTableRow2 = fourthTable.addRow([agent.Integer32(1)]) +fourthTableRow2.setRowCell(2, agent.DisplayString("Host 2")) +fourthTableRow2.setRowCell(3, agent.IpAddress("192.168.0.2")) + +# Add the second table row +fourthTableRow3 = fourthTable.addRow([agent.Integer32(2)]) +fourthTableRow3.setRowCell(2, agent.DisplayString("Host 3")) +fourthTableRow3.setRowCell(3, agent.IpAddress("192.168.0.3")) + # Finally, we tell the agent to "start". This actually connects the # agent to the master agent. try: