Relate I/O's activity to processes - HP UX

This is a discussion on Relate I/O's activity to processes - HP UX ; Hi, The guy here http://rootshell.be/~yong321/freeware/pio1_3_c.txt wrote a small C prg that easily allows you to see what processes perform strong I/O's, and to further troubleshoot eventual waits caused by this process activity. It's helped me in a few cases to ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: Relate I/O's activity to processes

  1. Relate I/O's activity to processes

    Hi,

    The guy here
    http://rootshell.be/~yong321/freeware/pio1_3_c.txt
    wrote a small C prg that easily allows you to see what
    processes perform strong I/O's, and to further troubleshoot
    eventual waits caused by this process activity. It's helped
    me in a few cases to point out database problems.

    But this code is only relevant to Solaris operating system:
    I'd like to know if you could help me to adapt it to HPUX
    operating system.
    As you'll see this code rests upon the psinfo files located
    in /proc/ directories. Is there a similar (and simple
    too) way to get at processes I/O activity within these 3
    operating systems as well ?


    Thanks a lot !


  2. Re: Relate I/O's activity to processes

    On 8 Nov 2006 01:27:02 -0800, Spendius wrote:
    > The guy here
    > http://rootshell.be/~yong321/freeware/pio1_3_c.txt

    [...]
    > But this code is only relevant to Solaris operating system:
    > I'd like to know if you could help me to adapt it to HPUX
    > operating system.


    Have a look at the pstat APIs:

    /*
    * This structure contains per-process information
    */
    struct __pst_status {
    [...]
    _T_ULONG_T pst_majorfaults; /* # page faults needing disk
    access */
    [...]
    _T_LONG_T pst_inblock; /* block input operations */
    _T_LONG_T pst_oublock; /* block output operations */
    [...]


    Christof

    --
    http://cmeerw.org sip:cmeerw at cmeerw.org
    mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org

  3. Re: Relate I/O's activity to processes

    Christof Meerwald wrote:
    > ...
    > Have a look at the pstat APIs:
    >
    > /*
    > * This structure contains per-process information
    > */
    > struct __pst_status {
    > [...]
    > _T_ULONG_T pst_majorfaults; /* # page faults needing disk
    > access */
    > [...]
    > _T_LONG_T pst_inblock; /* block input operations */
    > _T_LONG_T pst_oublock; /* block output operations */
    > [...]
    >
    >
    > Christof
    >
    > --
    > http://cmeerw.org sip:cmeerw at cmeerw.org
    > mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org


    Hi, Christof,

    I checked pst_inblock and pst_oublock with a small program. They seem
    to always have the same values 2147479776 and 2147479780, respectively,
    for all processes at any time. I just found somebody else had the same
    problem:

    http://www.unix.com/archive/index.php/t-15529.html

    Do you have any idea? Thanks.

    My server is:
    HP-UX td176 B.11.23 U ia64 1928826293 unlimited-user license

    Yong Huang


  4. Re: Relate I/O's activity to processes

    yong321@yahoo.com wrote:
    > Christof Meerwald wrote:
    >> ...
    >> Have a look at the pstat APIs:
    >>
    >> /*
    >> * This structure contains per-process information
    >> */
    >> struct __pst_status {
    >> [...]
    >> _T_ULONG_T pst_majorfaults; /* # page faults needing disk
    >> access */
    >> [...]
    >> _T_LONG_T pst_inblock; /* block input operations */
    >> _T_LONG_T pst_oublock; /* block output operations */
    >> [...]
    >>
    >>
    >> Christof
    >>
    >> --
    >> http://cmeerw.org sip:cmeerw at cmeerw.org
    >> mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org

    >
    > Hi, Christof,
    >
    > I checked pst_inblock and pst_oublock with a small program. They seem
    > to always have the same values 2147479776 and 2147479780, respectively,
    > for all processes at any time. I just found somebody else had the same
    > problem:


    Those look awfully 32-bit. Did you compile 32-bit and not use
    -D_PSTAT64? There's so many things that get misreported if you don't
    that this is officially unsupported. (From the pstat man page):

    The use of the pstat functional interfaces for applications using the
    ILP32 programming model without defining the -D_PSTAT64 compiler flag
    is deprecated. Furthermore, some pstat functions are available only
    for applications using the LP64 programming model and for
    applications
    written in standard C and extended ANSI C that use the ILP32
    programming model and that define -D_PSTAT64. The pstat functions
    pstat_getlwp(), pstat_getcrashinfo(), and pstat_getlocality() are
    some
    of the pstat functions that fall into this category.

    Don

    >
    > http://www.unix.com/archive/index.php/t-15529.html
    >
    > Do you have any idea? Thanks.
    >
    > My server is:
    > HP-UX td176 B.11.23 U ia64 1928826293 unlimited-user license
    >
    > Yong Huang
    >


  5. Re: Relate I/O's activity to processes

    Don Morris wrote:
    > yong321@yahoo.com wrote:
    > > Christof Meerwald wrote:
    > >> ...
    > >> Have a look at the pstat APIs:
    > >>
    > >> /*
    > >> * This structure contains per-process information
    > >> */
    > >> struct __pst_status {
    > >> [...]
    > >> _T_ULONG_T pst_majorfaults; /* # page faults needing disk
    > >> access */
    > >> [...]
    > >> _T_LONG_T pst_inblock; /* block input operations */
    > >> _T_LONG_T pst_oublock; /* block output operations */
    > >> [...]
    > >>
    > >>
    > >> Christof
    > >>
    > >> --
    > >> http://cmeerw.org sip:cmeerw at cmeerw.org
    > >> mailto:cmeerw at cmeerw.org xmpp:cmeerw at cmeerw.org

    > >
    > > Hi, Christof,
    > >
    > > I checked pst_inblock and pst_oublock with a small program. They seem
    > > to always have the same values 2147479776 and 2147479780, respectively,
    > > for all processes at any time. I just found somebody else had the same
    > > problem:

    >
    > Those look awfully 32-bit. Did you compile 32-bit and not use
    > -D_PSTAT64? There's so many things that get misreported if you don't
    > that this is officially unsupported. (From the pstat man page):
    >
    > The use of the pstat functional interfaces for applications using the
    > ILP32 programming model without defining the -D_PSTAT64 compiler flag
    > is deprecated. Furthermore, some pstat functions are available only
    > for applications using the LP64 programming model and for
    > applications
    > written in standard C and extended ANSI C that use the ILP32
    > programming model and that define -D_PSTAT64. The pstat functions
    > pstat_getlwp(), pstat_getcrashinfo(), and pstat_getlocality() are
    > some
    > of the pstat functions that fall into this category.
    >
    > Don
    >
    > >
    > > http://www.unix.com/archive/index.php/t-15529.html
    > >
    > > Do you have any idea? Thanks.
    > >
    > > My server is:
    > > HP-UX td176 B.11.23 U ia64 1928826293 unlimited-user license
    > >
    > > Yong Huang


    Thanks, Don. I tried gcc (3.4.3) and cc (/usr/bin/cc, cc: HP C/aC++
    B3910B A.06.12 [Aug 17 2006]) with and without -D_PSTAT64. All generate
    binary successfully but each binary shows the same inblock and oublock
    values for all processes, even though between with and without the
    flag, they show slightly different values.

    /house/yong321>cc test.c
    /house/yong321>./a.out -p $$
    InBlock Ops: 2147479808 ; OuBlocks: 2147479812

    /house/yong321>cc -D_PSTAT64 test.c
    /house/yong321>./a.out -p $$
    InBlock Ops: 2147479744 ; OuBlocks: 2147479752

    /house/yong321>./a.out -p 1
    InBlock Ops: 2147479744 ; OuBlocks: 2147479752

    Yong Huang


  6. Re: Relate I/O's activity to processes

    yong321@yahoo.com wrote:
    >
    > Thanks, Don. I tried gcc (3.4.3) and cc (/usr/bin/cc, cc: HP C/aC++
    > B3910B A.06.12 [Aug 17 2006]) with and without -D_PSTAT64. All generate
    > binary successfully but each binary shows the same inblock and oublock
    > values for all processes, even though between with and without the
    > flag, they show slightly different values.
    >
    > /house/yong321>cc test.c
    > /house/yong321>./a.out -p $$
    > InBlock Ops: 2147479808 ; OuBlocks: 2147479812
    >
    > /house/yong321>cc -D_PSTAT64 test.c
    > /house/yong321>./a.out -p $$
    > InBlock Ops: 2147479744 ; OuBlocks: 2147479752
    >
    > /house/yong321>./a.out -p 1
    > InBlock Ops: 2147479744 ; OuBlocks: 2147479752


    Hmm... I can't duplicate it here -- though I don't have your exact
    environment, so that may be an issue.

    Can you post your code -- or try with a really dirt simple program?

    Here's my sample (obviously you parse your args for a target pid -
    but you're likely not far off...):

    # cat inblock_test.c
    #include
    #include
    #include

    int
    main(int argc, char *argv[])
    {
    struct pst_status pst;
    register struct pst_status *psp = &pst;
    int count;

    (void)memset((void *)psp, -1, sizeof(*psp));
    count = pstat_getproc(psp, sizeof(*psp), 0UL, (int)getpid());

    if ( count == 0 ) {
    printf("Oddness: Couldn't locate ourselves?\n");
    exit(EXIT_FAILURE);
    }

    printf("pst_inblock: %llx, pst_oublock: %llx.\n",
    psp->pst_inblock, psp->pst_oublock);
    exit(EXIT_SUCCESS);
    }
    # cc +DD32 -D_PSTAT64 -o inblock_test inblock_test.c
    # ./inblock_test
    pst_inblock: 0, pst_oublock: 3.

    Don

  7. Re: Relate I/O's activity to processes

    Don Morris wrote:
    > yong321@yahoo.com wrote:
    > >
    > > Thanks, Don. I tried gcc (3.4.3) and cc (/usr/bin/cc, cc: HP C/aC++
    > > B3910B A.06.12 [Aug 17 2006]) with and without -D_PSTAT64. All generate
    > > binary successfully but each binary shows the same inblock and oublock
    > > values for all processes, even though between with and without the
    > > flag, they show slightly different values.
    > >
    > > /house/yong321>cc test.c
    > > /house/yong321>./a.out -p $$
    > > InBlock Ops: 2147479808 ; OuBlocks: 2147479812
    > >
    > > /house/yong321>cc -D_PSTAT64 test.c
    > > /house/yong321>./a.out -p $$
    > > InBlock Ops: 2147479744 ; OuBlocks: 2147479752
    > >
    > > /house/yong321>./a.out -p 1
    > > InBlock Ops: 2147479744 ; OuBlocks: 2147479752

    >
    > Hmm... I can't duplicate it here -- though I don't have your exact
    > environment, so that may be an issue.
    >
    > Can you post your code -- or try with a really dirt simple program?
    >
    > Here's my sample (obviously you parse your args for a target pid -
    > but you're likely not far off...):
    >
    > # cat inblock_test.c
    > #include
    > #include
    > #include
    >
    > int
    > main(int argc, char *argv[])
    > {
    > struct pst_status pst;
    > register struct pst_status *psp = &pst;
    > int count;
    >
    > (void)memset((void *)psp, -1, sizeof(*psp));
    > count = pstat_getproc(psp, sizeof(*psp), 0UL, (int)getpid());
    >
    > if ( count == 0 ) {
    > printf("Oddness: Couldn't locate ourselves?\n");
    > exit(EXIT_FAILURE);
    > }
    >
    > printf("pst_inblock: %llx, pst_oublock: %llx.\n",
    > psp->pst_inblock, psp->pst_oublock);
    > exit(EXIT_SUCCESS);
    > }
    > # cc +DD32 -D_PSTAT64 -o inblock_test inblock_test.c
    > # ./inblock_test
    > pst_inblock: 0, pst_oublock: 3.
    >
    > Don


    Thanks, Don. Here's my code cut down from a bigger program:

    /house/yong321>cat test.c
    #include
    #include

    void probe_one(pid_t);

    main(int argc, char **argv)
    {
    pid_t pid;
    int i;
    while ((i = getopt(argc, argv, "HhnAp:")) != EOF)
    { switch(i)
    { case 'p':
    pid = atoi(optarg);
    break;
    }
    }

    if (pid)
    probe_one(pid);
    }

    void probe_one(pid_t pid)
    {
    struct pst_status pst;

    if (pstat_getproc(&pst, sizeof(pst), (size_t)0, pid) != -1)
    printf("InBlock Ops: %lu ; OuBlocks: %lu \n", &pst.pst_inblock,
    &pst.pst_oublock);
    else
    perror("pstat_getproc");
    }
    /house/yong321>cc +DD32 -D_PSTAT64 test.c
    /house/yong321>./a.out -p $$
    InBlock Ops: 2147479744 ; OuBlocks: 2147479752
    /house/yong321>./a.out -p 1
    InBlock Ops: 2147479744 ; OuBlocks: 2147479752
    /house/yong321>uname -a
    HP-UX td176 B.11.23 U ia64 1928826293 unlimited-user license

    The server is td176.testdrive.hp.com [15.170.178.176]. Everybody can
    apply for a free account.

    When I run your code, I get two 0's:

    /house/yong321>./inblock_test
    pst_inblock: 0, pst_oublock: 0.

    Thanks again for your help.

    Yong Huang


  8. Re: Relate I/O's activity to processes

    yong321@yahoo.com wrote:
    > if (pstat_getproc(&pst, sizeof(pst), (size_t)0, pid) != -1)
    > printf("InBlock Ops: %lu ; OuBlocks: %lu \n", &pst.pst_inblock,
    > &pst.pst_oublock);


    Whoops! There's your problem, man. You want to print pst.pst_inblock
    and pst.pst_oublock -- not their address (well, unless you're just
    really really into seeing where on the stack your compiler puts your
    local addresses...). Remove the '&' character before them.

    Don

  9. Re: Relate I/O's activity to processes

    Don Morris wrote:
    > yong321@yahoo.com wrote:
    > > if (pstat_getproc(&pst, sizeof(pst), (size_t)0, pid) != -1)
    > > printf("InBlock Ops: %lu ; OuBlocks: %lu \n", &pst.pst_inblock,
    > > &pst.pst_oublock);

    >
    > Whoops! There's your problem, man. You want to print pst.pst_inblock
    > and pst.pst_oublock -- not their address (well, unless you're just
    > really really into seeing where on the stack your compiler puts your
    > local addresses...). Remove the '&' character before them.
    >
    > Don


    My eyes crossed when reading and copying Examples 4 and 5 in `man
    pstat`. Thanks for correction. I'm writing my topio freeware program.
    I'll give credit to those who helped.

    Yong Huang


  10. Re: Relate I/O's activity to processes

    yong321@yahoo.com wrote:
    ....
    > pstat`. Thanks for correction. I'm writing my topio freeware program.
    > I'll give credit to those who helped.
    >
    > Yong Huang


    Don and others, when you have time, take a quick look at

    http://rootshell.be/~yong321/freeware/pio.html#hpux

    Any comments are very welcome. Thanks.

    Yong Huang


+ Reply to Thread