From nobody Fri Mar 11 17:20:34 2022 X-Original-To: current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B7EB819FC690 for ; Fri, 11 Mar 2022 17:20:44 +0000 (UTC) (envelope-from jamie@catflap.org) Received: from donotpassgo.dyslexicfish.net (donotpassgo.dyslexicfish.net [IPv6:2001:19f0:300:2185:123::1]) by mx1.freebsd.org (Postfix) with ESMTP id 4KFXkz4X6Jz4jCv for ; Fri, 11 Mar 2022 17:20:43 +0000 (UTC) (envelope-from jamie@catflap.org) Received: from donotpassgo.dyslexicfish.net (donotpassgo.dyslexicfish.net [104.207.135.49]) by donotpassgo.dyslexicfish.net (8.14.5/8.14.5) with ESMTP id 22BHKYBB085156; Fri, 11 Mar 2022 17:20:34 GMT (envelope-from jamie@donotpassgo.dyslexicfish.net) Received: (from jamie@localhost) by donotpassgo.dyslexicfish.net (8.14.5/8.14.5/Submit) id 22BHKYOY085155; Fri, 11 Mar 2022 17:20:34 GMT (envelope-from jamie) From: Jamie Landeg-Jones Message-Id: <202203111720.22BHKYOY085155@donotpassgo.dyslexicfish.net> Date: Fri, 11 Mar 2022 17:20:34 +0000 Organization: Dyslexic Fish To: imp@bsdimp.com, Alexander@leidinger.net Cc: current@FreeBSD.org Subject: Re: What are the in-kernel functions to print human readable timestamps (bintime)? References: <20220311105149.Horde.uO0yyQjwC3xmwZvuZWV1ADl@webmail.leidinger.net> In-Reply-To: User-Agent: Heirloom mailx 12.4 7/29/08 List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.7 (donotpassgo.dyslexicfish.net [104.207.135.49]); Fri, 11 Mar 2022 17:20:35 +0000 (GMT) X-Rspamd-Queue-Id: 4KFXkz4X6Jz4jCv X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=pass (policy=none) header.from=catflap.org; spf=pass (mx1.freebsd.org: domain of jamie@catflap.org designates 2001:19f0:300:2185:123::1 as permitted sender) smtp.mailfrom=jamie@catflap.org X-Spamd-Result: default: False [-2.36 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FREEFALL_USER(0.00)[jamie]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_SPF_ALLOW(-0.20)[+mx:dyslexicfish.net]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; HAS_ORG_HEADER(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_HAM_SHORT(-0.66)[-0.656]; DMARC_POLICY_ALLOW(-0.50)[catflap.org,none]; MLMMJ_DEST(0.00)[current]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:20473, ipnet:2001:19f0::/38, country:US]; SUBJECT_ENDS_QUESTION(1.00)[]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N Warner Losh wrote: > since we already add stuff to what's printed for the priority. We could say > <3,seconds-since-boot.fracsec> instead of just <3> and hack dmesg > to print the right thing. Isn't that what kern.msgbuf_show_timestamp does already? I use that, along with this script: 17:15 (40.0°C 400) [2] (49) "completions" root@thompson# cat /usr/common/bin/dmesg-uptime-to-date #!/bin/sh -efu set -efu boottime="$(sysctl -n kern.boottime | gawk '{printf "%d", gensub ("^.* sec = ([1-9][0-9]*), .*$", "\\1", 1)}')" [ -z "$(printf '%s' "$boottime" | egrep '^0$|^[1-9][0-9]*$')" ] && { printf 'Invalid boottime retrieved.\n' >& 2; exit 1; } dmesg "$@" | gawk -v boottime="$boottime" ' { uptime = gensub ("^\\[([1-9][0-9]*)\\] .*$", "\\1", 1) if (uptime == $0) realtime = "??? ?? ??:??;??" else realtime = strftime ("%b %d %T", uptime + boottime) print realtime " " $0 }' Mar 11 00:41:51 [3568757] Limiting closed port RST response from 313 to 200 packets/sec Mar 11 00:41:54 [3568760] Limiting closed port RST response from 308 to 200 packets/sec Mar 11 06:23:28 [3589254] icmp redirect from 183.196.23.176: 192.168.2.104 => 183.196.23.161 etc. Cheers, Jamie