c++ - 使用 Net-SNMP 的 snmpset 的多个值

标签 c++ c net-snmp

最近在 Net-SNMP 邮件列表上询问就像中了彩票一样,即它永远不会发生。

我需要知道如何使用 snmpset 为我的命令标量设置多个参数值?

我已经将我的命令实现为简单的标量,但最近我在想也许我需要将它们实现为表,因为它们可以有多个参数。

当用snmpset设置/触发这样的命令时,可以选择无参数、一个参数或多个参数。

给定以下示例 MIB 表。可以说这是我的命令之一。 显然 SMIv2 不再允许只写,所以我使用了不可访问。这些命令不会被 snmpget 访问。

netSnmpHostsTable OBJECT-TYPE
  SYNTAX      SEQUENCE OF NetSnmpHostsEntry
  MAX-ACCESS  not-accessible
  STATUS      current
  DESCRIPTION
      "An example table that implements a wrapper around the 
      /etc/hosts file on a machine using the iterator helper API."
  ::= { netSnmpExampleTables 2 }

netSnmpHostsEntry OBJECT-TYPE
    SYNTAX      NetSnmpHostsEntry
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
        "A host name mapped to an ip address"
    INDEX   { netSnmpHostName }
::= { netSnmpHostsTable 1 }

NetSnmpHostsEntry ::= SEQUENCE {
    netSnmpHostName         OCTET STRING,
    netSnmpHostAddressType  OCTET STRING,
    netSnmpHostAddress      OCTET STRING
}

netSnmpHostName OBJECT-TYPE
    SYNTAX      OCTET STRING (SIZE(0..64))
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
        "A host name that exists in the /etc/hosts (unix) file."
::= { netSnmpHostsEntry 1 }

netSnmpHostAddressType OBJECT-TYPE
    SYNTAX      OCTET STRING (SIZE(0..64))
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
        "The address type of then given host."
::= { netSnmpHostsEntry 2 }

netSnmpHostAddress OBJECT-TYPE
    SYNTAX      OCTET STRING (SIZE(0..64))
    MAX-ACCESS  not-accessible
    STATUS      current
    DESCRIPTION
        "The address of then given host."
::= { netSnmpHostsEntry 3 }


不带参数调用
snmpset netSnmpHostsTable.0
或使用 3 个参数调用
snmpset netSnmpHostsTable.1 something netSnmpHostsTable.2 something netSnmpHostsTable.3 something 更多

snmpset 可以吗?使用 snmpset 设置多行时,它会作为一个请求还是多个请求来处理?

最佳答案

Not-accessible 的意思就是,您将无法设置、获取甚至在步行中看到这些,因为它们是不可访问的,即它们只是定义结构的节点。

如果您的表将具有添加行的条目状态,您可能必须使用读写或读取创建,我不知道为什么只写已经消失,这对某些事情有意义。

在回答是的问题时,命令如下:

C:\net-snmp\bin\snmpset -v 2c -c public -M +C:\mibs -m SOME-MIB 10.20.30.40 SOME-MIB::someString.9 = "martski"  SOME-MIB::someOtherString.9 = "http://waratah.webs.com/" SOME-MIB::someEntryStatus.9 = createAndGo

关于c++ - 使用 Net-SNMP 的 snmpset 的多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13563235/

相关文章:

c++ - 如何使用STL中的容器读取文件

ios - 32位RGBA到16位BGR565转换

C内存有点乱

port - 使用 snmptrap 时指定端口

python net-snmp加载mibs

c++ - 读取访问冲突错误

c++ - 如何从存档中检索 true_type?

c++ - 为什么C++被称为语言联盟?

c - 为什么 1 << 3 等于 8 而不是 6?

c - SNMP代理: Could mib2c generate code for InetAddress or String type (ie something not an integer type)