How to install tuptime in Linux


To install tuptime - Shows Historical and Statistical Running Time

Tuptime

tuptime is a tool for reporting the statistical and historical running time of a Linux system. This tool works like " uptime" command but it gives more advanced output. Installation and uses of tuptime in Linux will be discussed in this article.


Features

  • Register used kernels.
  • Counts good and bad shutdowns.
  • Register the first boot time.
  • Count system start-ups.
  • Calculate uptime and downtime percentage since first boot time.
  • Calculate the largest, average and shortest uptime and downtime.
  • Print current uptime.
  • Print formatted table.
  • Calculate the accumulated system downtime and uptime.

Requirements

  • Linux or FreeBSD OS.
  • Python modules (sys, OS, optparse, sqlite3, datetime, locale, platform, subprocess, time).
  • Python 2.7 or 3.x installed but latest version is recommended.


To Install tuptime in Linux

Before the installation of tuptime, execute the following command to install the git.

user1@linuxhelp:~$ cd /tmp/
user1@linuxhelp:/tmp$ sudo apt-get install git
[sudo] password for user1: 
Reading package lists... Done
Building dependency tree       
&hellip 
&hellip 
Setting up liberror-perl (0.17-1.1) ...
Setting up git-man (1:2.5.0-1ubuntu0.2) ...
Setting up git (1:2.5.0-1ubuntu0.2) ...


Execute the below command to clone the tuptime repository.

user1@linuxhelp:/tmp$ git clone https://github.com/rfrail3/tuptime.git
Cloning into ' tuptime' ...
remote: Counting objects: 2300, done.
remote: Total 2300 (delta 0), reused 0 (delta 0), pack-reused 2300
Receiving objects: 100% (2300/2300), 771.95 KiB | 311.00 KiB/s, done.
Resolving deltas: 100% (1141/1141), done.
Checking connectivity... done.

How to use tuptime tool?

By using this tool for certain system administration activities, to execute it with different options as a privileged user.

user1@linuxhelp:/tmp$ ll
total 64
drwxrwxrwt 15 root  root  4096 May 27 18:25 ./
drwxr-xr-x 23 root  root  4096 Mar 29 16:27 ../
-rw-------  1 user1 user1    0 Mar 29 12:19 config-err-xgRWAe
drwxrwxrwt  2 root  root  4096 Mar 29 12:18 .font-unix/
drwxrwxrwt  2 root  root  4096 Mar 29 12:19 .ICE-unix/
drwx------  3 root  root  4096 Mar 29 12:18 systemd-private-
&hellip 
&hellip 

drwxrwxr-x  6 user1 user1 4096 May 27 18:25 tuptime/


Now go to the cloned tuptime directory.

user1@linuxhelp:/tmp$ cd tuptime/
user1@linuxhelp:/tmp/tuptime$ ll
total 80
drwxrwxr-x  6 user1 user1  4096 May 27 18:25 ./
drwxrwxrwt 15 root  root   4096 May 27 18:28 ../
-rw-rw-r--  1 user1 user1  4899 May 27 18:25 CHANGELOG
drwxrwxr-x  3 user1 user1  4096 May 27 18:25 debian/
drwxrwxr-x  8 user1 user1  4096 May 27 18:25 .git/
-rw-rw-r--  1 user1 user1 18047 May 27 18:25 LICENSE
-rw-rw-r--  1 user1 user1  5113 May 27 18:25 README.md
drwxrwxr-x  2 user1 user1  4096 May 27 18:25 scripts/
drwxrwxr-x  7 user1 user1  4096 May 27 18:25 src/
-rw-rw-r--  1 user1 user1  3070 May 27 18:25 tuptime-install.sh
-rw-rw-r--  1 user1 user1 15491 May 27 18:25 tuptime-manual.txt


Install tuptime by executing the following script.

user1@linuxhelp:/tmp/tuptime$ sudo sh tuptime-install.sh
git version 2.5.0
Tuptime installation script

Clonning repository...
Cloning into ' /tmp/tmp.g0YdoMrzSX' &hellip 
&hellip 
&hellip 
Copying cron file...
Enjoy!
System startups:    1   since   09:54:12   Friday 27 May 2016
System shutdowns:    0 ok   -   0 bad
System uptime:         100.0 %   -   8 hours, 34 minutes and 36 seconds
System downtime:     0.0 %   -   0 seconds
System life:         8 hours, 34 minutes and 36 seconds

Largest uptime:        8 hours, 34 minutes and 36 seconds   from   09:54:12   Friday 27 May 2016
Shortest uptime:    8 hours, 34 minutes and 36 seconds   from   09:54:12   Friday 27 May 2016
Average uptime:     8 hours, 34 minutes and 36 seconds

Largest downtime:    0 seconds
Shortest downtime:    0 seconds
Average downtime:     0 seconds

Current uptime:     8 hours, 34 minutes and 36 seconds   since   09:54:12   Friday 27 May 2016


When you execute tuptime without any options, then you will get a display screen as follows.

user1@linuxhelp:/tmp/tuptime$ sudo tuptime 
System startups:    1   since   09:54:12   Friday 27 May 2016
System shutdowns:    0 ok   -   0 bad
System uptime:         100.0 %   -   8 hours, 35 minutes and 14 seconds
System downtime:     0.0 %   -   0 seconds
System life:         8 hours, 35 minutes and 14 seconds

Largest uptime:        8 hours, 35 minutes and 14 seconds   from   09:54:12   Friday 27 May 2016
Shortest uptime:    8 hours, 35 minutes and 14 seconds   from   09:54:12   Friday 27 May 2016
Average uptime:     8 hours, 35 minutes and 14 seconds

Largest downtime:    0 seconds
Shortest downtime:    0 seconds
Average downtime:     0 seconds

Current uptime:     8 hours, 35 minutes and 14 seconds   since   09:54:12   Friday 27 May 2016


To display output with date and time

Run the following command to display output with date and time.

user1@linuxhelp:/tmp/tuptime$ sudo tuptime --date=' %H:%M:%S%d-%m-%Y' 
System startups:    1   since   09:54:1227-05-2016
System shutdowns:    0 ok   -   0 bad
System uptime:         100.0 %   -   8 hours, 37 minutes and 16 seconds
System downtime:     0.0 %   -   0 seconds
System life:         8 hours, 37 minutes and 16 seconds

Largest uptime:        8 hours, 37 minutes and 16 seconds   from   09:54:1227-05-2016
Shortest uptime:    8 hours, 37 minutes and 16 seconds   from   09:54:1227-05-2016
Average uptime:     8 hours, 37 minutes and 16 seconds

Largest downtime:    0 seconds
Shortest downtime:    0 seconds
Average downtime:     0 seconds

Current uptime:     8 hours, 37 minutes and 16 seconds   since   09:54:1227-05-2016


Execute this command to print system life as a list.

user1@linuxhelp:/tmp/tuptime$ sudo tuptime --list
Startup:  1  at  09:54:12   Friday 27 May 2016
Uptime:   8 hours, 37 minutes and 37 seconds


To create an alternative database file

The database will be created in a SQLite format.

user1@linuxhelp:/tmp/tuptime$ sudo tuptime --filedb /tmp/tuptime_db.db
System startups:    1   since   09:54:12   Friday 27 May 2016
System shutdowns:    0 ok   -   0 bad
System uptime:         100.0 %   -   8 hours, 38 minutes and 21 seconds
System downtime:     0.0 %   -   0 seconds
System life:         8 hours, 38 minutes and 21 seconds

Largest uptime:        8 hours, 38 minutes and 21 seconds   from   09:54:12   Friday 27 May 2016
Shortest uptime:    8 hours, 38 minutes and 21 seconds   from   09:54:12   Friday 27 May 2016
Average uptime:     8 hours, 38 minutes and 21 seconds

Largest downtime:    0 seconds
Shortest downtime:    0 seconds
Average downtime:     0 seconds

Current uptime:     8 hours, 38 minutes and 21 seconds   since   09:54:12   Friday 27 May 2016

user1@linuxhelp:/tmp/tuptime$ cd /tmp/
user1@linuxhelp:/tmp$ ll
total 72
drwxrwxrwt 16 root  root  4096 May 27 18:32 ./
drwxr-xr-x 23 root  root  4096 Mar 29 16:27 ../
-rw-------  1 user1 user1    0 Mar 29 12:19 config-err-xgRWAe
drwxrwxrwt  2 root  root  4096 Mar 29 12:18 .font-unix/
&hellip 
&hellip 
drwxrwxr-x  6 user1 user1 4096 May 27 18:25 tuptime/
-rw-r--r--  1 root  root  2048 May 27 18:32 tuptime_db.db
-rw-rw-r--  1 user1 user1    0 Mar 29 12:19 unity_support_test.0


Execute this command to order output information.

user1@linuxhelp:/tmp$ sudo tuptime --end --table
No.  Startup Date  Uptime   Shutdown Date   End  Downtime
                                                                                                         
1    09:54:12  Friday 27 May 2016   8 hours, 39 minutes and 11 seconds

To get the uptime information with system kernel

user1@linuxhelp:/tmp$ sudo tuptime --kernel
System startups:    1   since   09:54:12   Friday 27 May 2016
System shutdowns:    0 ok   -   0 bad
System uptime:         100.0 %   -   8 hours, 39 minutes and 37 seconds
System downtime:     0.0 %   -   0 seconds
System life:         8 hours, 39 minutes and 37 seconds
System kernels:     1

Largest uptime:        8 hours, 39 minutes and 37 seconds   from   09:54:12   Friday 27 May 2016
...with kernel:     Linux-4.2.0-16-generic-x86_64-with-Ubuntu-15.10-wily
Shortest uptime:    8 hours, 39 minutes and 37 seconds   from   09:54:12   Friday 27 May 2016
...with kernel:     Linux-4.2.0-16-generic-x86_64-with-Ubuntu-15.10-wily
Average uptime:     8 hours, 39 minutes and 37 seconds

Largest downtime:    0 seconds
...with kernel:     
Shortest downtime:    0 seconds
Average downtime:     0 seconds

Current uptime:     8 hours, 39 minutes and 37 seconds   since   09:54:12   Friday 27 May 2016
...with kernel:     Linux-4.2.0-16-generic-x86_64-with-Ubuntu-15.10-wily


To get the tuptime version

user1@linuxhelp:/tmp$ sudo tuptime --version
tuptime version 3.3.0


Some more options used in the tuptime tool is,

Use " --help" option to view help information

user1@linuxhelp:/tmp$ sudo tuptime --help
Usage: tuptime [options]

Options:
  -h, --help            show this help message and exit
  -c, --ckernel         classify / order by kernel
  --csv                 csv output
  -d DATE_FORMAT, --date=DATE_FORMAT
                        date format output
  -e, --end             order by end state
  -f FILE, --filedb=FILE
                        database file
  -g, --graceful        register a gracefully shutdown
  -k, --kernel          print kernel information
  -l, --list            enumerate system life as list
  -n, --noup            avoid update values
  -o, --offtime         order by offtime / downtime
  -r, --reverse         reverse order
  -s, --seconds         output time in seconds and epoch
  -S SINCE, --since=SINCE
                        restric since this register number
  -t, --table           enumerate system life as table
  --tsince=TIMESTAMP    restrict since this timestamp
  --tuntil=TIMESTAMP    restrict until this timestamp
  -U UNTIL, --until=UNTIL
                        restrict until this register number
  -u, --uptime          order by uptime
  -v, --verbose         verbose output
  -V, --version         show version
  -x, --silent          update values into db without output
Tag : Tuptime
FAQ
Q
What are the various option available in tuptime?
A
Use tuptime --help for it, for more options.
Q
How can I check for the system list of Tuptime?
A
To check for the system list of Tuptime use option "-l, --list " is used for it
Q
Is der any alternatives ?
A
Yes. You can make use of 'Hyper Ping' ' Apex ping' .to monitor Uptime
Q
is it Necessary to navigate to /tmp directory
A
No, You can make use of any local directory
Q
why are you using Sudo command as a prefix for tuptime
A
the exection must be done only as an superuser so either you can switch to Superuser or just use sudo as a prefix