Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl 将同一主机中的多个应用程序实例注册到同一网络SNMP代理_Perl_Snmp_Net Snmp_Poe - Fatal编程技术网

Perl 将同一主机中的多个应用程序实例注册到同一网络SNMP代理

Perl 将同一主机中的多个应用程序实例注册到同一网络SNMP代理,perl,snmp,net-snmp,poe,Perl,Snmp,Net Snmp,Poe,我已经为此苦苦挣扎了几天,我发现没有一个解决方案能以我希望的方式工作,但我可能完全错了,尽管我已经很长时间没有使用SNMP了 这是我公司现有的代码,一个使用POE::Component::NetSNMP::Agent连接到NetSNMP代理的perl应用程序。为该应用程序定义的MIB已定义,基本oid在.154中完成。MIB文件定义了3个表:status.1、statistics.2和performance.3。一切正常,向代理注册正常,snmpwalk显示数据正在更新,等等 但现在已经实现了一

我已经为此苦苦挣扎了几天,我发现没有一个解决方案能以我希望的方式工作,但我可能完全错了,尽管我已经很长时间没有使用SNMP了

这是我公司现有的代码,一个使用POE::Component::NetSNMP::Agent连接到NetSNMP代理的perl应用程序。为该应用程序定义的MIB已定义,基本oid在.154中完成。MIB文件定义了3个表:status.1、statistics.2和performance.3。一切正常,向代理注册正常,snmpwalk显示数据正在更新,等等

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

我想做一些像这样的东西:

  .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抱怨预期的数据类型不同,数据没有以正确的方式显示,等等

到目前为止,我所尝试的:

数组:每个实例的主索引、状态的子索引、统计信息和使用{main index,subindex}索引的性能。像这样:

多个定义:为32个实例重新定义每个表和组件,在名称上使用不同的索引。此外,它还能工作,但与我期望的方式不完全相同:父对象的snmpwalk不显示任何子对象,因此必须使用….执行snmpwalk。154.1, . . . . . .154.2等

我也考虑过这个解决方案:。但在我的例子中,它不起作用,因为实例连接到一个公共代理,它们没有自己的代理在不同的端口上运行

我得承认我已经没有主意了。同样,我可能是完全错误的,可能是从错误的角度面对问题

是否有可能以我正在寻找的方式实现这一点?在SNMPv3中,这可能是对上下文的一个很好的使用,但据我所知,它们在NetSNMP中不可用

编辑

从我上面列出的第二个解决方案中,到目前为止效果更好

从父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
但结果并不像我预期的那样好,因为snmpwalk to master.154显示的是.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

正如你所说,你可能想看看上下文。网络SNMP常见问题解答中提到了这一点。甚至不知道NetSNMP支持上下文。谢谢