0

我已经为此苦苦挣扎了几天,但我找到的解决方案都没有按照我想要的方式工作(我可能完全错了,不过我已经很长时间没有使用 SNMP了) .

这是我公司的现有代码,一个使用 POE::Component::NetSNMP::Agent 连接到 net-snmp agentx 的 perl 应用程序。为该应用程序定义的 MIB 已定义,基础 oid 在 .154 中完成。MIB 文件在上面定义了 3 个表:状态 (.1)、统计 (.2) 和性能 (.3)。一切正常,代理注册正常,snmpwalk 显示数据正在更新等。

但现在已经实现了一项要求,允许在同一主机上运行多个(最多 32 个)应用程序实例。并且还要支持监控,这就带来了第一个问题:多次连接agentX时,相同的OID,只有一个实例连接,其他的都被拒绝。

我虽然做了这样的事情:

  .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)

使用这种方法,每个实例(他们知道自己的 id)都可以毫无问题地注册到 AgentX(很好!)。按照上面的模型,状态、统计和性能表对所有实例都是通用的。

  • 查询到 .154 将显示上述模型。
  • 通过步行到 .154.1、.154.2 等来查询每个特定实例的数据也是可能的。

    但我无法正常运行,因为 smlint、snmpwalk 和 iReasoning 抱怨预期的不同数据类型、数据显示不正确等。

    到目前为止我已经尝试过:

  • 数组:每个实例的主索引,状态的子索引,统计信息和性能索引与{主索引,子索引}。像这样:SNMP:ASN.1 MIB 定义。在表中引用表

  • 多重定义:为 32 个实例重新定义每个表和组件,并在名称上使用不同的索引。它还可以工作,但并不完全符合我的预期:父母的 snmpwalk 没有显示任何孩子,所以 snmpwalk 必须使用 . . . . .154.1, . . . . . .154.2 等

  • 我也考虑过这个解决方案:通过 SNMP 监视同一主机上的多个 java 进程。但在我的情况下不起作用,因为实例连接到一个公共代理,它们没有自己的代理在不同的端口上运行。

    我不得不承认我的想法已经不多了。同样,我可能完全错了,可能从错误的角度面对问题。

    是否可以按照我正在寻找的方式实现这一点?在 SNMPv3 中,这可能对上下文很有用,但据我所知,它们在 net-snmp 中不可用。

编辑

从我上面的列表中,第二个解决方案是迄今为止效果更好的解决方案。

从父 MIB 定义了 32 个新的子 OID:

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 }
[...]

并且为每个 instanceId 重复表,python 脚本为此编写了大 MIB 文件(我知道,

-- 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 输出:

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

但结果不如我预期的那么好,因为掌握 .154 的 snmpwalk 显示 .154.1 的状态,而不是显示每个实例。不确定这是否是预期的行为。

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
4

0 回答 0