the code above reply ccan be wrong when key values changed their position.
i fixed this problem with this modification:
if [SNMPv2-MIB::snmpTrapOID.0] == "BRIDGE-MIB::topologyChange"
{
ruby
{
code => "
v_array=Array.new;
i=0;
event.to_hash.values.each { |v| v_array.push(v); i=i+1;};
i=0;
j=0;
event.to_hash.keys.each { |k| event.set('vlanid',v_array[i]) if k.include?'VTP-MIB::vtpVlanIndexVlanID';
event.set('portid',v_array[j]) if k.include?'IF-MIB::ifName';
j=j+1; i=i+1;
};
temp=Time.new;
temp=temp.localtime.strftime ('%d %B %Y %H:%M:%S.%L %z' );
event.set('timeid',temp);
"
add_tag => "Topo_Change"
add_field => { "eventid" => "Topology_Change" }
}