register multiple instances of application in the same host to same Net-SNMP agent

783 views Asked by At

I've been struggling with this for a couple of days, and none of the solutions I've found work the way I'd like (I can be completely wrong, I've not used SNMP for a very long time, though).

This is existing code in my company, a perl application that connects to net-snmp agentx using POE::Component::NetSNMP::Agent. MIB defined for this application is defined, with base oid finished in .154. The MIB file defines 3 tables on it: status (.1), statistics (.2) and performance (.3). Everything works fine, registration with the agent goes fine, snmpwalk shows data being updated, etc.

But now a requirement has been implemented, allowing multiple (up to 32) instances of the application running in the same host. And monitoring shall be supported too, which brings the first issue: when connecting to agentX more than once, with the same OID, only one instance connects, and the others are refused.

I've though to make something like this:

  .154
       .1 (instance 1):
             .1 (status table)
             .2 (statistics table)
             .3 (performance table)
       .2 (instance 2):
             .1 (status table)
             .2 (statistics table)
             .3 (performance table)
       .3 (instance 3):
             .1 (status table)
             .2 (statistics table)
             .3 (performance table)
       [...]
       .32 (instance 32):
             .1 (status table)
             .2 (statistics table)
             .3 (performance table)

With this approach, each instance (they know their own id) can register to AgentX with no problems (nice!). Following the model above, tables for status, statistics and performance would be common to all instances.

  • querying to .154 would show the model above.
  • querying data for each specific instance by walking to .154.1, .154.2, etc would be possible too.

    But I'm unable to get this running properly, as smlint, snmpwalk and iReasoning moan about different data types expected, data is not being shown the right way, etc.

    What I've tried so far:

  • arrays: main index per instance, subindex on status, statistics and performance indexed with { main index, subindex}. Like this: SNMP: ASN.1 MIB Definitions. Referencing a table within a table.

  • Multiple definitions: re-define every table and component for the 32 instances, with different indices on names. It works moreover, but not exactly the way I was expecting: an snmpwalk of the parent does not show any child, so snmpwalk must be performed using . . . . .154.1, . . . . . .154.2, etc.

  • I've considered this solution as well: Monitoring multiple java processes on the same host via SNMP. But in my case does not work, as the instances connect to a common agent, they don't have their own agent running in a different port.

    I have to admit I'm running out of ideas. Again, I could be completely wrong and could be facing the problem from a wrong perspective.

    Is it possible to implement this the way I'm looking for? In SNMPv3 this could possibly be a good use for contexts, but they are not available in net-snmp to my knowledge.

edit

Solution number two, from my list above, is the one working better by far.

From parent MIB, 32 new child OIDs are defined:

sampleServer MODULE-IDENTITY
    LAST-UPDATED "201210101200Z"
    [...]
    DESCRIPTION "Sample Server MIB module"
    REVISION "201211191200Z" -- 19 November 2012
    DESCRIPTION "Version 0.1"

::= { parentMibs 154 }

instance1       OBJECT IDENTIFIER ::= { sampleServer 1 }
instance2       OBJECT IDENTIFIER ::= { sampleServer 2 }
instance3       OBJECT IDENTIFIER ::= { sampleServer 3 }
instance4       OBJECT IDENTIFIER ::= { sampleServer 4 }
instance5       OBJECT IDENTIFIER ::= { sampleServer 5 }
instance6       OBJECT IDENTIFIER ::= { sampleServer 6 }
[...]

And tables are repeated for each instanceId, a python script wrote the big MIB file for this (I know,

-- the table contains static information for instance number 1
-- this includes version, start time etc

sampleStatusTable1 OBJECT-TYPE
    SYNTAX          SEQUENCE OF sampleStatusEntry1
    MAX-ACCESS      not-accessible
    STATUS          current
    DESCRIPTION     "sample Server instance1 Status, table"
    ::= { instance1 1 }

[...]

-- this table contains statistics and sums that change constantly
-- please note that depending on sample_server configuraiton not all
-- of these will be filled in

sampleStatisticsTable1 OBJECT-TYPE
    SYNTAX          SEQUENCE OF sampleStatisticsEntry1
    MAX-ACCESS      not-accessible
    STATUS          current
    DESCRIPTION     "sample Server Statistics, table"
    ::= { instance1 2 }

[...]

-- performance figures that reflect the current load of sample_server

samplePerformanceTable1 OBJECT-TYPE
    SYNTAX          SEQUENCE OF samplePerformanceEntry
    MAX-ACCESS      not-accessible
    STATUS          current
    DESCRIPTION     "sample Server Performance, table"
    ::= { instance1 3 }

[...]

snmpwalk output for each instance:

snmpwalk -M +/opt/sample_server/docs/mibs -m +COMPANY-SAMPLE-MIB -v2c -cpublic localhost 1.3.6.1.1.1.2.154.1
    COMPANY-SAMPLE-MIB::sampleStatusInstance1 = INTEGER: 1
    COMPANY-SAMPLE-MIB::sampleStatusVersion1 = STRING: "3.58"
    COMPANY-SAMPLE-MIB::sampleStatusStartTime1 = STRING: "2014-12-13T00:06:27+0000"
    COMPANY-SAMPLE-MIB::sampleStatisticsInstance1 = INTEGER: 1
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPInputTransactions1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPInputErrors1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPOutputTransactions1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPOutputErrorsRecoverable1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPOutputErrors1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsEntry1.7 = INTEGER: 0
    COMPANY-SAMPLE-MIB::samplePerformanceInstance1 = INTEGER: 1
    COMPANY-SAMPLE-MIB::samplePerformanceQueueLoad1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::samplePerformanceThroughput1 = INTEGER: 0

snmpwalk -M +/opt/sample_server/docs/mibs -m +COMPANY-SAMPLE-MIB -v2c -cpublic localhost 1.3.6.1.1.1.2.154.2
    COMPANY-SAMPLE-MIB::sampleStatusInstance2 = INTEGER: 1
    COMPANY-SAMPLE-MIB::sampleStatusVersion2 = STRING: "3.58"
    COMPANY-SAMPLE-MIB::sampleStatusStartTime2 = STRING: "2014-12-13T00:06:27+0000"
    COMPANY-SAMPLE-MIB::sampleStatisticsInstance2 = INTEGER: 1
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPInputTransactions2 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPInputErrors2 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPOutputTransactions2 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPOutputErrorsRecoverable2 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPOutputErrors2 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsEntry2.7 = INTEGER: 0
    COMPANY-SAMPLE-MIB::samplePerformanceInstance2 = INTEGER: 1
    COMPANY-SAMPLE-MIB::samplePerformanceQueueLoad2 = INTEGER: 0
    COMPANY-SAMPLE-MIB::samplePerformanceThroughput2 = INTEGER: 0

But the result it's not as good as I was expecting, because a snmpwalk to master .154 shows the status for .154.1, instead of showing for every instance. Not sure if this is the expected behavior.

snmpwalk -M +/opt/sample_server/docs/mibs -m +COMPANY-SAMPLE-MIB -v2c -cpublic localhost 1.3.6.1.1.1.2.154
    COMPANY-SAMPLE-MIB::sampleStatusInstance1 = INTEGER: 1
    COMPANY-SAMPLE-MIB::sampleStatusVersion1 = STRING: "3.58"
    COMPANY-SAMPLE-MIB::sampleStatusStartTime1 = STRING: "2014-12-13T00:06:27+0000"
    COMPANY-SAMPLE-MIB::sampleStatisticsInstance1 = INTEGER: 1
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPInputTransactions1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPInputErrors1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPOutputTransactions1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPOutputErrorsRecoverable1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsHTTPOutputErrors1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::sampleStatisticsEntry1.7 = INTEGER: 0
    COMPANY-SAMPLE-MIB::samplePerformanceInstance1 = INTEGER: 1
    COMPANY-SAMPLE-MIB::samplePerformanceQueueLoad1 = INTEGER: 0
    COMPANY-SAMPLE-MIB::samplePerformanceThroughput1 = INTEGER: 0
0

There are 0 answers