⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-agent7.html

📁 vxworks相关论文
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title>    The WindNet SNMPv1/v2c Agent   </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a></a><a href="c-agent.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-agent6.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-agent8.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="83785">4.7  &nbsp;&nbsp;Traps</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="83786"> </a>Traps are used to notify remote managers that a significant event has taken place at the agent. Many different kinds of events qualify as "significant." For example, a manager may want to know if a certain internal agent variable reaches an arbitrary threshold; this can be accomplished by defining that condition as a trap. In another example, a communication link has gone down or come up in order to decide on an appropriate course of action, such as rerouting the packets; this is accomplished with the standard MIB-II traps described below.</p><dd><p class="Body"><a name="83787"> </a>The user-defined agent routine <b class="routine"><i class="routine">snmpIoTrapSend</i></b><b>(&nbsp;)</b> can be used to convey standard traps (defined by SNMP or MIB-II) from the agent to one or more managers. For more information on this routine, see the entry for <b class="routine"><i class="routine">snmpIoTrapSend</i></b><b>(&nbsp;)</b>in <a href="snmp.refEntries.TOC.html#83416"><i class="title">F.&nbsp;SNMP Reference</i></a>.</p><dd><p class="Body"><a name="83788"> </a>Traps that are generated by user-defined applications should invoke the function <b class="routine"><i class="routine">snmpdTrapSend</i></b><b>(&nbsp;)</b> directly. For more information, see the manual page for <b class="routine"><i class="routine">snmpdTrapSend</i></b><b>(&nbsp;)</b> in <a href="snmp.refEntries.TOC.html#83416"><i class="title">F.&nbsp;SNMP Reference</i></a>.</p><dd><p class="Body"><a name="83789"> </a>SNMP traps usually consist of, among other parameters, a <i class="emphasis">trap value</i>, in integer which indicates the event which triggered the trap. <a href="c-agent7.html#83796">Table&nbsp;4-1</a> displays the available standard SNMP and MIB-II traps. <p class="table"><h4 class="EntityTitle"><a name="83796"><font face="Helvetica, sans-serif" size="-1" class="sans">Table 4-1:&nbsp;&nbsp;Standard Traps</font></a></h4><table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellHeading"><b><a name="83802"> </a><font face="Helvetica, sans-serif" size="-1" class="sans">Trap message type </font></b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellHeadingC" align="center"><a name="83804"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans">Defined in</font></b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellHeadingC" align="center"><a name="83806"> </a><b><font face="Helvetica, sans-serif" size="-1" class="sans">Trap value</font></b></div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="83808"> </a><b class="keyword">coldStart</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="83810"> </a>SNMP</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="83812"> </a>0</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="83814"> </a><b class="keyword">warmStart</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="83816"> </a>SNMP</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="83818"> </a>1</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="83820"> </a><b class="keyword">linkDown</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="83822"> </a>MIB-II</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="83824"> </a>2</div></td><td width="10">&nbsp;</td></tr><tr valign="top"><td colspan=1 rowspan=1><div class="CellBody"><a name="83826"> </a><b class="keyword">linkUp</b></div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="83828"> </a>MIB-II</div></td><td width="10">&nbsp;</td><td colspan=1 rowspan=1><div class="CellBodyC" align="center"><a name="83830"> </a>3</div></td><td width="10">&nbsp;</td></tr><tr><td colspan="20"><hr class="tablerule"></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p></p></dl></dl><h4 class="EntityTitle"><a name="83831"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 4-1:&nbsp;&nbsp;Trap Example</font></a></h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84468"> </a>The code below provides a simple example of a trap. Invoking the function <b class="routine"><i class="routine">trapExmpl</i></b><b>(&nbsp;)</b> causes the trap to be sent to the boot host.</p><dl class="margin"><dd><pre class="Code2"><b><a name="83832">/* This is the routine to bind values in the trap */    int trapBindVals ( SNMP_PKT_T *pkt, void *   vals ) { static OIDC_T   compl_1 [] = { 1, 3, 6, 1, 4, 1, 731, 1, 0 }; static OIDC_T   compl_2 [] = { 1, 3, 6, 1, 4, 1, 731, 2, 0 };   static OCTET_T  name [] = "Wind River SNMP";   /* Do the bindings done with index 0 and 1 respectively */   SNMP_Bind_Integer (pkt, 0, sizeof compl_1 / sizeof compl_1 [0], compl_1, 1996);   SNMP_Bind_String (pkt, 1, sizeof compl_2 / sizeof compl_2 [0], compl_2, VT_STRING,                    strlen (name), name, 1);   return (0); }   void trapExmpl() {     void *                    pDestAddr;     struct sockaddr_in        destAddr;     u_long                    ipAddr;       IMPORT    int             snmpSocket;     IMPORT    char            sysBootHost [];       ipAddr = 0;            destAddr.sin_family = AF_INET;      destAddr.sin_port = htons (TRAP_PORT);      destAddr.sin_addr.s_addr = hostGetByName (sysBootHost);      pDestAddr =  &amp; destAddr;        /* We send a trap with 2 varbinds as specified in the 3'rd last       * param using the rtn trapBindVals to do the binding. A null       * cookie is passed to the binding rtn in this particular case.       * You may make use of it if needed.       */        snmpdTrapSend (&amp;snmpSocket, 1, &amp; pDestAddr, NULL, SNMP_VERSION_1,                   "trap community", snmpTrapMyOid, MYOIDLEN, &amp;ipAddr,                  ENTERPRISE_SPECIFIC, 0, 2, trapBindVals, 0); }</a></b></pre></dl><dd><p class="Body"><a name="83885"> </a>The output trap is as follows </p><dl class="margin"><dd><pre class="Code2"><b><a name="83886">------------  SNMP Header  ------------ SNMP: Version = 0 SNMP: Community = trap community SNMP: PDU = Trap SNMP: Enterprise = 1.2.3.4.5.6  SNMP: Agent address = 0.0.0.0 SNMP: Trap type = enterpriseSpecific (6) SNMP: Specific code = 0 SNMP: Time stamp = 4368  SNMP: Object = 1.3.6.1.4.1.731.1.0  SNMP: Value = 1996  SNMP: Object = 1.3.6.1.4.1.731.2.0  SNMP: Value = "Wind River SNMP"</a></b></pre></dl></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a></a><a href="c-agent.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-agent6.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-agent8.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc.    conversion tool:  Quadralay WebWorks Publisher 4.0.11    template:         CSS Template, Jan 1998 - Jefro --->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -