From owner-freebsd-rc@FreeBSD.ORG Tue Jun 14 14:13:05 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 E14541065677 for ; Tue, 14 Jun 2011 14:13:05 +0000 (UTC) (envelope-from utisoft@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 AAA1F8FC23 for ; Tue, 14 Jun 2011 14:13:05 +0000 (UTC) Received: by iwn33 with SMTP id 33so6907809iwn.13 for ; Tue, 14 Jun 2011 07:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=io0WSfkuEZfhtwTDgQkTjPDTew82AYK3Zy1Zm+pC8/E=; b=LQ3eA84NSyympdRud6XCKVO2aeECRfkzBTzqRbYUH3qaRVDdcmOOmPTNiy0rjheNyY e+oMJjJVUqC2I/RTf0+3JOgUcW82iaCm4YshnrFBBaoM5uhhciKmWxcYLWsoDfEnCs8h cvhEkH02pQPcb+am6QCrT8XPvB1dRhkydsIxg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=A6GhkfDKZQ7V1fFeB5VK9pQGy4/lKC2SfhAN5Z/qAU0dZsIoa6UWZTbAhejmtocXqI DnZGkpK15SbnWK9bUDh/xNlmAeAynJd4Bnxp+nFHms7BRLTMRn4BSfJUOvRClaFQYFSK GTZxmZ4/EUWjnMQljaKeW56dmVxryAZYNqHDw= Received: by 10.231.119.105 with SMTP id y41mr6984517ibq.27.1308060784099; Tue, 14 Jun 2011 07:13:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.174.70 with HTTP; Tue, 14 Jun 2011 07:12:34 -0700 (PDT) In-Reply-To: <20110614131105.GA27199@DataIX.net> References: <20110614032343.GA96959@FreeBSD.org> <20110614131105.GA27199@DataIX.net> From: Chris Rees Date: Tue, 14 Jun 2011 15:12:34 +0100 Message-ID: To: jhell Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-rc@freebsd.org, John 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 14:13:06 -0000 On 14 June 2011 14:11, jhell wrote: > On Tue, Jun 14, 2011 at 03:23:43AM +0000, John wrote: >> >> Hi Folks, >> >> =A0 =A0I'm trying to put together a simple to report at boot time how >> long the system was down. >> >> =A0 =A0The 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. >> >> =A0 =A0Am I missing something simple? I've thought about writing a simpl= e >> 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. >> >> =A0 =A0Thoughts? >> > > 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. > Also, the Uptimes Project [1], this one showing my old server before I finally retired it. Chris [1] http://uptimes-project.org/hosts/view/2288