Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

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

by bpoag (Monk)
on Feb 18, 2005 at 18:18 UTC ( [id://432453]=CUFP: print w/replies, xml ) Need Help??

Given any line from a plain-jane errpt dump, this routine will parse out and rebuild the timestamp into something a bit more recognizable. Since errpt doesn't have per-second resolution, I just throw an ":00" at the end of the string. The form that $errorTimeStamp takes is actually SQL type-compliant to DATETIME. :)
sub figureOutDateOfLogEntry { $itemMeridian="AM"; ($logEntry)=@_; $itemMonth=substr($logEntry,11,2); $itemDay=substr($logEntry,13,2); $itemHour=substr($logEntry,15,2); $itemMinute=substr($logEntry,17,2); $itemYear=substr($logEntry,19,2); $itemResource=substr($logEntry,26,7); $itemType=substr($logEntry,41,20); chomp($itemType); if($itemHour>12) { $itemMeridian="PM"; $itemHour-=12; } $errorTimeStamp="20".$itemYear."-".$itemMonth."-".$itemDay." " +.$itemHour.":".$itemMinute.":00"; }
  • Comment on Parsing bizarro AIX errpt timestamps into English (or SQL DATETIME) format.
  • Download Code

Replies are listed 'Best First'.
Re: Parsing bizarro AIX errpt timestamps into English (or SQL DATETIME) format.
by FreeBeerReekingMonk (Deacon) on Feb 10, 2019 at 14:01 UTC
    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.

Re: Parsing bizarro AIX errpt timestamps into English (or SQL DATETIME) format.
by Akhasha (Scribe) on Feb 25, 2005 at 06:25 UTC
    Don't you mean BIZARRO bizarro AIX errpt timestamps?

    (sorry, I couldn't help it at half past beer o'clock)
      BIZZAARRRROOOOOOO I love you. :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2026-05-11 06:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.