Hi, htop author here: this brought a smile to my face! Wondering if I should do the same in htop's own website. Would be fun to follow the activity spike when the new major release comes later this year! Major kudos to the author for the idea!
htop is one of my favorite UNIX tools in existence!
Check out htop running my laptop while I had an "ssh-multi" tmux session opened up on an Apache Spark cluster, doing computation 32 cores x 25 nodes = 800 cluster cores! It's so fun to watch all of those cores light up green while doing a big batch job.
Thanks! Every now and then I want to see individual CPU usage (usually when I want to check if a program is multithreaded) and I Google to find a way to do it.
I always end up doing `sudo apt-get install htop`.
You can make it more efficient by capturing the images to a buffer and rendering a low FPS h264 stream, serving it as HLS fragments and displaying it with hls.js ( https://github.com/dailymotion/hls.js ) as a background element. There is a lot of inter frame compression benefits to be had from this sort of content + it will look more nice with a constant stream of frames. With a low FPS, the CPU usage should be low enough to not be noticeable and also, you can serve a static JPEG as a "preview" when loading the stream in the background for having a background picture on load.
I studied the line
read _ _ sid < <(2>&1 strace -esetsid setsid sh -c "exec $PROGRAM <> /dev/tty2 >&0 2>&1 ")
<( is an example of process substitution, in case anyone is interested. Basically it feeds the stdout of the subshell into the stdin of the read (previous) command.
Here is a detailed explanation:
http://www.tldp.org/LDP/abs/html/abs-guide.html#PROCESS-SUB
Well they could use an ordinary pipe, but they would have to group the later expression in parantheses.
In bash the | creates a fork, so if you try:
echo "sdfsdf" | read sid && echo $sid
you get a blank line,
but if you try:
echo "sdfsdf" | (read sid && echo $sid)
you get "sdfsdf"
|& is an abbreviation for >2&1 | .
In zsh the grouping isn't needed, the expression works out of the box.
Hmm... looks like zsh runs the last element of the pipeline, if a builtin, in the current process. I use the pipe-to-read trick all the time in zsh without even thinking about it.
I wrote a tiny program that captures the content of a Linux virtual console and prints it to stdout.[1] I forgot why I wrote it, but the source code shows how to access foreground color, background color and the font weight.[2] You could hack it to print everything in a format that's easily parsable, write it to a file every second and do the rendering on the client side with JavaScript.
On some old systems, I remember that env vars of other UIDs could be seen, even if you weren't root. I wonder if that's still true for any systems out there.
You would have to parse the VT-100 escape codes to generate the correct html + css (e.g. colors and cursor relocation escape sequences). It is not that straight forward, but on the other hand there are libraries for that.
Great idea! But wouldn't it be best to restrain the output of htop to a few interesting processes that are running without root privileges. It seems to me that it could be possible to bubble up processes that can leak information, especially at startup and when you put the server under load externally...
Not sure I understand why there's 4 nginx processes, 4 php-fpm processes and like 20 mysql processes, why so many, don't you need like 1 (or 4 if there' no pooling)?
That's worker threads, not processes. You can enable tree view in display options, then the worker threads would have been sorta moved to the right to indicate that fact, but that's not a default option.
Processes and threads are basically the same in Linux (except threads share resources, since we're talking about the same mysql "program" is a given that these are 'threads', sorry if I'm imprecise and call everything the same).
I'm no mysql expert but I highly doubt you need more than a few threads (a bunch for the db housekeeping and one per connection), looks like this server is not using pooling. Then again I don't know much about WP and I may be talking out of my behind.
Nice idea although a bit dangerous! I wonder if it would be better to use as background the output of a program like gotty, which streams a terminal's output as a web page.
Interesting, thanks! Probably not as cool, but you could also just get the output of the regular top, parse it and generate HTML from it (a bit like http://tracesof.net/uebersicht/)