MultiTail – Monitor Multiple Files Simultaneously in a Single Linux Terminal

[‘

n

Whether it’s a server administrator or a programmer some time we need to refer multiple logfiles for effectively troubleshooting tasks. To achieve this we have to open, tail or less a each logfile in a different shell. However, we can use traditional tail command like tail -f /var/log/messages or tail -f /var/log/secure in a single line. But if we want to see multiple files in a real-time we need to install a specific tool called MultiTail.

n

What is MultiTail?

n

MultiTail is an open source ncurses utility that can be used to display multiple logfiles to standard output in a single window or a single shell that shows last few lines of logfiles in a real-time like tail command which split console into more subwindows (much like screen command). It also supports color highlighting, filtering, adding and deleting windows and much more.

n

Features

n

    n

  1. Multiple input sources.
  2. n

  3. Color display using Regular Expression in the case of important informations.
  4. n

  5. Line filtering.
  6. n

  7. Interactive Menus for deleting and adding shells.
  8. n

n

Here is an example screen grab of MultiTail in action.

n

Install MultiTail in Linux
MultiTail View

n

Installation of MultiTail in Linux

n

To get MultiTail on Red Hat based distributions, you must turn on EPEL repository and then run the following command on the terminal to install it.

n

On RHEL/CentOS/Fedora

n

# yum install -y multitail

n

On Debian/Ubuntu/Linux Mint

n

$ sudo apt-get updatern$ sudo apt-get install multitail

n

Usage of MultiTail

n

By default MultiTail does the same thing as ‘tail -f‘, i.e. view files in a real time. To view/monitor two different files in one window, the basic syntax is:

n

1. How To View 2 Files in Single Window

n

[emailxa0protected]:~# multitail /var/log/apache2/error.log /var/log/apache2/error.log.1

n

View Two Files in Linux
View Two Files in Linux

n

To scroll through the files, hit ‘b‘ and select the file you want from the list.

n

File Selection
File Selection

n

Once, you select the file, it will show you last 100 lines of that selected file, to scroll through use the cursor keys. You can also use ‘gg‘/’G‘ to move to the top/bottom of the scroll window. If you want to view more lines, hit ‘q’ to exit and hit ‘m‘ to enter a new value for the number of lines to view.

n

View File
View File

n

2. How To View 2 Files in 2 Columns

n

The following command will display two different files in 2 columns.

n

[[emailxa0protected] ~]# multitail -s 2 /var/log/mysqld.log /var/log/xferlog

n

View Files in 2 Columns
View Files in 2 Columns

n

3. How To View Multiple Files in Multiple Columns

n

Display 3 files in three columns.

n

[[emailxa0protected] ~]# multitail -s 3 /var/log/mysqld.log /var/log/xferlog /var/log/yum.log

n

View Files in 3 Columns
View Files in 3 Columns

n

4. Merge/View Multiple Files in Multiple Columns

n

Displays 5 logfiles while merging 2 files in one column and keep 2 files in two columns with only one in the left column.

n

[[emailxa0protected] ~]# multitail -s 2 -sn 1,3  /var/log/mysqld.log -I /var/log/xferlog /var/log/monitorix /var/log/ajenti.log /var/log/yum.log

n

Multiple View Files
Multiple View Files

n

5. How to View File and Execute a Command

n

Shows 1 file while ‘-l‘ option allows command to execute in a window.

n

[[emailxa0protected] ~]# multitail /var/log/iptables.log -l "ping server.nixcraft.in"

n

Run Command and View File
Run Command and View File

n

6. How to Merge/View Two Files in Different Color

n

Merge 2 logfiles in one window, but give different color to each logfile so that you can easily understand what lines are for what logfile.

n

[[emailxa0protected] ~]# multitail -ci green /var/log/yum.log -ci yellow -I /var/log/mysqld.log

n

View Files in Color
View Files in Color

n

Conclusion

n

We’ve only covered few basic usage of multitail command. For a complete list of options and keys you can look at the man page of multitail or you may press ‘h‘ key for help while the program runs.

n

‘]