Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting all the memory and the cpu usage! #6

Open
ihamieh opened this issue Jan 6, 2021 · 6 comments
Open

Not getting all the memory and the cpu usage! #6

ihamieh opened this issue Jan 6, 2021 · 6 comments

Comments

@ihamieh
Copy link

ihamieh commented Jan 6, 2021

hi
when i run the program, this is my output:
7H:~/PycharmProjects/cpu_monitor-master$ python monitor.py
[INFO] [1609940542.760856]: [cpu monitor] adding new node /cpu_monitor
[INFO] [1609940542.769134]: [cpu monitor] adding new node /rosout
[INFO] [1609940542.777597]: [cpu monitor] adding new node /Mono

I'm not getting any of the memory information or any other information about the program i'm running! Is there something that I have to modify in the program?

thanks,

@alspitz
Copy link
Owner

alspitz commented Jan 16, 2021

The CPU and memory information are published on ROS topics. You should be able to see them if you run rostopic list and e.g. rostopic echo /cpu_monitor/Mono/mem. Does this help?

@leojaie
Copy link

leojaie commented Jan 26, 2022

Hi,
Thank you for the code.
The nodes data information works well. However I have total cpu informations only on /cpu_monitor/total_cpu topic. Nothing on the rest of the total_xxx topics.
I am running my code on RPi4.
Do you have any idea about this issue.
Thanks

@alspitz
Copy link
Owner

alspitz commented Jan 26, 2022

The code uses the entries of psutil.virtual_memory() to create the total memory topics. I'm not sure, but they may be named differently or not there on the Raspberry Pi 4.

If you run psutil.virtual_memory() in a separate python process, what do you get?

If there are names in the output that don't show up when you run the node, then you can add them to https://github.com/alspitz/cpu_monitor/blob/master/monitor.py#L50.

The documentation for virtual_memory is here (https://psutil.readthedocs.io/en/latest/#psutil.virtual_memory) so if it doesn't return the right values, consider filing an issue with psutil.
Maybe there's a better way to grab memory usage on the Raspberry Pis but I'm not super familiar with it.

@apalapramanik
Copy link

what is the unit of memory here?
i did: rostopic echo /cpu_monitor/node_name/mem and got data: 657272832

@alspitz
Copy link
Owner

alspitz commented Oct 7, 2022

what is the unit of memory here? i did: rostopic echo /cpu_monitor/node_name/mem and got data: 657272832

The memory values are grabbed directly from psutil's output of memory_info (https://psutil.readthedocs.io/en/latest/#psutil.Process.memory_info), so all are in bytes.

@alspitz
Copy link
Owner

alspitz commented Jul 16, 2023

Hi, Thank you for the code. The nodes data information works well. However I have total cpu informations only on /cpu_monitor/total_cpu topic. Nothing on the rest of the total_xxx topics. I am running my code on RPi4. Do you have any idea about this issue. Thanks

@leojaie Actually there was a bug after the conversion to Python 3 where these system-wide memory topics would not get published and that sounds exactly like what you described. Sorry about that. Should be fixed by ab3ec38.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants