Ruby on Rails Friday, January 13, 2017


i am very beginner using ruby.

i use a application that its name is logstash. it is ruby based monitoring tool.

it is let use ruby code in its configuration file.

i use this application for snmptrap messages.
these messages contain some key = value sections.

example output raw data:

raw datası: 

{"event"=>{"SNMPv2-MIB::snmpTrapOID.0"=>"BRIDGE-MIB::topologyChange", "DISMAN-EXPRESSION-MIB::sysUpTimeInstance"=>"206 days, 21:34:07.64", "VTP-MIB::vtpVlanIndexVlanID.3002"=>"3002", "@timestamp"=>2017-01-13T07:49:56.579Z, "host"=>"", "@version"=>"1", "message"=>"#<SNMP::SNMPv2_Trap:0x42394ae7 @request_id=110, @error_index=0, @error_status=0, @source_ip=\"\", @varbind_list=[#<SNMP::VarBind:0x30440dc @name=[], @value=#<SNMP::TimeTicks:0x3aab3b59 @value=1787604764>>, #<SNMP::VarBind:0x324d2099 @name=[], @value=[]>, #<SNMP::VarBind:0x420805ae @name=[], @value=#<SNMP::Integer:0x632bbf93 @value=3002>>, #<SNMP::VarBind:0x39215c @name=[], @value=\"Fa0/27\">]>", "IF-MIB::ifName.10027"=>"Fa0/27", "tags"=>[]}}

more readable version.

                   "SNMPv2-MIB::snmpTrapOID.0" => "BRIDGE-MIB::topologyChange",
    "DISMAN-EXPRESSION-MIB::sysUpTimeInstance" => "206 days, 21:34:07.64",
            "VTP-MIB::vtpVlanIndexVlanID.3002" => "3002",
                                  "@timestamp" => 2017-01-13T07:49:56.579Z,
                                        "host" => "",
                                    "@version" => "1",
                                     "message" => "#<SNMP::SNMPv2_Trap:0x42394ae7 @request_id=110, @error_index=0, @error_status=0, @source_ip=\"\", @varbind_list=[#<SNMP::VarBind:0x30440dc @name=[], @value=#<SNMP::TimeTicks:0x3aab3b59 @value=1787604764>>, #<SNMP::VarBind:0x324d2099 @name=[], @value=[]>, #<SNMP::VarBind:0x420805ae @name=[], @value=#<SNMP::Integer:0x632bbf93 @value=3002>>, #<SNMP::VarBind:0x39215c @name=[], @value=\"Fa0/27\">]>",
                        "IF-MIB::ifName.10027" => "Fa0/27",
                                        "tags" => [
        [0] "_rubyexception"

There is a problem these keys

"VTP-MIB::vtpVlanIndexVlanID.3002" and "IF-MIB::ifName.10027". this field contains digit section and this section is dynamic.

i want to remove this section on key. 

it looks like "VTP-MIB::vtpVlanIndexVlanID" and "IF-MIB::ifName". 

how can i do this modification?

i am not good at with ruby. i will push your patient :)

thank you :) 

You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment