How to correctly get the percentage of CPU being used by the process
I try to get the % CPU used by process under windows with Qt/C++. First to get a list of running processes and after that, for each process, I try to get the CPU used, for most of the processes that the result seems valid (they correspond with the windows Task Manager), but with the process of AIDA64 (running a CPU in the background stress test), I got strange as 312% values what is the problem with my code c ++?
sigar_t *sigarproclist;
sigar_proc_list_t proclist;
sigar_open(&sigarproclist);
sigar_proc_list_get(sigarproclist, &proclist);
for (size_t i = 0; i < proclist.number; i++)
{
sigar_proc_cpu_t cpu;
int status1 = sigar_proc_cpu_get(sigarproclist, proclist.data[i], &cpu);
if (status1 == SIGAR_OK)
{
Sleep(50);
int status2 = sigar_proc_cpu_get(sigarproclist, proclist.data[i], &cpu);
if (status2 == SIGAR_OK)
{
sigar_proc_state_t procstate;
sigar_proc_state_get(sigarproclist, proclist.data[i], &procstate);
qDebug() << procstate.name << cpu.percent * 100 << "%";
}
}
}
sigar_close(sigarproclist);
You may need to scale (divide) by the number of cores. This is the sigar code uses on windows to deliver the cpu process:
SIGAR_DECLARE(int) sigar_proc_time_get(sigar_t *sigar, sigar_pid_t pid, sigar_proc_time_t *proctime) { HANDLE proc = open_process(pid); FILETIME start_time, exit_time, system_time, user_time; int status = ERROR_SUCCESS; if (!proc) { return GetLastError(); } if (!GetProcessTimes(proc, &start_time, &exit_time, &system_time, &user_time)) { status = GetLastError(); } CloseHandle(proc); if (status != ERROR_SUCCESS) { return status; } if (start_time.dwHighDateTime) { proctime->start_time = sigar_FileTimeToTime(&start_time) / 1000; } else { proctime->start_time = 0; } proctime->user = FILETIME2MSEC(user_time); proctime->sys = FILETIME2MSEC(system_time); proctime->total = proctime->user + proctime->sys; return SIGAR_OK; }
The doc of api windows indicates the time here is a sum on all threads and must therefore be reduced by the number of cores.
We had something like this in our use of links Java the 1.6.4 release of SIGAR. I'm curious to know if it works for you.
Best,
Vishal
Tags: VMware
Similar Questions
-
How can I get the ePrint android app to print on the correct printer?
My home network is a HP OfficeJet Pro 8500 A909 connected to the network wired (not wireless), and which is NOT active ePrint (I understand it does not support ePrint).
The network also has a HP OfficeJet 7500 has yet once connected to the network by wire (not wireless) and what ePrint IS activated.
Both printers are on my network 192.168.1.x behind a router, but not a proxy with separate IP addresses.
If I send a print by the 7500 ePrint a email address, he goes out on the printer correct (7500).
But If I print using the HP ePrint home & Biz Android app that shows to the 7500 a print out immediately on the 8500 - the incorrect printer. The app shows the type of printer as 8500, although she still bears the name of 7500 a correct.
So I have 3 questions:
- How could I get the ePrint initiated by app printed to reach the 7500 a?
I like the idea that it is possible to reach the 8500 and 7500 a remotely (when I discovered ePrint after buying the 7500 a I checked if the 8500 supported that to find it does not work). But, if I wanted to keep accidental remote printing to the 8500 then...
- How can I print on the 8500 email? (Remember, emailed still prints go to the 7500).
- How can I add the 7500 a the ePrint application so that I can print to the 7500 a still without disturbing the current app ePrint printer that prints to the 8500?
Thanks for the tips you may have.
Kevin
Hi, I would like to try and answer your questions to the best of my ability:
- How could I get the ePrint initiated by app printed to reach the 7500 a?
With the printed file you want displayed in the app, you must see the details of the printer at the bottom of the screen on your device. If the printer you want to print to is not presented, you can press the arrow to the right of the name of the printer and then select the printer at the top of the next screen. It will automatically search and find printers available on your network. Choose the printer you wish to print and it will update the printer selected at the time of printing. I've included a few screen shots of what it will look like
- How can I print on the 8500 email? (Remember, emailed still prints go to the 7500).
Unfortunately, it is not possible to print on the 8500 email. The printer must have the ability of ePrint in order to be able to do this.
- How can I add the 7500 a the ePrint application so that I can print to the 7500 a still without disturbing the current app ePrint printer that prints to the 8500?
See the answer to the first question
If this does not solve your problem you can try to install the HP Home Network Diagnostic Utility tool to check that nothing is wrong with your network printers
-
How can I get the correct product key for my sleekbook want PC4
How can I get the correct product key for my sleekbook desire 4 PC
Hello
As mentioned in your other post you can get it from Microsoft with your money:
Kind regards.
-
I need to know how I can get the correct download for my Mac computer?
Contact support - for the link below, click on the still need help? option in the blue box below and choose the option to chat or by phone...
Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache. If it fails to connect, try to use another browser.
Get help from cat with orders, refunds and exchanges (non - CC)
http://helpx.Adobe.com/x-productkb/global/service-b.html ( http://adobe.ly/1d3k3a5 )
-
Try installing Adobe Acrobat Pro DC and it will not accept the serial number. Receive the message invalid serial number.
How can I get the correct number to enter?
Hi chrise68847178,
You can check your serial number of this link:find the serial number of your product Adobe quickly
Also, you can check this link:error of incorrect serial number
Let us know if that helps.
Concerning
Sarojini
-
in newly improved LR6.4, when I want to import from SD card, the images are in a random order, not the order that I pulled on them. Images are scattered. Once imported, the images are correct. How can I get the import to be in the order that I pulled on them?
Is there a sort option near the bottom of the import screen. Have you tried different sort options that are available?
-
How can I get a percentage value in curves - in CS5, it used to be Cmde would make a point on a point on the curve, to allow for precise adjustment...
Hugh,
Your screenshot shows that you're NOT watching the modeless panel that mentions Christoph Pfaffenbichler.
This screenshot is not of all 'menu', as you call it mistakingly, but of the dialog modal adjustment, not a modeless adjustment panelthat would look like this:
-
How can I get the correct product key for my laptop?
Hello I bought my Pavillion dv6707 us in TI 2008 has Windows Vista Home 32-bit (OPS).
I just got a notice saying that my (OPS) are not authentic I have 2 key 1 products in the software 89578-OEM-7332157-00061 the other is on the bottem of my laptop that I can almost distinguish as V6KPX-BFMJF-DM7QP-T3X7B-QCQDD how can I get the right pair?
Hello
Those at the bottom of the laptop is for the operating system on your machine.
Kind regards.
-
How can I get the address of the memory of a table?
Hi all
Please bear with me, as this can be confusing. Let me know if you have any questions.
I have a CCD of Hamamatsu and an external DLL that comes with it that I use. I call the "DcamCapture" function - this sends the capture command to the CCD.
Its documentation:
"BOOL DcamCapture (LPVOID pImageBuff, INT nBuffSize)
[Summary]
Begins to capture an image of the device.[Arguments]
pImageBuff specifies the start address of the buffer where the image data is
to be stored.nBuffSize specifies the size of the buffer (number of bytes).
[Note]
(1) this function emits an instruction to begin to capture the image. Since the image
capture is not complete even when the function is completed, use the DcamWaitfunction to check if the image capture is complete. »
The "BOLD" is my own. So after that I called this function, I have to call DcamWait. The problem is, from this point, labview has already written the pImageBuff to its indicator variable - in fact, he wrote immediately after the return of this function. But before that data has even written to memory! So I go out exactly what I put in - an empty array.
In C++, this isn't a problem. What they do in their code for the example is call DcamCapture, DcamWait in a loop, and then dereference the pointer pImageBuff once all this is done.
I don't know how to dereference the pointer of table in Labview.
So I have to, as a clumsy hack, call DcamCapture TWICE. I first call DcamCapture, then DcamWait, then DcamCapture again - this time, I use the FCM to dereference the pointer, pImageBuff, which has the correct data (now).
-How can I get the location of the memory of the pImageBuff? And then, how can I access it?
Thanks for your help. I called NOR and they 'think' about my problem - I would see if anyone here can come up with a solution.
You can do this by using the functions of the memory manager of LabVIEW, you call by setting the name of the library to 'LabVIEW' in the call library function node. The functions you need are DSNewPtr, MoveBlock (which in fact copy of data) and DSDisposePtr. There are short documents on these functions using LabVIEW. You need to call DSNewPtr to allocate the memory, switch to the DCamCapture, loop on DCamWait, use MoveBlock to copy this pointer data in a table that manages LabVIEW and finally free the pointer. Here is an example of a similar sequence: http://forums.ni.com/t5/LabVIEW/array-pointer-from-dll/m-p/1217453#M519958.
-
I've lost all my acrobat adobe Pro XI files during a reinstallation of win7. How can I get the news I need to download and install Adobe Acrobat XI Pro?
[Read https://forums.adobe.com/docs/DOC-7273]
[Ask in the correct forum allows... Left the connections for specific program forum forum... MOD]https://Accounts.adobe.com/ , then click on Plans & products above to find a list of your programs and your serial numbers
-
How can I get the update to Camera Raw 8.4?
How can I get the update to Camera Raw 8.4?
I don't inderstand why someone would get ACR 8.4. The correct version of ACR for CS5 is ACR 6.7, cs6 is cab 9.1.1 and CC, CC 2014 and 2015 ACR 9.5 CC.
Update can be downloaded from these links
Adobe Camera Raw 8.4 or later on Mac OS 10.6, Windows XP and Vista
Adobe - Photoshop: For Windows
2015 all updates of Adobe CC: Direct for Windows download links | ProDesignTools
Adobe - Photoshop: For Macintosh
2015 all updates of Adobe CC: Direct for Windows download links | ProDesignTools
-
How can I get the reference of the UI button?
How can I get the createBtn to connect to the pathBtnFunc for she service?
I know that my code is wrong, can someone tell me the correct way?
Thank you!
I just noticed this. You must set the onClick function before the line win.show (). All user interface control functions should be in the code that creates the user interface.
-
I need to eager zero a virtual disk while building a virtual machine. I found the eagerZeroVirtualDisk_Task() under VcVirtualDiskManager function, which takes in 2 parameters:
name - (String) the name of the disk, is a path to the data store or a URL pointing to the virtual disk that needs to be inflated.
Data Center - (VcDatacenter) if the name is a path of data store, the data center for the path of the data store. Not necessary when called directly on ESX. If not specified on a call to VirtualCenter, the name must be a URL.
How can I get the correct path of data store given the virtual disk? I intend to iterate through the features of the virtual machine to get the disks.
Thank you!
Actually figured out how to get the path of the data store, and how a drive zeros. In case it is useful to share the code here:
var vimHost = vm.vimHost; VM instanceof VCVirtualMachine
var vDiskMgr = vimHost.virtualDiskManager;
for each disk
var features = vm.config.hardware.device;
for each {(dev var in devices)
dev.backing contains a lot of useful things...
If (dev instanceof VcVirtualDisk) {}
a disc!
var dsPath = dev.backing.fileName;
System.log ("path of disk:" + dsPath);
Data var Center =
System.getModule('com.vmware.library.vc.datastore').getDatacenterForDatastore (dev.backing.datastore);
var vcTask = vDiskMgr.eagerZeroVirtualDisk_Task (dsPath, datacenter);
wait
var waitResult =
System.getModule('com.vmware.library.vc.basic').vim3WaitTaskEnd (vcTask, true, 5);
}
}
-
When I drag my clip in my calendar, there is no audio that comes with it, even if it is supposed to be. How can I get the audio?
Make sure your Source patch and the targeting of the track are set correctly:
MtD
-
How do you get the header of HTTP authentication for our hosted solution?
How do you get the header of our hosted solution (adobeconnect_admin_httpauth) HTTP authentication? The documentation says find a custom.ini file but I have no idea how access.
I need to provide only the plugin adobeconnect used with a Moodle instance, screnshot below.
If it helps, when I click "Test connection", I see the following output.
A series of tests were run to determine if the Adobe Connect Pro Server has been properly configured for this integration to work and also determine if the user credentials provided in the global settings activity has the appropriate permissions to perform the necessary tasks required by the activity module. If none of the tests below have failed, this activity module will not work correctly.
To get help and documentation in how to configure your Adobe Connect Pro Server, please see the help page of MoodleDocs for this activity module help page
Sending call common-info:
has managed to get the session key: na11breezrirhb4f4ryf5shqy
connected as user admin
Test retrevial of shared content, registration, and records of the meeting:
Error getting the shared content folder
XML request:
<? XML version = "1.0" encoding = "UTF-8"? > < params > < param name = 'action' > sco-shortcuts < / param > < / params >
XML response:
<? XML version = "1.0" encoding = "utf-8"? > < results > < status code = "lack of access" subcode = "no-login" / > < / results >
getting error forced archives folder (meeting records)
XML request:
<? XML version = "1.0" encoding = "UTF-8"? > < params > < param name = 'action' > sco-shortcuts < / param > < / params >
XML response:
<? XML version = "1.0" encoding = "utf-8"? > < results > < status code = "lack of access" subcode = "no-login" / > < / results >
record of meetings to get error
XML request:
<? XML version = "1.0" encoding = "UTF-8"? > < params > < param name = 'action' > sco-shortcuts < / param > < / params >
XML response:
<? XML version = "1.0" encoding = "utf-8"? > < results > < status code = "lack of access" subcode = "no-login" / > < / results >
meeting testmeetingtest file creation error
XML request:
<? XML version = "1.0" = "UTF-8 encoding"? > < params > < param name = 'action' > sco-update < / param > < param name = ' type' > meeting < / param > < param name = "name" > testmeetingtest < / param > < param name = 'folder-id' / > < param name = "date-begin" > 2015-03-14T 06: + 00:00 53:39.000 < / param > < param name = 'date-end' > 2015-03-14 T 07: + 00:00 53:39.000 < / param > < / params >
XML response:
<? XML version = "1.0" encoding = "utf-8"? > < results > < = "invalid" status code > < invalid field = 'folder-id' type = subcode 'id' = 'format' / > < / status > < / results >
Error creating user testusertest
XML request:
<? xml version = "1.0" = 'UTF-8' encoding? > < params > < param name = 'action' > principal-update < / param > < param name = "name" > testusertest < / param > < param name = "name" > testusertest < / param > < param name = "login" > [email protected] < / param > < param name = "password" > 9B396EA828A00203FB3E8E69010FE537 < / param > < param name = "extlogin" > [email protected] < / param > < param name = ' type' > user < / param > < param name = "send email" > false < / param > < param name = "a-kids" > 0 < / param > < param name = "email" > [email protected] < / param > < / params >
XML response:
<? XML version = "1.0" encoding = "utf-8"? > < results > < status code = "lack of access" subcode = "no-login" / > < / results >
What do we lack?
Thank you!
Here's the docuementation for loging in there with a Headder HTTP Adobe Connect 9 * log from an application
Because there may be some changes to the files on the server, you may need to work with Adobe's Support to see if they can be changed in the hosted environment. Acrobat Connect Pro help | Acrobat Connect Pro Support
Maybe you are looking for
-
function "clear recent history" - not available in the Tools tab is not clcikable - winXP?
WinXP - when I click on the menu Tools to clear recent history of the feature isn't available, I can see the name, but it is grayed out and is not clickable - the same for ctrl + shift del ... How can I solve this problem? How can I clear the cache?
-
Use Peoplesoft 8 and when I go to open a doc (tiff on a shared server file) link, it says that I am not authorized to view the page.
-
A security update (KB2744842) comes back.
I have Windows XP and Windows Explorer 8. I have religiously accept that all the security updates that Microsoft sent me. After I ran the first update from September 22, 2012, this same update is almost every week or so. Put it back, again and again
-
OfficeJet HP 6600: printhead missing, not detected or ill-posed
Ink is not empty and is correctly installed, but above message continues to appear and it give no details about the problem.
-
OptiPlex GX620 under Windows 7-64 bit
We discuss to modernize our systems with Windows 7-64 bit. Some of them are OptiPlex GX620 with Pentium D processor. One of my colleageus began installing Windows 7-64 bit for some of them. So far, she said, she did not no problem. This system does s