Hot answers tagged htop
9
I use this script (from this thread on the Arch boards):
#!/bin/bash
read cpu a b c previdle rest < /proc/stat
prevtotal=$((a+b+c+previdle))
sleep 0.5
read cpu a b c idle rest < /proc/stat
total=$((a+b+c+idle))
CPU=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) ))
7
F1 or h will show you the legend.
It looks like in this color scheme:
CPU:
blue is for low priority threads
green is normal priority threads
black is for io-wait
see below for more.
Memory:
green is memory in use
blue is buffer
orange is cache
5
Check out sar, as well. Implementations can vary widely from nix to nix, but it should give you basic system stats, at given snapshots. I'm not sure how accurate the values are at the point at which the command is first initialized, but you might play around to see how it compares to top, iostat, etc.
The output is column-based, like top, so you should be ...
3
This sort of inconsistency is usually indicative of high processor usage by kernel threads, which aren't displayed in htop by default. To display them, in htop go to Setup, then Display options, and then uncheck Hide kernel threads. This should allow you to see the thread(s) that are responsible.
You can also disable this behaviour by setting ...
3
From man htop:
INTERACTIVE COMMANDS
Space
Tag or untag a process. Commands that can operate on multiple processes, like "kill", will then apply over the list of
tagged processes, instead of the currently highlighted one.
U Untag all processes (remove all tags added with the Space key).
F9, k
"Kill" process: sends a ...
3
A complete re-write of my previous post. Got a bit curious and checked out further.
In short: the reason for the difference is that openSUSE uses a patched version of top and free that adds some extra values to `cached'.
A) Standard version
top, free, htop, ...:
Usage is calculated by reading data from /proc/meminfo:
E.g.:
#free:
Row Column | ...
2
Don't you have colors?
Green Blue Orange
Mem[|||||||||||||||||||||||||||||||||||||||||||| 1978/7847MB]
Where green should be 1978 MiB.
Else you can enter F2 -> Under setup stay on "Meters" -> Right arrow to get to "Left column". -> Down 1 to get to "Memory Bar".
Then press enter to view various ways of display.
When it comes to ...
1
You could hijack htop's s command. In htop, pressing s invokes strace -p <the-pid-of-the-selected-process>.
Then what you could do is create a strace command that contains something like:
#! /bin/sh -
pids=$(ps -eo pid= -o ppid= |
awk -v exclude="$PPID" -v pid="$2" '
function descends(p) {
if (p == exclude) return 0
if (p == pid) ...
1
From the htop manpage:
F5, t
Tree view: organize processes by parenthood, and layout the relations between them as a tree. Toggling the key will switch between tree and your previously selected sort view. Selecting a sort view will exit tree view.
So hit F5, and you may have to then hit 't'. That'll let you kill the entire tree.
1
You could run top in batch mode -b with 1 iteration -n1. You grep it, pipe it to awk, SUM the result and print it.
top -b -n1 | grep chrome | awk '{ SUM += $9} END { print SUM }'
I don't know which column you want to output. Change $9 to fit your needs.
Only top voted, non community-wiki answers of a minimum length are eligible


