linux:programaanalizadordelogs
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revision | |||
— | linux:programaanalizadordelogs [2022/12/02 22:02] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | <code awk> | ||
+ | # | ||
+ | # parser_log.awk - identifica los ficheros de log de apache | ||
+ | # | ||
+ | # | ||
+ | |||
+ | BEGIN { | ||
+ | IGNORECASE = 1; | ||
+ | pattern=" | ||
+ | pattern=pattern " | ||
+ | pattern=pattern " | ||
+ | print pattern; | ||
+ | } | ||
+ | |||
+ | /.*/ { | ||
+ | line = $0; | ||
+ | |||
+ | if( match( line, / | ||
+ | { | ||
+ | ip = a[1]; | ||
+ | line = a[2] | ||
+ | } | ||
+ | else if( match( line, / | ||
+ | { | ||
+ | ip = a[1]; | ||
+ | line = a[2]; | ||
+ | } | ||
+ | |||
+ | if( match( line, / | ||
+ | { | ||
+ | user = a[1]; | ||
+ | line = a[2]; | ||
+ | } | ||
+ | |||
+ | if( match( line, / | ||
+ | { | ||
+ | pass = a[1]; | ||
+ | line = a[2]; | ||
+ | } | ||
+ | |||
+ | # parse date and time | ||
+ | if( match( line, /\[(.*)\] (.*)/, a ) != 0 ) | ||
+ | { | ||
+ | date_raw = a[1]; | ||
+ | line = a[2]; | ||
+ | # parse date_raw into date, time and timezone | ||
+ | rest = date_raw; | ||
+ | if( match( rest, / | ||
+ | { | ||
+ | date = a[1]; | ||
+ | rest = a[2]; | ||
+ | if( match( rest, /: | ||
+ | { | ||
+ | time = a[1]; | ||
+ | rest = a[2]; | ||
+ | if( match( rest, / | ||
+ | { | ||
+ | timezone = a[1]; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | # parse request | ||
+ | if( match( line, /" | ||
+ | { | ||
+ | request = a[1]; | ||
+ | line = a[2]; | ||
+ | } | ||
+ | |||
+ | # parse response codes (200, 400, etc) | ||
+ | if( match( line, / | ||
+ | { | ||
+ | code1 = a[1]; | ||
+ | line = a[2]; | ||
+ | } | ||
+ | # parse response codes (200, 400, etc) | ||
+ | if( match( line, / | ||
+ | { | ||
+ | code2 = a[1]; | ||
+ | line = a[2]; | ||
+ | } | ||
+ | |||
+ | # parse referer | ||
+ | if( match( line, /" | ||
+ | { | ||
+ | referer = a[1]; | ||
+ | line = a[2]; | ||
+ | } | ||
+ | |||
+ | # parse agent | ||
+ | if( match( line, /" | ||
+ | { | ||
+ | agent = a[1]; | ||
+ | line = a[2]; | ||
+ | } | ||
+ | |||
+ | out = pattern; | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | out = gensub( "# | ||
+ | |||
+ | print out; | ||
+ | } | ||
+ | |||
+ | |||
+ | </ |
linux/programaanalizadordelogs.txt · Last modified: 2022/12/02 22:02 by 127.0.0.1