Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------
- Contents of data.txt provides a sample line from a syslog file
- --------------------------------------------------------------
- [May 4 11:48:37] SECURITY[31715] res_security_log.c: SecurityEvent="ChallengeSent",EventTV="2020-05-04T11:48:37.805-0400",Severity="Informational",Service="SIP",EventVersion="1",AccountID="sip:8103@my.ipv4.addr.here",SessionID="0x7fbf5c0070d8",LocalAddress="IPV4/UDP/my.ipv4.addr.here/5060",RemoteAddress="IPV4/UDP/198.46.135.250/63113",Challenge="558e30b4"
- Raku script to get the line
- ___________________________
- use v6;
- my $line = slurp "data.txt" ;
- my $line1 = $line.split(".c:") ;
- my $logprefix = $line1[0]~".c" ;
- my $line4hash = $line1[1].subst("\"", "", :global) ;
- my %linehash = LogPrefix => "$logprefix" ;
- my $lineseq = $line4hash.split(",") ;
- loop (my $i = 0; $i < 10; $i++) {
- say $lineseq[$i] ;
- my $mykv = $lineseq[$i].subst(" ", "", :g).split("=") ;
- %linehash.push: ($mykv[0] => "$mykv[1]") ;
- }
- say %linehash.keys ;
- say %linehash.values ;
- ------
- Output
- ------
- SecurityEvent=ChallengeSent
- EventTV=2020-05-04T11:48:37.805-0400
- Severity=Informational
- Service=SIP
- EventVersion=1
- AccountID=sip:8103@my.ipv4.addr.here
- SessionID=0x7fbf5c0070d8
- LocalAddress=IPV4/UDP/my.ipv4.addr.here/5060
- RemoteAddress=IPV4/UDP/198.46.135.250/63113
- Challenge=558e30b4
- (EventVersion LocalAddress SessionID Severity Challenge LogPrefix RemoteAddress SecurityEvent AccountID EventTV Service)
- (1 IPV4/UDP/my.ipv4.addr.here/5060 0x7fbf5c0070d8 Informational 558e30b4
- [May 4 11:48:37] SECURITY[31715] res_security_log.c IPV4/UDP/198.46.135.250/63113 ChallengeSent sip:8103@my.ipv4.addr.here 2020-05-04T11:48:37.805-0400 SIP)
Add Comment
Please, Sign In to add comment