7

I am connecting to my Raspberry Pi 4 over SSH. Although I see iftop on all captures as having a nice frame, mine shows 'b' characters instead of lines. The curious thing is, the corner pieces and all other output is shown nicely. Is this something to do with my SSH client built into OS X? Is it a bug in iftop?

Screen capture of iftop process over SSH

Screen capture of iftop process over SSH

phuclv
  • 30,396
  • 15
  • 136
  • 260

5 Answers5

6

Check the env variable TERM ( echo $TERM ). tmux and friends set it to 'screen' or something similar which might be unknown to the ncurses library. This runtime library is used by iftop to draw decorations and ascii windows.

Set it to something iftop accepts and call up iftop:

TERM=xterm iftop

You can set an environment variable in the commandline like above and it will only be used for this invocation of 'iftop'. That's an easy way to test.

If you're on OSX you might use xterm-256color, same for linux with xcfe-terminal running. I'm using good ol' /usr/bin/xterm, so TERM=xterm works for me.

To see all possible terminals just use toe the "table of (terminfo) entries".

Further man/google keywords: ncurses, terminfo, tic, ls -l /usr/share/terminfo/?/*

wwwutz
  • 76
3

None of these suggestions for trying alternate TERM types seem to work on Ubuntu 20.x and 21.x either at the text console or via SSH (no X on my server). However, changing LANG did the trick:

LANG=C iftop
OAreaMan
  • 131
  • 2
1

iftop uses the VT100 "Special Graphics" alternate character set mode to display these box-drawing characters – it doesn't use plain Unicode symbols. (Technically ncurses manages the screen and all drawing, but iftop seems to be specifically asking for ACS characters, so even if $NCURSES_NO_UTF8_ACS is active it still doesn't force UTF-8 usage.)

The way it works is that \e(0 switches to the alternate characters; ordinary ASCII letters like qwqvqk are drawn as symbols like └─┬─┴─┐, and finally \e(B switches back to normal characters.

But I don't know why this problem would affect only some graphics, as normally iftop prints the entire line at once – there doesn't seem anything that would force the terminal to switch back to ASCII mid-way through. It might be caused by whatever ncurses and/or iftop version is used on the server.

(When you use tmux/Mosh/Screen, they act as terminal emulators on their own and internally translate ACS to Unicode when receiving data from the program, so Terminal.app receives a "cleaned up" version of what iftop tried to send, smoothing out the impedance mismatch.)

grawity
  • 501,077
0

This works for me:

vim  ~/.bashrc

add this line:

alias iftop='export NCURSES_NO_UTF8_ACS=1 && iftop $@'

then

sysctl -p
Sonic
  • 1
0

The last one works on OpenWRT 22.03.3. Nothing else worked. Sorry it's 2023 now. But I had this problem. export NCURSES_NO_UTF8_ACS=1. I put it in my shell script to run IFTOP.

In OpenWRT, version mentioned above, in SSH session.

#!/bin/bash
if [ -z $1 ]; then
        echo "usage $0 <interface>"
        exit 1
else
        # The below needed, or else lines are letters like qqqqqqqq
        export NCURSES_NO_UTF8_ACS=1
                iftop -i $1
fi