Every developer is familiar with tail – tool used to display the last lines – or tail – of the file. Of course most popular usage of this command is:
tail -f /var/log/uwsgi.log
…which displays continuously updates to the file. Every time new line is appended (i.e. to the log file), it is also printed to the screen. It is useful, when one wants to monitor log files in the real time to see the progress of some action or to look for errors in the application.
Recently, I had to monitor four application servers at once. At every one of them there was the same application. To monitor logs, I had to open four ssh sessions and then run four tail commands. I had to switch to such log monitoring once every few hours, so it started to be tiring. After short search, I found the most useful tool since tail – multitail. It allows you to tail multiple files at once – in many different configurations. Multitail not only is capable of displaying the log files, but also filtering them, adding some lines, etc. Just look at the list of the features.
So with multitail, monitoring four logfiles on remote machines is as easy as:
[email protected]:~$ multitail -s 2 \
-l "ssh pr_app1 tail -f /var/log/uwsgi.log" \
-l "ssh pr_app2 tail -f /var/log/uwsgi.log" \
-l "ssh pr_app3 tail -f /var/log/uwsgi.log" \
-l "ssh pr_app4 tail -f /var/log/uwsgi.log"
(where pr_app[1-4] are different hosts, defined in my .ssh/config file and “\” denotes line break, for easier reading).
Result is very similar to this: