阅读:3312回复:0
net-snmp 扩展MIB库 trap问题 ???
我通过自定义一个mib库
并新增一个trap功能,部分MIB细节如下: -- 1.3.6.1.4.1.8888.2.1.6 trapFunction NOTIFICATION-TYPE OBJECTS { trapMessage} STATUS current DESCRIPTION "Description." ::= { baseinfo 6 } -- 1.3.6.1.4.1.8888.2.1.7 trapMessage OBJECT-TYPE SYNTAX DisplayString (SIZE (1..255)) MAX-ACCESS read-write STATUS current DESCRIPTION "Description." ::= { baseinfo 7 } 我通过mib2c生成代码并修改如下: int send_trapFunction_trap(void) { netsnmp_variable_list *var_list = NULL; oid trapFunction_oid[] = { 1, 3, 6, 1, 4, 1, 8888, 2, 1, 6 }; oid trapMessage_oid[] = { 1, 3, 6, 1, 4, 1, 8888, 2, 1, 7, 0 }; const char *trapMessageStr = "Hello, This is trap!"; /* * Set the snmpTrapOid.0 value */ snmp_varlist_add_variable(&var_list, snmptrap_oid, OID_LENGTH(snmptrap_oid), ASN_OBJECT_ID, trapFunction_oid, sizeof(trapFunction_oid)); /* * Add any objects from the trap definition */ snmp_varlist_add_variable(&var_list, trapMessage_oid, OID_LENGTH(trapMessage_oid), ASN_OCTET_STR, /* * Set an appropriate value for trapMessage */ (u_char *)trapMessageStr, sizeof(trapMessageStr)); /* * Add any extra (optional) objects here */ /* * Send the trap to the list of configured destinations * and clean up */ send_v2trap(var_list); snmp_free_varbind(var_list); return SNMP_ERR_NOERROR; } 我通过网上的方法,将这个函数添加到snmpd.exe程序初始化中并启动程序,但是通过snmptrapd.exe -d -f -Lo无法收到snmpd.exe发送的trap信息,通过snmptrap.exe -v2c -c public 127.0.0.1:162 "" PROBA-MIB::trapFunction PROBA-MIB::trapMessage.0 s "just here" 命令snmptrapd.exe 有收到信息,但是修改snmpd.exe程序发送的trap则无法收到,请各位大侠帮帮忙。 |
|