Home Command line utilities How To Monitor Linux System Uptime Using Uptimed

How To Monitor Linux System Uptime Using Uptimed

By sk
Published: Last Updated on 4.6K views

A while ago, we discussed how to find Linux system uptime using Tuptime utility on Linux. Today, we are going to learn about a similar utility named Uptimed. It is a command line utility used to record and keep track of a Linux system up times. Using Uptimed, we can easily display a summary of historical uptime records, such as how long your Linux system has been up, what is the highest uptime, when the system has been rebooted etc. In this brief guide, let us see how to monitor Linux system uptime using Uptimed utility.

Install Uptimed On Linux

Uptimed is available in the official repositories of popular Linux operating systems.

To install Uptimed on Arch Linux, simply run:

$ sudo pacman -S uptimed

On Debian, Ubuntu, Linux Mint:

$ sudo apt-get install uptimed

Please note that on Ubuntu and its derivatives, make sure enabled [universe] repository.

$ sudo add-apt-repository universe

On Fedora:

$ sudo dnf install uptimed

On CentOS 7:

Uptimed is not available in the default repositories of CentOS. So, you need to enable EPEL repository in-order to install it.

Enable EPEL repository:

$ sudo yum install epel-release

And then install Uptimed using command:

$ sudo yum install uptimed

On other Linux systems, download Uptimed from the releases page and then compile and install it manually.

# wget https://github.com/rpodgorny/uptimed/archive/v0.4.2.zip -O uptimed.zip
# unzip uptimed.zip
# cd uptimed-0.4.2/
# ./configure
# make
# make install

After installing Uptimed, enable and start uptimed service:

# systemctl enable uptimed
# systemctl start uptimed

Check status of the uptimed service:

# systemctl status uptimed
● uptimed.service - Uptime record tracking daemon
   Loaded: loaded (/usr/lib/systemd/system/uptimed.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-02-11 14:21:12 IST; 1s ago
     Docs: man:uptimed(8)
           man:uprecords(1)
 Main PID: 1435 (uptimed)
   Status: "Next milestone (five days) at Sun Feb 16 14:13:59 2020"
   CGroup: /system.slice/uptimed.service
           └─1435 /usr/sbin/uptimed -f

Feb 11 14:21:12 server.ostechnix.local systemd[1]: Starting Uptime record tracking daemon...
Feb 11 14:21:12 server.ostechnix.local systemd[1]: Started Uptime record tracking daemon.

Monitor Linux System Uptime Using Uptimed

To monitor a Linux system's uptime between system reboots, simply run:

# uprecords

Sample output:

     #               Uptime | System                                     Boot up
----------------------------+---------------------------------------------------
     1     0 days, 02:35:51 | Linux 3.10.0-1062.1.1.el  Tue Feb 11 14:22:33 2020
     2     0 days, 00:07:27 | Linux 3.10.0-1062.1.1.el  Tue Feb 11 14:13:59 2020
->   3     0 days, 00:02:11 | Linux 3.10.0-1062.1.1.el  Tue Feb 11 17:02:29 2020
----------------------------+---------------------------------------------------
1up in     0 days, 00:05:17 | at                        Tue Feb 11 17:09:56 2020
no1 in     0 days, 02:33:41 | at                        Tue Feb 11 19:38:20 2020
    up     0 days, 02:45:29 | since                     Tue Feb 11 14:13:59 2020
  down     0 days, 00:05:12 | since                     Tue Feb 11 14:13:59 2020
   %up               96.953 | since                     Tue Feb 11 14:13:59 2020

Monitor Linux System Uptime Using Uptimed

Here, the arrow mark in the first column indicates the most recent uptime.

Sort result by boottime

To display your Linux system uptime sorted by boottime, use -b flag:

# uprecords -b
     #               Uptime | System                                     Boot up
----------------------------+---------------------------------------------------
     1     0 days, 00:07:27 | Linux 3.10.0-1062.1.1.el  Tue Feb 11 14:13:59 2020
     2     0 days, 02:35:51 | Linux 3.10.0-1062.1.1.el  Tue Feb 11 14:22:33 2020
->   3     0 days, 00:30:14 | Linux 3.10.0-1062.1.1.el  Tue Feb 11 17:02:29 2020

Similarly, to reverse sort by boottime (i.e. show only the most recent reboots), use -B flag:

# uprecords -B
     #               Uptime | System                                     Boot up
----------------------------+---------------------------------------------------
->   1     0 days, 00:14:51 | Linux 3.10.0-1062.1.1.el  Tue Feb 11 17:02:29 2020
     2     0 days, 02:35:51 | Linux 3.10.0-1062.1.1.el  Tue Feb 11 14:22:33 2020
     3     0 days, 00:07:27 | Linux 3.10.0-1062.1.1.el  Tue Feb 11 14:13:59 2020

Display X number of uptimes

When running uprecords command without any options, it will display a summary of the top 10 historical uptime records by default. You can, however, change this using -m flag. For example, the following command will display the top 20 records:

# uprecords -m 20

Don't truncate output

As you noticed in the above output, the Linux kernel version information in the system column has been truncated (i.e. Linux 3.10.0-1062.1.1.el). If you don't want to truncate the information, use -w (wide output) flag.

# uprecords -w
     #               Uptime | System                                     Boot up
----------------------------+---------------------------------------------------
     1     0 days, 02:35:51 | Linux 3.10.0-1062.1.1.el7.x86_64  Tue Feb 11 14:22:33 2020
->   2     0 days, 00:16:35 | Linux 3.10.0-1062.1.1.el7.x86_64  Tue Feb 11 17:02:29 2020
     3     0 days, 00:07:27 | Linux 3.10.0-1062.1.1.el7.x86_64  Tue Feb 11 14:13:59 2020
----------------------------+---------------------------------------------------
no1 in     0 days, 02:19:17 | at                        Tue Feb 11 19:38:21 2020
    up     0 days, 02:59:53 | since                     Tue Feb 11 14:13:59 2020
  down     0 days, 00:05:12 | since                     Tue Feb 11 14:13:59 2020
   %up               97.190 | since                     Tue Feb 11 14:13:59 2020

Display downtime

You can also display the downtime between reboots instead of the kernel version using -d flag like below:

# uprecords -d
     #               Uptime |        Last downtime                       Boot up
----------------------------+---------------------------------------------------
     1     0 days, 02:35:51 |     0 days, 00:01:07      Tue Feb 11 14:22:33 2020
->   2     0 days, 00:13:02 |     0 days, 00:04:05      Tue Feb 11 17:02:29 2020
     3     0 days, 00:07:27 |     0 days, 00:00:00      Tue Feb 11 14:13:59 2020
----------------------------+---------------------------------------------------
no1 in     0 days, 02:22:50 | at                        Tue Feb 11 19:38:21 2020
    up     0 days, 02:56:20 | since                     Tue Feb 11 14:13:59 2020
  down     0 days, 00:05:12 | since                     Tue Feb 11 14:13:59 2020
   %up               97.136 | since                     Tue Feb 11 14:13:59 2020

Uprecords has a few more options. To display all options with description, run:

# uprecords -?
usage: uprecords [OPTION]...

  -?             this help
  -a             do not print ansi codes
  -b             sort by boottime
  -B             reverse sort by boottime
  -k             sort by sysinfo
  -K             reverse sort by sysinfo
  -d             print downtime seen before every uptimes instead of system
  -c             do not show current entry if not in top entries
  -f             run continously in a loop
  -s             do not print extra statistics
  -w             wide output (more than 80 cols per line)
  -i INTERVAL    use INTERVAL seconds for loop instead of 5, implies -f
  -m COUNT       show a maximum of top COUNT entries instead of 10
  -M             show next milestone
  -v             version information

For more details, refer man pages.

$ man uprecords

Resource:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More