htop isn't returning CPU or memory usage!?
I think that top is great application to monitor a Linux system. I really like it, but top doesn't look so good on Mac. I know that Mac have a system monitor to do it, but I prefer using a terminal.
I have installed htop by running:
brew install htop
.
Here is what it looks like:
PID USER PRI NI VIRT RES SHR S CPU% MEM% TIME+ Command
1 0 0 0 0 0 0 ? 0.0 0.0 0:00.00 (launchd)
10 0 0 0 0 0 0 ? 0.0 0.0 0:00.00 (kextd)
11 0 0 0 0 0 0 ? 0.0 0.0 0:00.00 (UserEventAgent)
12 65 0 0 0 0 0 ? 0.0 0.0 0:00.00 (mDNSResponder)
The problem is that both CPU and MEM aren't returning the real values of either on my system.
Has anyone else experienced this? Or, could some one point me in the right direction?
Solution 1:
I have the same problem so I check the recipe.
$ brew edit htop
Then I check this part of the recipe:
def caveats; <<-EOS.undent
For htop to display correctly all running processes, it needs to run as root.
If you don't want to `sudo htop` every time, change the owner and permissions:
cd #{bin}
chmod 6555 htop
sudo chown root htop
EOS
So just type sudo htop
and you will see CPU and MEM.
Solution 2:
From my brew info:
You can either run the program via `sudo` or set the setuid bit:
sudo chown root:wheel /usr/local/Cellar/htop-osx/0.8.2.2/bin/htop
sudo chmod u+s /usr/local/Cellar/htop-osx/0.8.2.2/bin/htop
This worked to ensure that I don't need to run htop as sudo
Solution 3:
Here is an alternative for those who don't want to muck with the permissions and still avoid typing sudo htop
in preference to just htop
:
- Install with brew:
brew install htop
- Allow
sudo htop
to run without sudo password- Run
sudo visudo
to open the sudoers file in an editor - Add this to the config file:
%admin ALL=(ALL) NOPASSWD: /usr/local/bin/htop
- Save the file and exit (
:wq
most likely)
- Run
- Add the following alias to your shell rc file (example is for
~/.bashrc
or~/.profile
):alias htop='sudo htop'