【问题标题】:Snmpset not working on an agent generated by mib2cSnmpset 不适用于 mib2c 生成的代理
【发布时间】:2021-09-13 13:24:09
【问题描述】:

我使用 mib2c 从 MIB 文件生成代码。当我尝试设置具有读写访问权限的对象时,它返回Error in packet.Reason: notWritable (That object does not support modification。 我试图用很少的调试标志运行我的子代理。我发现在 snmpset 请求上没有调用单个函数生成的代码,仅在 snmpget 上调用。完全相同 OID 上的 smnpget 将返回有效值。我在任何地方都有具有 RW 访问权限的用户。我可以使用同一用户将值设置为 sysName.0。我尝试删除 MIB 文件并使用精确的 oid 但结果相同。

因为它甚至没有达到代码,我不知道该怎么做。

我尝试了以相同方式生成的 2 个表。 一个表的索引为 IMPLIED DisplayString,第二个表的索引为 2 个 INTEGER 的组合。

编辑: 我发现它在 /var/lib/snmp/ 中为我的每个代理创建了 .conf 文件。我尝试添加具有相同名称和密码的 create_user,但在代理再次启动后它消失了。

EDIT2: 代码是使用 mib2c.mfd.conf 生成的。我尝试了 mib2c.iterate.conf,它从生成的代码中调用了函数。它不能与 mib2c.mfd.conf 一起使用,但看起来它可以与 mib2c.iterate.conf 一起使用。我希望能够使其与 mib2c.mfd.conf 一起使用,因此我不需要更改所有子代理。

我的子代理的输出,其中 3.fw 是索引:

agentx/subagent: checking status of session 0x44150
agentx_build: packet built okay
agentx/subagent: synching input, op 0x01
agentx/subagent: session 0x44150 responded to ping
agentx/subagent: handling AgentX request (req=0x1f9,trans=0x1f8,sess=0x21)
agentx/subagent:   -> testset
snmp_agent: agent_sesion  0xc4a08 created
snmp_agent: add_vb_to_cache( 0xc4a08, 1, MSE-CONFIGURATION-MIB::mseDpuConfigActivationAdminStatus.3.fw,  0x3d3d0)
snmp_agent: tp->start MSE-CONFIGURATION-MIB::mseDpuConfigActivationTable, tp->end MSE-CONFIGURATION-MIB::mseDpuConfigActivation.3,
agent_set: doing set mode = 0 (SET_RESERVE1)
agent_set: did set mode = 0, status = 17
results: request results (status = 17):
results:        MSE-CONFIGURATION-MIB::mseDpuConfigActivationAdminStatus.3.fw = INTEGER: prepare(1)
snmp_agent: REMOVE session ==  0xc4a08
snmp_agent: agent_session  0xc4a08 released
snmp_agent: end of handle_snmp_packet, asp =  0xc4a08
agentx/subagent: handling agentx subagent set response (mode=162,req=0x1f9,trans=0x1f8,sess=0x21)
agentx_build: packet built okay
agentx/subagent:   FINISHED
agentx/subagent: handling AgentX request (req=0x1fa,trans=0x1f8,sess=0x21)
agentx/subagent:   -> cleanupset
snmp_agent: agent_sesion  0xc7640 created
agent_set: doing set mode = 4 (SET_FREE)
agent_set: did set mode = 4, status = 17
results: request results (status = 17):
results:        MSE-CONFIGURATION-MIB::mseDpuConfigActivationAdminStatus.3.fw = INTEGER: prepare(1)
snmp_agent: REMOVE session ==  0xc7640
snmp_agent: agent_session  0xc7640 released
snmp_agent: end of handle_snmp_packet, asp =  0xc7640
agentx/subagent: handling agentx subagent set response (mode=162,req=0x1fa,trans=0x1f8,sess=0x21)
agentx_build: packet built okay
agentx/subagent:   FINISHED
agentx/subagent: checking status of session 0x44150
agentx_build: packet built okay
agentx/subagent: synching input, op 0x01
agentx/subagent: session 0x44150 responded to ping

用于生成代码的值/配置:

## defaults
@eval $m2c_context_reg = "netsnmp_data_list"@
@eval $m2c_data_allocate = 0@
@eval $m2c_data_cache = 1@
@eval $m2c_data_context = "generated"@ [generated|NAME]
@eval $m2c_data_init = 1@
@eval $m2c_data_transient = 0@
@eval $m2c_include_examples = 1@
@eval $m2c_irreversible_commit = 0@
@eval $m2c_table_access = "container-cached"@
@eval $m2c_table_dependencies = 0@
@eval $m2c_table_persistent = 0@
@eval $m2c_table_row_creation = 0@
@eval $m2c_table_settable = 1@
@eval $m2c_table_skip_mapping = 1@
@eval $m2c_table_sparse = 1@
@eval $mfd_generate_makefile = 1@
@eval $mfd_generate_subagent = 1@

SNMPd 版本:

# snmpd --version
NET-SNMP version:  5.9
Web:               http://www.net-snmp.org/
Email:             net-snmp-coders@lists.sourceforge.net

【问题讨论】:

    标签: c linux snmp net-snmp snmpd


    【解决方案1】:

    我发现在mib2c.mfd.conf模板生成的文件*_interface.c中,有倒排检查。

    #if !(defined(NETSNMP_NO_WRITE_SUPPORT) || defined(NETSNMP_DISABLE_SET_SUPPORT))
                                                          HANDLER_CAN_RONLY
    #else
                                                          HANDLER_CAN_RWRITE
    #endif /* NETSNMP_NO_WRITE_SUPPORT || NETSNMP_DISABLE_SET_SUPPORT */
    

    我删除了!从条件开始,它开始工作了。两个定义都是未定义的,所以它应该使用 HANDLER_CAN_RWRITE 但由于错误检查它使用了 HANDLER_CAN_RONLY。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-07-16
    • 2011-07-24
    • 1970-01-01
    • 1970-01-01
    • 2012-01-08
    • 1970-01-01
    • 2016-11-25
    相关资源
    最近更新 更多