From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 29 06:39:47 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8ECDB106566C for ; Wed, 29 Jun 2011 06:39:47 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mx1.fisglobal.com (mx1.fisglobal.com [199.200.24.190]) by mx1.freebsd.org (Postfix) with ESMTP id 56EBF8FC08 for ; Wed, 29 Jun 2011 06:39:47 +0000 (UTC) Received: from sbhfislrext01.fnfis.com ([192.168.249.167]) by SCSFISLTC01 (8.14.3/8.14.3) with ESMTP id p5T6dkMj004189 for ; Wed, 29 Jun 2011 01:39:46 -0500 Received: from sbhfisltcgw01.FNFIS.COM (Not Verified[10.132.248.121]) by sbhfislrext01.fnfis.com with MailMarshal (v6, 5, 4, 7535) id ; Wed, 29 Jun 2011 01:39:43 -0500 Received: from sbhfisltcgw02.FNFIS.COM ([10.132.248.122]) by sbhfisltcgw01.FNFIS.COM with Microsoft SMTPSVC(6.0.3790.4675); Wed, 29 Jun 2011 01:39:46 -0500 Received: from [10.0.0.104] ([10.132.254.136]) by sbhfisltcgw02.FNFIS.COM over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Wed, 29 Jun 2011 01:39:45 -0500 From: Devin Teske Date: Tue, 28 Jun 2011 23:39:39 -0700 Message-Id: <649FDF09-010A-4184-9B03-E8449A584DE1@vicor.com> To: FreeBSD Hackers Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) X-OriginalArrivalTime: 29 Jun 2011 06:39:45.0733 (UTC) FILETIME=[55C26750:01CC3627] Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Devin Teske Subject: [RELEASE] lastdown(8) -- A utility to show you whom was logged on when a system went down X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Jun 2011 06:39:47 -0000 I've written a new script. It's called "lastdown". What it does is pretty simple, but yet oh-so valuable to us for administeri= ng large clusters. 1. Use sysctl(8) to get the ``kern.boottime'' MIB 2. Parse the `sec' value from the above 3. Make optional adjustments 4. Pass value to date(1) to format it in CCYYddmmHHMM.SS format 5. Pass formatted date string to last(8)'s `-d' argument to... wait for it.= .. List the users that were on that system during that time. At first, I just wrote this to see if last(8)'s manual was accurate. That i= s, I wanted to see what exactly it would have to say if I gave it a value. = Well, after playing with it -- and then not -- I realized one of the more p= ractical applications of it might be to list the state of the UTMP(5) log f= rom just-before the system booted. Running this on a cluster is fun. You get to see all the people that (pardo= n my [non-]French, but) got screwed when last the system took a long walk i= n the desert (looking for it's horse no doubt *chuckles*). I just wanted to clean this up, release it under the BSD License for all, a= nd then sleep on how to implement the next iteration (you'll notice it's in= ternal version in the header states it's at 2.0 -- there was an uglier pred= ecessor). If you head on over to http://druidbsd.sourceforge.net/ you'll see examples= where the UTMP(5) log (that's the wtmp file) begins on a date that is afte= r the boottime and you'll have to specific "-f /var/log/wtmp.1" for example= to query a log that knows about the state of the machine at boot time. I'm= going to dream up ways to automatically when I should go back. The code can be had at: http://druidbsd.sourceforge.net/download/lastdown.txt or http://druidbsd.sourceforge.net/ --=20 Cheers, Devin Teske -> LEGAL DISCLAIMER <- This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy. -> FUN STUFF <- -----BEGIN GEEK CODE BLOCK----- Version 3.12 GAT/CS/B/CC/E/IT/MC/M/MU/P/S/TW d+(++) s: a- C+++@$ UB++++$ P++++@$ L++++$ = E- W+++ N? o? K? w@ O M++$ V- PS+>++ PE@ Y+ PGP-> t(+) 5? X(+) R(-) tv+ b+>++ = DI+ D+(++) G++ e>++++ h r+++ z+++ ------END GEEK CODE BLOCK------ http://www.geekcode.com/ -> END TRANSMISSION <- _____________ The information contained in this message is proprietary and/or confidentia= l. If you are not the intended recipient, please: (i) delete the message an= d all copies; (ii) do not disclose, distribute or use the message in any ma= nner; and (iii) notify the sender immediately. In addition, please be aware= that any message addressed to our domain is subject to archiving and revie= w by persons other than the intended recipient. Thank you. _____________