From owner-freebsd-rc@FreeBSD.ORG Tue Jun 14 13:35:58 2011 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E161C106564A for ; Tue, 14 Jun 2011 13:35:57 +0000 (UTC) (envelope-from cmdlnkid@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id 9E8508FC1A for ; Tue, 14 Jun 2011 13:35:57 +0000 (UTC) Received: by iwn33 with SMTP id 33so6863150iwn.13 for ; Tue, 14 Jun 2011 06:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to; bh=XwFDFJmO6EuMe7adXTSIfVEBLFxipGgY28tWxFS4KVw=; b=QycFxBfrZOV3ljSfgcZQqpMQK3j3duG3sG7uL345NZL63sh/cMWBsW4oNoXpmuGzsV WfOuzY6QFiD+PMA61vJ9zBRY5OkLldjzwjiCuyqhTsMsTrA4Itt/9ITpekUzpkgJm3gw huPiTYGMF8j2wwcK2cReAn2XT9chSgxxdNQ4c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to; b=goxqX2UZXonmHNkRy9IFCa3PDQCqDwLzsb6V7Rzm96df56zzMhspX9vKbA13t3PRuX 3vN9SIzBuCvSnRmaMeSDLob3786YmTqalmASGtmo6NY1K3IsEjGfIE34B3OD1Gij39uR Vq9qmUsej+UpKXCLqz9DF0hktkw3HbHde0OS8= Received: by 10.42.75.202 with SMTP id b10mr4883374ick.242.1308057070925; Tue, 14 Jun 2011 06:11:10 -0700 (PDT) Received: from DataIX.net ([99.181.139.216]) by mx.google.com with ESMTPS id r1sm4742360icz.14.2011.06.14.06.11.09 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 14 Jun 2011 06:11:10 -0700 (PDT) Sender: The Command Line Kid Received: from DataIX.net (localhost [127.0.0.1]) by DataIX.net (8.14.4/8.14.4) with ESMTP id p5EDB6jX031954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 14 Jun 2011 09:11:07 -0400 (EDT) (envelope-from jhell@DataIX.net) Received: (from jhell@localhost) by DataIX.net (8.14.4/8.14.4/Submit) id p5EDB6pp031953; Tue, 14 Jun 2011 09:11:06 -0400 (EDT) (envelope-from jhell@DataIX.net) Date: Tue, 14 Jun 2011 09:11:06 -0400 From: jhell To: John Message-ID: <20110614131105.GA27199@DataIX.net> References: <20110614032343.GA96959@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7JfCtLOvnd9MIVvH" Content-Disposition: inline In-Reply-To: <20110614032343.GA96959@FreeBSD.org> Cc: freebsd-rc@freebsd.org Subject: Re: Downtime report rc script? X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jun 2011 13:35:58 -0000 --7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 14, 2011 at 03:23:43AM +0000, John wrote: >=20 > Hi Folks, >=20 > I'm trying to put together a simple to report at boot time how > long the system was down. >=20 > The script itself isn't really a problem, but I'm coming up short > looking for a reliable way to determine exactly when the sytem > went down regardless of whether it was a clean reboot or a crash. >=20 > Am I missing something simple? I've thought about writing a simple > little program to touch a file once per second invoked by the downtime > rc script after querying the last time the file was touched... but > there must be a simpler solution. >=20 > Thoughts? >=20 Record the system bootup time, and then every 5 minutes or so the current time with each new record replacing the last. In the shutdown, record the current time that replaces the last recorded current time, so it will give you the actual time the machine was going down as close as possible. Get these two/three things together then you got a fairly close/accurate way to determine how long the system is down when it comes back up. I would suggest using (date -u). sysutils/uptimed has some internal routines for calculating this. you might want to also take a look at that. --7JfCtLOvnd9MIVvH Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) Comment: http://bit.ly/0x89D8547E iQEcBAEBAgAGBQJN913pAAoJEJBXh4mJ2FR+8yUH/3zUpW+6eGlCMOuq+mBEZH3m 360+sIbKNzfABHjz8ZmwzJQHBrMOBqiprqK2G5+GnMGbIEVNozsHJSi4EO9CgNgn asu8CFnBab9DCNwepHsFd11LBv2S6M5kkehknx0a6FQjdVE8m38QibbUOaMaKAAx 3YtVNRkdCU38E9ioz3N538s/7mjgQBFO0hGs3PZV+3m1Gd4BoNVNWDXNp7RTiE8P TKjRh87RdUBT25BamSrSkl+za6SQKTi0jTLepRKBDyk2KUK4esJhDRu2bD3Qi3Lr uVXhk0wKWLMl+cRVgVOruytkG+f/6A9OuhEZkRDOYwylY6y8VzIIwCsdQy+wqxc= =PLZg -----END PGP SIGNATURE----- --7JfCtLOvnd9MIVvH--