Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Jun 2011 23:39:39 -0700
From:      Devin Teske <dteske@vicor.com>
To:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Cc:        Devin Teske <devin.teske@fisglobal.com>
Subject:   [RELEASE] lastdown(8) -- A utility to show you whom was logged on when a system went down
Message-ID:  <649FDF09-010A-4184-9B03-E8449A584DE1@vicor.com>

next in thread | raw e-mail | index | archive | help
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.
_____________



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?649FDF09-010A-4184-9B03-E8449A584DE1>