- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Reading time that is in Posix format
I am writing a UDS for a device that timestamps events using Posix Time
1227639038.707 231 142.175.222.76 TCP_MISS/200 [etc.]
Time is 1227639038.707
Converts to Tue, 25 Nov 2008 18:50:38 GMT
Is there a way I can do this conversion in the UDS so that the time is saved in human-readable format in the database?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hello Francois,
Unfortunately, no. The UDS functionality does not contain a conversion for Posix/Unix tick timestamp formats.
Currently, you either need to read them in "as-is" or else preprocess them
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Not a big deal. While waiting for the reply, I had the log files pre-processed.
For people interested, here is a snippet of code that quickly pre-process the data in $LOG and converts the first field from epoch unix time to a more huma-readable format:
printf "cat $LOG" > $TMP/bfsed
cat $LOG | /usr/xpg4/bin/awk '{print $1}' | sed 's/\..*$//g' | sort | uniq > $TMP/timestamps
while read TIMESTAMP
do
printf " | sed \"s/$TIMESTAMP\.[0-9][0-9][0-9]/`/usr/local/bin/date -d "1970-01-01 \
$TIMESTAMP secs" +%c`/g\" " >> $TMP/bfsed
done < $TMP/timestamps
chmod 0755 $TMP/bfsed
$TMP/bfsed > $LOGROOT/processed_proxy.log
This is from a Solaris server where coreutils were installed (need GNU date). This works fine with log files of 30,000 lines
