net-snmp自定义trap怎么实现

咔酷咿赤影 2016-07-13 11:13:05
net-snmp中,自定义trap的mib用mib2c框架生成了.c和.h文件,怎么去修改.c文件以及加触发条件,自动生成的.c如下
1 /*
2 * Note: this file originally auto-generated by mib2c using
3 * $
4 */
5
6 #include <net-snmp/net-snmp-config.h>
7 #include <net-snmp/net-snmp-includes.h>
8 #include <net-snmp/agent/net-snmp-agent-includes.h>
9 #include "DevStatetraps.h"
10
11 extern const oid snmptrap_oid[];
12 extern const size_t snmptrap_oid_len;
13
14 int
15 send_linkDown_trap( void )
16 {
17 netsnmp_variable_list *var_list = NULL;
18 const oid linkDown_oid[] = { 1,3,6,1,4,1,1000,4,1,1 };
19
20 /*
21 * Set the snmpTrapOid.0 value
22 */
23 snmp_varlist_add_variable(&var_list,
24 snmptrap_oid, snmptrap_oid_len,
25 ASN_OBJECT_ID,
26 linkDown_oid, sizeof(linkDown_oid));
27
28
29 /*
30 * Add any extra (optional) objects here
31 */
32
33 /*
34 * Send the trap to the list of configured destinations
35 * and clean up
36 */
37 send_v2trap( var_list );
38 snmp_free_varbind( var_list );
39
40 return SNMP_ERR_NOERROR;
41 }
42 int
43 send_ifOverflow_trap( void )
44 {
45 netsnmp_variable_list *var_list = NULL;
46 const oid ifOverflow_oid[] = { 1,3,6,1,4,1,1000,4,1,2 };
47
48 /*
49 * Set the snmpTrapOid.0 value
50 */
51 snmp_varlist_add_variable(&var_list,
52 snmptrap_oid, snmptrap_oid_len,
53 ASN_OBJECT_ID,
54 ifOverflow_oid, sizeof(ifOverflow_oid));
55
56
57 /*
58 * Add any extra (optional) objects here
59 */
60
61 /*
62 * Send the trap to the list of configured destinations
63 * and clean up
64 */
65 send_v2trap( var_list );
66 snmp_free_varbind( var_list );
67
68 return SNMP_ERR_NOERROR;
69 }
70 int
71 send_innerOverflow_trap( void )
72 {
73 netsnmp_variable_list *var_list = NULL;
74 const oid innerOverflow_oid[] = { 1,3,6,1,4,1,1000,4,1,3 };
75
76 /*
77 * Set the snmpTrapOid.0 value
78 */
79 snmp_varlist_add_variable(&var_list,
80 snmptrap_oid, snmptrap_oid_len,
81 ASN_OBJECT_ID,
82 innerOverflow_oid, sizeof(innerOverflow_oid));
83
84
85 /*
86 * Add any extra (optional) objects here
87 */
88
89 /*
90 * Send the trap to the list of configured destinations
91 * and clean up
92 */
93 send_v2trap( var_list );
94 snmp_free_varbind( var_list );
95
96 return SNMP_ERR_NOERROR;
97 }
...全文
299 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

23,120

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧