arunvelusamy has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,

I have a file with SNMP trap outputs, like

2006-09-01 18:29:19 localhost [127.0.0.1] (via UDP: [10.50.11.142]:110 +5) TRAP, SNMP v1, community public SNMPv2-SMI::enterprises.3.1.1 Ente +rprise Specific Trap (0) Uptime: 0:00:00.00 .........

I would like to read this information. How can i go about with this? If anyone can give a sample snippet, it will be more helpful to me.

Thanks,

Arun Velusamy.

Replies are listed 'Best First'.
Re: Read a SNMP trap information
by McDarren (Abbot) on Sep 04, 2006 at 15:44 UTC
    You'll need to use the open command.
    Then you'll probably want to use a while loop to iterate through each line in your file.
    Assuming that you are only interested in certain bits from each line (you didn't actually say which), you'll probably want to extract the bits of interest using a pattern match.
    Finally, you might want to print your results.

    That's pretty much it. Suggest you have a read of the docs for open, perlre and perhaps perlretut, then have a go at writing some code. If/when you get stuck, come back and show us what you've written and we'll be glad to help out :)

    Cheers,
    Darren :)

      Thanks Darren.

      I would be happy if someone could suggest a SNMP module to read a snmp trap from a file.

Re: Read a SNMP trap information
by NetWallah (Canon) on Sep 05, 2006 at 05:25 UTC
    Try SNMP::Trapinfo (Untested). It's description seems to meet your needs.

         "For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken