Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Parsing bizarro AIX errpt timestamps into English (or SQL DATETIME) format.

by FreeBeerReekingMonk (Deacon)
on Feb 10, 2019 at 14:01 UTC ( [id://1229720]=note: print w/replies, xml ) Need Help??


in reply to Parsing bizarro AIX errpt timestamps into English (or SQL DATETIME) format.

This is a oneliner that removes the AIX TIMESTAMP, and prepends the date:

$ errpt |perl -lape '@_=$F[1]=~/(..)/g; substr $_,11,11,""; $_ = ($.== +1? "TIMEDATE".(" "x8) : "20".join("-",@_[4,0,1])." ".join(":",@_[2,3] +))." ".$_' TIMEDATE IDENTIFIER T C RESOURCE_NAME DESCRIPTION TIMEDATE IDENTIFIER T C RESOURCE_NAME DESCRIPTION 2013-09-30 15:27 982C78BF T S mir0 DISPLAY ADAPTER CONFIGUR +ATION ERROR 2013-09-25 16:27 BA431EB7 P S SRC SOFTWARE PROGRAM ERROR

You can also replace the TIMESTAMP with the TIMEDATE:

errpt | perl -lape '@_=$F[1]=~/(..)/g; substr $_,11,11, ($.==1? "TIMED +ATE".(" "x9) : "20".join("-",@_[4,0,1])." ".join(":",@_[2,3])." ")' IDENTIFIER TIMEDATE T C RESOURCE_NAME DESCRIPTION 982C78BF 2013-09-30 15:27 T S mir0 DISPLAY ADAPTER CONFIGUR +ATION ERROR BA431EB7 2013-09-25 16:27 P S SRC SOFTWARE PROGRAM ERROR

for the following errpt output:

IDENTIFIER TIMESTAMP T C RESOURCE_NAME DESCRIPTION 982C78BF 0930152713 T S mir0 DISPLAY ADAPTER CONFIGURATION +ERROR BA431EB7 0925162713 P S SRC SOFTWARE PROGRAM ERROR
</code>

Note that AIX errpt output does not have the seconds, so you can add those as hardcoded :00

Should you not have a header in the output you want parsed, then remove the $.==1? "TIMEDATE".(" "x9) :

Sorry for necroposting.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-24 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found