aristocratos / bashtop

Linux/OSX/FreeBSD resource monitor
Apache License 2.0
10.79k stars 552 forks source link

[BUG] CPU usage not showing as normal user, needs su access #170

Closed freijon closed 4 years ago

freijon commented 4 years ago

Describe the bug

Since a week or two the CPU usage doesn't display correctly anymore. All processes owned by user root or portage have 0.0% Cpu, both with cpu_responsive and cpu_lazy. Only processes owned by the same user show a percentage. This used to work before, not sure what changed...

Expected behavior

It should show all percentages, not only for processes owned by the same user.

Info (please complete the following information):

aristocratos commented 4 years ago

Sounds like an issue with user privileges. Does it work like normal if running sudo bashtop? I know this is an issue on OSX but I haven't seen in on Linux before.

Does the user you are running as have administrator rights?

aristocratos commented 4 years ago

Did you upgrade kernel since it worked like normal? Could possibly be new kernel security features in that case.

freijon commented 4 years ago

Yes, I upgraded the kernel from 5.7.6 to 5.7.7 (and I remember that it also didn't work with 5.7.7) and now to 5.7.8. Unfortunately I already deleted the 5.7.6 kernel so I can't boot it up and test :( I don't have sudo installed but if I run bashtop as root I am able to see all process CPU usages from all users, not only from root.

aristocratos commented 4 years ago

Check your /etc/fstab and see if you have hidepid= under the /proc entry.

Restricting access to PID directories

procfs provides the hidepid mount option to restrict access to the /proc/<pid> directories by other users. This is a hardening technique that can make it more difficult for malicious local users to gather information about the processes of other users[2]. 

hidepid=0 | The file located in /proc/<pid>/* will be world readable. This is the default behavior.
hidepid=1 | The /proc/<pid> directories are visible by all users, but users can only access the /proc/<pid> directories they own. This will protect files such as /proc/<pid>/cmdline, which may contain sensitive information.
hidepid=2 | Same as hidepid=1 but the /proc/<pid>  directories of other users are hidden. Since this will hide process  information from all users except root, it may be useful to allow access  to privileged users such as those belonging to the wheel group.

From https://wiki.gentoo.org/wiki/Procfs

freijon commented 4 years ago

I figured out what went wrong and it seems to be my mistake. I deleted the .config/bashtop folder and let the app create a new one. After that it worked just fine. I then did a diff of the two configs and it turns out I must have set "proc_reversed" to true by mistake. Like that it just showed 0.0% for all processes (I never scrolled to the bottom to notice that at the bottom there are a few non-zero processes).

Anyway... I'm sorry to have wasted your time!

aristocratos commented 4 years ago

No problem. The default is set to not reversed, but you could have hit the "r" key without noticing which would reverse the order. However that should be indicated by "reversed" being underlined in the processes box titlebar.

freijon commented 4 years ago

You're right, I'm pretty sure that's what happened. I might have picked it up if it would have been visible. Unfortunately I use bashtop in a splitted terminal (98x51) and like this the "reversed" part is hidden because there is not enough horizontal space... Anyway, I'm happy to have it back working now :)