Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I do iftop -i eth1 > out.txt

It does produce the file with "encrypted" UI content such as [(B[)0[[1;80r[[mO[[?7h[[?1h[=[[H[[J[[0;7mO Listening on eth1 [[1;48H[[mO12.5Kb

Is it possible to display this as a web xhtml output somehow?

cat out.txt on my console does produce a normal iftop window but when I do the same thing over the web I get the content above. I understand that it is "managed" on kernel level. Is the task that I want to perform possible?

share|improve this question
up vote 2 down vote accepted

It is probably not practical to grab continuous ncurses output.

You can probably try to get simmilar output with ntop. It's a bit larger and has many other features, and it's "prettier".

share|improve this answer
I get that I can do it well with ntop. But technically is it possible? And if so - which way? – DmitrySemenov May 22 '12 at 23:56
okay I found this here - – DmitrySemenov May 23 '12 at 0:16

What you call "encrypted UI content" is the terminal control codes that instruct the cursor to move to different parts of the screen and change colour. This is what makes the output of iftop look more like a graphical interface and not just scrolling lines of text. Almost all interactive console programs use these terminal codes.

iftop is designed to produce an interactive, "graphical" display, and it doesn't seem possible to turn that off. You could try to parse and remove them, but this requires a detailed knowledge of the length and meaning of each control code, which you can find online but is probably not worth the effort.

You could literally run iftop inside a Javascript terminal emulator that understands these control codes and converts them to HTML, such as Gate One, Shell in a Box or AjaxTerm. It will still look like a console application to the user, but they won't need to install or run an SSH client.

You might want to investigate other tools. pmacct for example can collect information about flows, similar to iftop, and either store it in a SQL database, or an in-memory table which you can query using a command-line tool. This can generate output which you can parse from a web application. netgraph's pmacct server writes this output in JSON, to be interpreted by a javascript client running in a browser and updating live.

You might also be able to hack the iftop source code to return the information you want in a more web-friendly format such as AJAX.

share|improve this answer
iftop -t > out.txt

-t option do the job of removing all terminal code

iftop manual says following:

-t text output mode
      Use text interface without ncurses and print the output to STDOUT.
share|improve this answer
Which version of iftop is that? The newest version on Ubuntu LTS does not have any -t option. – kasperd Dec 23 '15 at 10:02
I am using 15.10 Ubuntu, iftop version is 1.0pre, my iftop manual last update was 2014/01/05. I dont have good internet today otherwise i would have seen git commit and let you know when exactly it was addef – Anshul Dec 24 '15 at 10:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.