I am looking for an option to programmatically get the System CPU usage % and Individual application CPU % as shown in the Task Manager.
The use case is to monitor the application performance and take action if memory or CPU usage crosses the threshold limit. I am able to get the memory usage through the "Tasklist" Command line.
I explored on few options and most of it points to Processor time using counters from the performance monitor. I am also not able to get an exact relation/formula to compute CPU utilization % from processor time.
Attaching links explored,
Please let me know if anyone has prior experience or any thoughts on this.
If you only need the CPU load, you could try this:
You can also get memory usage with the same node.
This doesn't separate it by process though, and as you see it returns a value for each thread (so 12 on my 6-core laptop).
For specific processes, you might try the .NET PerfMon interface/tool: https://forums.ni.com/t5/Example-Code/Performance-Monitor-Using-LabVIEW/ta-p/3501988
Thanks Cbutcher for your reply,
I did look at the Resource monitor example shipped with LabVIEW and was not sure how to compute CPU total % as adding up all is higher than 100 and Average doesn't match with the task manager value. Let me know if you have any insights on this.
I know this is a somewhat old thread, but I've been looking for a solution for CPU utilization for some time. I had a 32bits DLL (processHandles.dll) that worked exactly as I wanted, but I've moved to 64 bits Labview and can't use it anymore. It allowed to check resources for a specific task, and I used it to save memory and processor usage to disk. I've found a way to read memory using .NET calls, but the processor usage per task is not the same as windows task manager. Does anyone have a solution for this?