cpu_monitor icon indicating copy to clipboard operation
cpu_monitor copied to clipboard

Not getting all the memory and the cpu usage!

Open ihamieh opened this issue 4 years ago • 6 comments

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,

ihamieh avatar Jan 06 '21 13:01 ihamieh

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?

alspitz avatar Jan 16 '21 04:01 alspitz

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 avatar Jan 26 '22 13:01 leojaie

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.

alspitz avatar Jan 26 '22 22:01 alspitz

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

apalapramanik avatar Oct 03 '22 21:10 apalapramanik

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 avatar Oct 07 '22 06:10 alspitz

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 https://github.com/alspitz/cpu_monitor/commit/ab3ec3858d84384d8383bf0f6ea90f6dbb62f42f.

alspitz avatar Jul 16 '23 02:07 alspitz