Total uptime in linux system, also between shutdowns

30 09 2011

In a linux system, the uptime command its used for know how long the system has been running. But there aren’t any tool for keeping a historical uptime between shutdowns or restarts/reboots.

The command tuptime comes for cover this hole, it report historial and statistical running time of the system, keeping it along the live of the system.

Also, tuptime can do these other things:
– count system startups
– register first boot time (a.k.a. installation time)
– count nicely and accidentally shutdowns
– average uptime
– current uptime
– uptime rate since first boot time
– accumulated system time

For example:

$ tuptime
System startups: 26 since 16:31:28 05/06/15
System shutdowns: 25 ok - 0 bad
Average uptime: 2 hours, 22 minutes and 9 seconds
Current uptime: 6 hours, 38 minutes and 6 seconds since 08:05:14 05/27/15
Uptime rate: 12.2659 %
System time: 2 days, 13 hours, 35 minutes and 56 seconds

The installation in a Debian system it’s pretty easy.

Download source .deb package from https://github.com/rfrail3/tuptime/tree/master/deb-package

In this case, the last relase is “tuptime-2.2.00.deb”, once the file is in the server, the next step its the package installation.

# dpkg -i tuptime-2.2.00.deb
Selecting previously unselected package tuptime.
(Reading database ... 42116 files and directories currently installed.)
Preparing to unpack tuptime-2.2.00.deb ...
Unpacking tuptime (2.2.00) ...
Setting up tuptime (2.2.00) ...
Created symlink from /etc/systemd/system/local-fs.target.wants/tuptime.service to /etc/systemd/system/tuptime.service.
Processing triggers for man-db (2.7.0.2-5) ...

Now, tuptime its available and it just start couting the time, the report will be similar to this, note that the hour/date format may change depending of the local settings.
# tuptime
System startups: 1 since 11:16:33 05/08/15
System shutdowns: 0 ok - 0 bad
Average uptime: 19 days, 3 hours, 34 minutes and 14 seconds
Current uptime: 19 days, 3 hours, 34 minutes and 14 seconds since 11:16:33 05/08/15
Uptime rate: 100.0 %
System time: 19 days, 3 hours, 34 minutes and 14 seconds

The output can be changed to seconds, for example:
# tuptime -s
System startups: 1 since 1431076593
System shutdowns: 0 ok - 0 bad
Average uptime: 1654748.0
Current uptime: 1654748.0 since 1431076593
Uptime rate: 100.0 %
System time: 1654748.0

An the date format too, for example, to date-month-year:
# tuptime -d "%m-%d-%y"
System startups: 1 since 05-08-15
System shutdowns: 0 ok - 0 bad
Average uptime: 19 days, 3 hours, 40 minutes and 43 seconds
Current uptime: 19 days, 3 hours, 40 minutes and 43 seconds since 05-08-15
Uptime rate: 100.0 %
System time: 19 days, 3 hours, 40 minutes and 43 seconds

A spin-off related with tuptime its the database in which the program register the values. Maybe this db will be helpfull for other tools of projects. By default, the file is a sqlite3 located at /var/lib/tuptime/tuptime.db and its formated with three cols, each row have:

1º – The uptime in seconds from the last tuptime execution.
2º – The last boot time in epoch date (btime).
3º – The state of the shutdown 0-bad 1-ok.

More info: https://github.com/rfrail3/tuptime

Advertisements

Actions

Information

One response

1 11 2011
jason

Really nice piece of software! It’s good.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: