Hi,

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"=>"172.26.44.65", 
> "@version"=>"1", "message"=>"#<SNMP::SNMPv2_Trap:0x42394ae7 
> @request_id=110, @error_index=0, @error_status=0, 
> @source_ip=\"172.26.44.65\", @varbind_list=[#<SNMP::VarBind:0x30440dc 
> @name=[1.3.6.1.2.1.1.3.0], @value=#<SNMP::TimeTicks:0x3aab3b59 
> @value=1787604764>>, #<SNMP::VarBind:0x324d2099 
> @name=[1.3.6.1.6.3.1.1.4.1.0], @value=[1.3.6.1.2.1.17.0.2]>, 
> #<SNMP::VarBind:0x420805ae @name=[1.3.6.1.4.1.9.9.46.1.3.1.1.1.1.3002], 
> @value=#<SNMP::Integer:0x632bbf93 @value=3002>>, #<SNMP::VarBind:0x39215c 
> @name=[1.3.6.1.2.1.31.1.1.1.1.10027], @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" => "172.26.44.65",
>                                     "@version" => "1",
>                                      "message" => 
> "#<SNMP::SNMPv2_Trap:0x42394ae7 @request_id=110, @error_index=0, 
> @error_status=0, @source_ip=\"172.26.44.65\", 
> @varbind_list=[#<SNMP::VarBind:0x30440dc @name=[1.3.6.1.2.1.1.3.0], 
> @value=#<SNMP::TimeTicks:0x3aab3b59 @value=1787604764>>, 
> #<SNMP::VarBind:0x324d2099 @name=[1.3.6.1.6.3.1.1.4.1.0], 
> @value=[1.3.6.1.2.1.17.0.2]>, #<SNMP::VarBind:0x420805ae 
> @name=[1.3.6.1.4.1.9.9.46.1.3.1.1.1.1.3002], 
> @value=#<SNMP::Integer:0x632bbf93 @value=3002>>, #<SNMP::VarBind:0x39215c 
> @name=[1.3.6.1.2.1.31.1.1.1.1.10027], @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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/d58f703a-772b-40c8-afc3-65f17bf285c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to