0

I'm attempting to show the hostname above htop output, in order to better identify which server its monitoring. I haven't found a good way to do this, but the closest I've gotten is with the command:

watch --color -t "hostname; echo q | htop"

Unfortunately, due to how watch interprets special characters, it renders slightly mangled output like:

enter image description here

It looks like watch is corrupting the newline, tab and carriage return characters. I think I could potentially correct this via a Python or Bash script, but I'm having trouble making sense of the escape syntax. All the special characters seem to be rendered as "(B" followed by 0 to 4 numbers. However, for characters that should be the same, such as what should be new lines after each process row, the escaped character uses a completely different code. For example "(B3263" and "(B3264".

How do I interpret these numbers and convert them back to the correct characters while preserving the color?

Cerin
  • 60,957
  • 96
  • 316
  • 522
  • 2
    You seem to put a lot of effort into a solution for a problem most terminal applications solve by putting the hostname into the window and / or the tab label. – Klaus D. Dec 17 '17 at 03:47
  • @Cerin – You can control delay with `-d --delay=DELAY` and add hostname with `F2 (setup)` then just select `Hostname` from *Available meters*. Is `watch` necessary here? – Travis Clarke Dec 17 '17 at 03:55
  • @KlausD. Ah, yes, I probably should have mentioned I'm running this inside tmux/tmuxinator, which obscure the window/tab title. – Cerin Dec 18 '17 at 06:02
  • @TravisClarke, Interesting, that's good to know. I didn't realize that could be selected. – Cerin Dec 18 '17 at 06:08

0 Answers0