Technical article 109543

Script to convert Morning Star PPP's /usr/adm/pppd.log timestamps from epoch time.

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4

Written · Last revised

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 here

Using 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.

From the Xinuos technical article database, record 109543. Reproduced with permission. The original is at www.sco.com/ta/109543, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.