Problem
pppd(MST_PPP) is logging epoch time in /usr/adm/pppd.log. How do
I convert that to a more meaningful timestamp? Solution
To make the log more "human-readable", save the following script off to a file named readlog, perform a "chmod 0755 readlog", and follow the usage instructions below.
# cut here
#!/bin/tcl
# readlog: converts date in /usr/adm/pppd.log to human-readable format.
# Usage "readlog [filename]". With no argument, filename defaults to
# /usr/adm/pppd.log. With an argument of "-", it reads from stdin,
# as in "tail -f pppd.log | readlog -"if {$argc == 0} {
set file [open /usr/adm/pppd.log r]
} else {
if {[set filename [lindex $argv 0]] == "-"} {
set file stdin
} else {
set file [open $filename r]
}
}while {[gets $file line] >= 0} {
if {! [regexp {^([^:]+):([0-9]+):(.*)$} $line {} head date tail]} {
echo $line
} else {
set date [fmtclock $date "%T %D %Z"]
echo "$head:($date):$tail"
}
}
# cut hereUsing the above script, a log entry that used to look like this:
229:901111890:LCP: Sending option MRU 2048 230:901111890:LCP: Sending option Async-Map 0xA0000 (^S,^Q) 233:901111890:LCP: Sending option Magic-Number 0x4C6D9905 235:901111890:LCP: Sending option Prot-Compression 236:901111890:LCP: Sending option Addr-Ctl-Compression
will now look like this:229:(05:51:30 07/22/98 PDT):LCP: Sending option MRU 2048 230:(05:51:30 07/22/98 PDT):LCP: Sending option Async-Map 0xA0000 (^S,^Q) 233:(05:51:30 07/22/98 PDT):LCP: Sending option Magic-Number 0x4C6D9905 235:(05:51:30 07/22/98 PDT):LCP: Sending option Prot-Compression 236:(05:51:30 07/22/98 PDT):LCP: Sending option Addr-Ctl-Compression
The "readlog" script has been incorporated into Morning Star PPP version 2.1.2, so this script should not be necessary in that release.