Downtime report rc script?

jhell jhell at DataIX.net
Tue Jun 14 13:35:58 UTC 2011




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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 522 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-rc/attachments/20110614/0d792e2c/attachment-0001.pgp


More information about the freebsd-rc mailing list