- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: pstat_getdynamic/pstat_getprocessor-Can these ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2013 10:55 PM
02-12-2013 10:55 PM
pstat_getdynamic/pstat_getprocessor-Can these system calls be used for getting CPU usage on HP-UX
Hi,
We are using the following piece of code for getting the processor utilization details on HP-UX systems.
<code>
struct pst_processor pstat_buffer[MAX_PROCESSORS];
struct pst_dynamic pstat_dyn;
int nproc,id;
printf("In main class\n");
if(pstat_getdynamic(&pstat_dyn, sizeof(struct pst_dynamic),1,0) == -1)
{
printf("pstat_getdynamic failed");
}
nproc = pstat_dyn.psd_proc_cnt;
printf("nproc = %d\n", nproc);
if (nproc > MAX_PROCESSORS)
{
nproc = MAX_PROCESSORS;
}
if(pstat_getprocessor(pstat_buffer,sizeof(struct pst_processor), nproc, 0) == -1)
{
printf("pstat_getprocessor failed");
}
for (id=0; nproc>0; ++id)
{
printf("id = %d \n",id);
printf("CP_USER %d\n",pstat_buffer[id].psp_cpu_time[CP_USER]);
printf("CP_SYS %d \n",pstat_buffer[id].psp_cpu_time[CP_SYS]);
printf("CP_WAIT %d \n ",pstat_buffer[id].psp_cpu_time[CP_WAIT]);
printf("CP_IDLE %d\n",pstat_buffer[id].psp_cpu_time[CP_IDLE] );
nproc--;
}
printf("Returning 0");
return 0;
</code>
We are seeing that the above code returns zero values for some of the processors while the top command shows non zero values for processor utilization for the same set of processors. There is one more observation that the above peice of code returns usage values for all processors on a system if they are numbered with IDs that are consecutive similar to 0,1, 2 , 3..... . However, the same piece of code returns zero values for some of the processors when their IDs are numbered in the following manner - 0, 2, 4, 6 etc.
Can some one please let me know if this is a known issue? Also, I would like to know if processor utlization can be collected using other system calls?
- Tags:
- pstat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2013 12:01 AM
02-13-2013 12:01 AM
Re: pstat_getdynamic/pstat_getprocessor-Can these calls be used for getting CPU usage on HP-UX
What HP-UX version?
Do you have the correct number of processors from your code? What does machinfo(1) show?
Is it confusing hyperthreads?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2014 12:45 PM
03-19-2014 12:45 PM
Re: pstat_getdynamic/pstat_getprocessor-Can these system calls be used for getting CPU usage on HP-U
Was there any solution to this reqeust for even numbered processors when using the function pstat_getprocessor()?
Is there a os patch that resolved the issue?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2014 10:03 PM - edited 03-20-2014 11:07 AM
03-19-2014 10:03 PM - edited 03-20-2014 11:07 AM
Re: pstat_getdynamic/pstat_getprocessor-Can these system calls be used for getting CPU usage on HP-U
Why do you think there is a problem? Rewriting the program correctly, I get this info:
getprocessor returned: 4
id = 0 lid = 0 sockid = 0, coreid = 0, thrdid = 0
...
id = 1 lid = 1 sockid = 0, coreid = 0, thrdid = 1
id = 2 lid = 2 sockid = 0, coreid = 2, thrdid = 0
id = 3 lid = 3 sockid = 0, coreid = 2, thrdid = 1
Last idx: 4
getprocessor returned: 4
id = 4 lid = 4 sockid = 3, coreid = 4, thrdid = 0
id = 5 lid = 5 sockid = 3, coreid = 4, thrdid = 1
id = 6 lid = 6 sockid = 3, coreid = 6, thrdid = 0
id = 7 lid = 7 sockid = 3, coreid = 6, thrdid = 1
Last idx: 8
So the reason the odd logical _id times are 0, is that hyperthreading is turned off.
So Example 2 in pstat(2) is wrong.
(I'm not sure why the socket ID jumps from 0 to 3 but perhaps more sockets could be added to this rx2660?)