1833847 Members
2206 Online
110063 Solutions
New Discussion

hp-ux tuning

 
SOLVED
Go to solution
debraj bhattacharya
New Member

hp-ux tuning

i am doing a hp-ux tuning project.can someone tell me a way to find out the number of application threads spwaned out by a application.
2 REPLIES 2
Abhijit P.
Valued Contributor
Solution

Re: hp-ux tuning

hi...

I think for doing this you need some process monitoring softwares like Glanceplus

Regards,
Abhijit

Arunvijai_4
Honored Contributor

Re: hp-ux tuning

Hi,

A C program for this,

#include "sys/param.h"
#include "sys/pstat.h"

int main ( void )
{

struct pst_status * psa = NULL;
struct pst_status * prc = NULL;
struct pst_dynamic psd;
long nproc = 0;
long thsum = 0;
long i;

if ( pstat_getdynamic(&psd, sizeof(psd), 1, 0) == -1 )
(void)perror("pstat_getdynamic failed");

// Get the number of active processes from pst_dynamic
nproc = psd.psd_activeprocs;
psa = (struct pst_status *)malloc(nproc * sizeof(struct pst_status));

// Read the info about the active processes into the array 'psa'
if ( pstat_getproc(psa, sizeof(struct pst_status), nproc, 0) == -1 )
(void)perror("pstat_getproc failed");

(void)printf("\n\n------------------------------------------------------------------------------");
(void)printf("\n %5s | %5s |%7s| %5s | %s", "PID", "UID", "Threads", "RSS", "Command");
(void)printf("\n------------------------------------------------------------------------------");

// Report the process info as required
prc = (struct pst_status *)psa;
for (i=0; i < nproc; i++)
{
(void)printf("\n %5ld | ", prc->pst_pid);
(void)printf("%5ld | ", prc->pst_uid);
(void)printf("%5ld | ", prc->pst_nlwps);
(void)printf("%5ld | ", prc->pst_rssize);
(void)printf("%s ", prc->pst_cmd);
thsum += prc->pst_nlwps;
++prc;
}

(void)printf("\n\n*** %ld processes, %ld threads running\n\n", nproc, thsum);
(void)free(psa);
(void)exit(0);
}

http://h21007.www2.hp.com/dspp/tech/tech_TechSingleTipDetailPage_IDX/1,2366,5944,00.html

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"