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. :)