Multitail – monitor multiple log files with tail on steroids

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:

Multitail example.

Getting started with PHP templating

Recently in Smashing Magazine I published the article about templating in the PHP:

In this article, we’ll cover how to separate the view of your PHP application from its other components. We’ll look at why using such an architecture is useful and what tools we can use to accomplish this. Here’s what we’ll cover:

  1. Learn some basic MVC concepts,
  2. Review some popular templating libraries,
  3. Play around with a small custom-made view class.
  4. Explore the basics of using the Twig library.

Click here to read the article.

Sample code for the article is available as a mercurial repository.

How to sue fraudulent internet auction seller (and win)

I invite all Polish-speaking visitors to check out my new website www.pozew-cywilny.pl (civil action/lawsuit under the Polish civil law), where I put my tips on how to sue fraudulent internet auction seller and win your money back (with interest). This tutorial is based on my true, successful story and features examples of official documents, ideas for investigation, etc.