afunms

My Software,My Dream—Forge a more perfect NMS product.

PSAX Trap 翻译(4)

有了以上三张表,很容易把PSAX Trap翻译过来:
/**
     * 翻译snmp trap
     
*/

    
private String translatePsaxTrap(Connection conn,SnmptrapDto dto) throws Exception{
        StringBuffer trap 
= new StringBuffer(200
);
        Statement stat 
=
 conn.createStatement();
        String oid 
= dto.getOid() + "." +
 dto.getSpecifics();
        ResultSet rs 
= stat.executeQuery("select b.description from acmib_oid a,acmib_event b where a.oid='" + oid + "' and a.symbol=b.symbol"
);
        
if
(rs.next())
            trap.append(rs.getString(
1
));
        
        String[] msgs 
= dto.getMessage().split(","
);
        
/**
         * 过滤掉最后一行1.3.6.1.4.1.1751.2.18.1.146.
         
*/

        
for(int i=0;i < msgs.length - 1;i++){
            String[] _msgs 
= msgs[i].split("="
);
            String _oid 
= _msgs[0].substring(0,_msgs[0].length() - 3); //去掉最后.0

            String _value = _msgs[1].trim();            
            rs 
= stat.executeQuery("select * from acmib_oid where oid='" + _oid + "'"
);
            
if(rs.next())
{
                trap.append(rs.getString(
"symbol")).append("=").append(_msgs[1
]);
                
if(rs.getString("symbol").endsWith("Code"))
{
                    ResultSet _rs 
= stat.executeQuery("select * from acmib_code where symbol='" + rs.getString("symbol"+ "' and code=" +
 _value);
                    
if
(_rs.next())
                        trap.append(
"[").append(_rs.getString("description")).append("]"
);
                }

                trap.append(
",");
            }
            
        }

        
return trap.toString();
    }
(这里省略了接受SNMP Trap的代码)

举例1:
Trap原包内容:
oid=
1.3.6.1.4.1.1751.2.18.8.4
specifics=67
message=
1.3.6.1.4.1.1751.2.18.6.31.1.1.0 = 1309001,
1.3.6.1.4.1.1751.2.18.6.33.1.1.0 = 14,
1.3.6.1.4.1.1751.2.18.6.33.1.2.0 = 153,
1.3.6.1.4.1.1751.2.18.6.33.1.3.0 = 45:86:20:02:00:88:01:00:0f:00:00:00:00:00:00:06:00:90:01:77,
1.3.6.1.4.1.1751.2.18.6.33.1.4.0 = 301001,
1.3.6.1.4.1.1751.2.18.6.33.1.5.0 = 0,
1.3.6.1.4.1.1751.2.18.6.33.1.6.0 = 669,
1.3.6.1.4.1.1751.2.18.1.146.1.1.0 = 100286

翻译后:
Notification that a SPVC connection between ATM and ATM endpoints has been deleted. spvcAddrIfA= 1309001,
atmAtmSpvcVccVpiA= 14,
atmAtmSpvcVccVciA= 153,
atmAtmSpvcVccRemoteAtmPortAddr= 45:86:20:02:00:88:01:00:0f:00:00:00:00:00:00:06:00:90:01:77,
atmAtmSpvcVccIfB= 301001,
atmAtmSpvcVccVpiB= 0,
atmAtmSpvcVccVciB= 669,
(这个atmAtmSpvcVccRemoteAtmPortAddr应该能转成一个IP或Interface,暂时没搞明白)
很明显,可以明白是一条ATM2ATM的SPVC被删除。

举例2:
Trap原包内容:
oid=
1.3.6.1.4.1.1751.2.18.8.3
specifics=104
message=
1.3.6.1.4.1.1751.2.18.15.2.0 = 1309001,
1.3.6.1.4.1.1751.2.18.15.4.0 = 67,
1.3.6.1.4.1.1751.2.18.1.146.1.1.0 = 100374,
翻译后:
Notification that a interface has undergone reduction in bandwidth. Critical depending on  Failure Reason Code.interfaceIndex= 1309001,interfaceFailureReasonCode= 67[newBWBelowCurrentAllocated]
可以看明白,是一个通道的带宽被改小了。

posted on 2009-10-24 01:16 afunms 阅读(115) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 

My Links

News

留言簿(18)

随笔档案

相册

搜索

最新评论

阅读排行榜