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

How to retrieve On-prem resource utilization #2040

Open
leeyiding opened this issue Jul 23, 2024 · 8 comments
Open

How to retrieve On-prem resource utilization #2040

leeyiding opened this issue Jul 23, 2024 · 8 comments

Comments

@leeyiding
Copy link

Hello, I am currently trying to retrieve the resource utilization of on-premise QEMU instances, specifically focusing on CPU and memory usage.

  1. The results obtained using standard commands like ps are often inaccurate.
  2. I attempted to use QMP to get memory usage by executing the command {"execute": "query-balloon"}, but I encountered an error: {'error': {'class': 'DeviceNotActive', 'desc': 'No balloon device has been activated'}}.
  3. So far, I haven't found a reliable method to measure CPU usage.

Any assistance or guidance on how to accurately measure these resource utilizations would be greatly appreciated.

@eyberg
Copy link
Contributor

eyberg commented Jul 23, 2024

is there a particular language you are using as most will have ways of getting at this info - in c something like

unsigned long mem_avail() {
  struct sysinfo info;

  if (sysinfo(&info) < 0)
    return 0;

  return info.freeram * info.mem_unit;
}

would work

@leeyiding
Copy link
Author

Thanks for your reply. This code looks like it is executed in Nanos to get the system free memory. If I want to get Nanos related information in the host machine, similar to the metrics provided to the cloud platform, how can I do it?

@eyberg
Copy link
Contributor

eyberg commented Jul 23, 2024

yes, you need to export your metrics through an agent; most people have a preferred apm vendor or the cloud metrics as you suggest, there is also radar which does memory && disk by default: https://docs.ops.city/ops/klibs#radar

we could look at adding some sort of optional flag or something for ops for local instances

@eyberg
Copy link
Contributor

eyberg commented Jul 23, 2024

fyi, i added a WIP for mem metrics via balloon in ops here: https://github.com/nanovms/ops/tree/balloon

@leeyiding
Copy link
Author

Looks good, is there any way to get CPU utilization?

@eyberg
Copy link
Contributor

eyberg commented Jul 24, 2024

if asking about outside the guest you could use your normal tools but inside - i'm not quite sure what we would do there since it's single process and you aren't showing the share of utilization amongst everything else (such as ubuntu where you might have a few hundred processes running) - i know several apm vendors have thread utilization that you might look into

@francescolavra
Copy link
Member

@leeyiding if you are looking for a host-side tool to measure CPU utilization that is more accurate than ps, I would suggest you give a try to the perf tool (https://perf.wiki.kernel.org/index.php/Tutorial): you can attach it to a Qemu process and trace the "instructions" events, whose count will give you a pretty accurate measure of how much CPU the VM instance uses.

@leeyiding
Copy link
Author

@leeyiding if you are looking for a host-side tool to measure CPU utilization that is more accurate than ps, I would suggest you give a try to the perf tool (https://perf.wiki.kernel.org/index.php/Tutorial): you can attach it to a Qemu process and trace the "instructions" events, whose count will give you a pretty accurate measure of how much CPU the VM instance uses.

Thanks for the suggestion, I'll try it

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

3 participants