Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Parsing text string in Perl

by shadowsong (Monk)
on Sep 02, 2015 at 09:29 UTC ( #1140766=note: print w/replies, xml ) Need Help??


in reply to Parsing text string in Perl

Tom,

Assuming your log file is called throttle_log.txt

#! perl -slw use strict; open FH_INPUT, "<throttle_log.txt" or die $!; $/ = 'Time:'; while ( <FH_INPUT> ) { chomp; m{ESME_RTHROTTLED} and (m{^\s+([0-9/\.\:\-]+)\n} and print "THROTT +LING DETECTED: $1"); }

will give an output of:

THROTTLING DETECTED: 31/8/2015-09:01:43.010 THROTTLING DETECTED: 1/9/2015-09:01:43.010

Provided your file looks like this:

Time: 31/8/2015-09:01:43.010 Protocol: SMPP ESME: ehttp_rknoe Direction: Outgoing From: 10.247.231.212/2775 To: 10.247.231.212/35173 PDU Type: Full PDU PDU Length: 16 PDU Data: 00000010800000040000005800029a92 Decode Error 0x00000000 Decoded PDU: [ smpp hdr 16 octets ] 00000000: 00 00 00 10 command_length: 16 00000004: 80 00 00 04 command_id: 0x80000004 submit_sm_re +sp 00000008: 00 00 00 58 command_status: 0x00000058 ESME_RTH +ROTTLED 0000000C: 00 02 9A 92 sequence_number: 170642 Time: 1/9/2015-09:01:43.010 Protocol: SMPP ESME: ehttp_rknoe Direction: Outgoing From: 10.247.231.212/2775 To: 10.247.231.212/35173 PDU Type: Full PDU PDU Length: 16 PDU Data: 00000010800000040000005800029a92 Decode Error 0x00000000 Decoded PDU: [ smpp hdr 16 octets ] 00000000: 00 00 00 10 command_length: 16 00000004: 80 00 00 04 command_id: 0x80000004 submit_sm_re +sp 00000008: 00 00 00 58 command_status: 0x00000059 ESME_XTH +ROTTLED 0000000C: 00 02 9A 92 sequence_number: 170642 Time: 1/9/2015-09:01:43.010 Protocol: SMPP ESME: ehttp_rknoe Direction: Outgoing From: 10.247.231.212/2775 To: 10.247.231.212/35173 PDU Type: Full PDU PDU Length: 16 PDU Data: 00000010800000040000005800029a92 Decode Error 0x00000000 Decoded PDU: [ smpp hdr 16 octets ] 00000000: 00 00 00 10 command_length: 16 00000004: 80 00 00 04 command_id: 0x80000004 submit_sm_re +sp 00000008: 00 00 00 58 command_status: 0x00000058 ESME_RTH +ROTTLED 0000000C: 00 02 9A 92 sequence_number: 170642

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1140766]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2019-05-24 17:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (151 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!