Downtime report rc script?
    Chris Rees 
    utisoft at gmail.com
       
    Tue Jun 14 14:13:06 UTC 2011
    
    
  
On 14 June 2011 14:11, jhell <jhell at dataix.net> wrote:
> On Tue, Jun 14, 2011 at 03:23:43AM +0000, John wrote:
>>
>> Hi Folks,
>>
>>    I'm trying to put together a simple to report at boot time how
>> long the system was down.
>>
>>    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.
>>
>>    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.
>>
>>    Thoughts?
>>
>
> 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
    
    
More information about the freebsd-rc
mailing list