Linux script that indicates time the server was offline?

Posted by RD on Super User See other posts from Super User or by RD
Published on 2010-05-18T10:07:56Z Indexed on 2010/05/18 10:11 UTC
Read the original article Hit count: 239

Filed under:
|
|
|

Below is data taken from my dedicated server:

root@namhost [~]# last
root     pts/0        XXX Tue May 18 09:46   still logged in
root     pts/0        XXX Mon May 17 08:51 - 12:18  (03:26)
reboot   system boot  XXX Mon May 17 08:49         (1+00:59)
root     pts/0        XXX Sun May 16 11:50 - 13:15  (01:25)

root@namhost [~]# last | grep "system boot"
reboot   system boot  2.6.18-164.15.1. Mon May 17 08:49         (1+01:02)
reboot   system boot  2.6.18-164.el5   Tue May 11 04:20         (7+05:31)
reboot   system boot  2.6.18-164.el5   Tue May 11 03:53         (7+05:58)
reboot   system boot  2.6.18-128.el5   Mon Oct  5 22:40          (-3:-50)
....

I need a script that I can run on an hourly basis that will: 1. Calculate the total downtime since the first date 2. The overall downtime percentage 3. Store this data in a file at /home/bla/file.txt, in the following format: TotalDowntime=03:02:02 Average=0.01%

How do I go about doing this?

© Super User or respective owner

Related posts about downtime

Related posts about linux