Topic
  • 4 replies
  • Latest Post - ‏2013-04-25T08:25:10Z by dpxray
SystemAdmin
SystemAdmin
2402 Posts

Pinned topic ryo perfstat_diskpath statistik

‏2013-04-03T15:02:45Z |
Hello (Nigel),

i try to write a small c programm, which show me the service times (read and write) for all mpio pathes.

I used the examples from

http://www.ibm.com/developerworks/wikis/display/wikiptype/ryo

and

http://pic.dhe.ibm.com/infocenter/aix/v7r1/index.jsp?topic=%2Fcom.ibm.aix.basetechref%2Fdoc%2Fbasetrf1%2Fperfstat_diskpath.htm

but i get no values for "rserv" or "wserv". Both variables are allways zero.

$ oslevel -s
7100-01-06-1241

$ gcc -g -l perfstat -o pathstat pathstat.c

Has anyone a suggestion?

Regards
Ron
Updated on 2013-04-05T19:49:48Z at 2013-04-05T19:49:48Z by nagger
  • nagger
    nagger
    1686 Posts

    Re: ryo perfstat_diskpath statistik

    ‏2013-04-05T19:49:48Z  
    Hi,
    I would have some one else check over your code.
    thanks, Nigel
  • dpxray
    dpxray
    2 Posts

    Re: ryo perfstat_diskpath statistik

    ‏2013-04-23T08:14:14Z  
    • nagger
    • ‏2013-04-05T19:49:48Z
    Hi,
    I would have some one else check over your code.
    thanks, Nigel

    Hi Nigel,

    thanks for your reply.

    Could you look over the code?

    /* gcc -g -l perfstat -o pathstat pathstat.c */
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <libperfstat.h>
    #include <sys/var.h>

    int main(int argc, char* argv[]) {

        char * pointer;
        char IOSTAT[5];
           char hdisk[20];
           char hdisk_name[20];
           char hdisk_alt[20];
           int i, pcount, length;
           unsigned int step;
           double reads,writes,xfers,activity;
           perfstat_id_t first;
           perfstat_diskpath_t *statpA, *statpB;

        if(argc < 2) {printf("\nBitte Intervall in Sekunden uebergeben\t[./%s 2]\n\n",argv[0]);exit(-1);}
        step = atoi(argv[1]);
        
           pcount = perfstat_diskpath(NULL,NULL,sizeof(perfstat_diskpath_t),0);
           if (pcount < 0)     {perror("perfstat_diskpath");exit(-1);}
           if (pcount == 0)    {printf("No Paths found in System\n");exit(-1);}
           /* allocate enough memory for all the structures */
           statpA = calloc(pcount, sizeof(perfstat_diskpath_t));
           statpB = calloc(pcount, sizeof(perfstat_diskpath_t));
       
           strcpy(first.name, FIRST_DISKPATH);
           perfstat_diskpath(&first, statpA, sizeof(perfstat_diskpath_t),pcount);
               
              
           while (1) {
               #define DELTA(member) (statpB[i].member - statpA[i].member)
               sleep(step);
           
            
               strcpy(first.name, FIRST_DISKPATH);
               perfstat_diskpath(&first, statpB, sizeof(perfstat_diskpath_t),pcount);
               
               printf("\n%-8s %-8s %-9s ","HDisk","Pfad","Adapter");
               printf("%6s %8s ","%Activ","Xfers");
               printf("%10s %8s ","Kb_read","rserv");
               printf("%10s %8s\n","Kb_wrtn","wserv");
               
               printf("%-8s %-8s %-9s ","------","--------","---------");
               printf("%6s %8s ","------","--------");
               printf("%10s %8s ","----------","--------");
               printf("%10s %8s\n","----------","--------");
               
                          
               for (i = 0; i < pcount; i++) {
               
                  pointer = strstr(statpB[i].name, "Path");
                   if (pointer == NULL) {return (-1);}
                   length = pointer - statpB[i].name -1;
                   strncpy(hdisk,statpB[i].name, length);
                   if (hdisk == NULL) {return (-1);}
                   hdisk[length] = '\0';
                   
                   strcpy(hdisk_name,hdisk);            
                                                 
                if (strcmp(hdisk_alt,hdisk_name) == 0) {strcpy(hdisk_name,NULL);}        

                writes         = (double)DELTA(wblks)  / (step * 2);
                reads        = (double)DELTA(rblks)  / (step * 2);  
                xfers        = (double)DELTA(xfers)  / step;                    
                activity     = (double)DELTA(time)   / step;    
                                
                   printf("%-8s %-8s %-9s ",hdisk_name,pointer,statpB[i].adapter);
                   printf("%6.2lf %8.2lf ",activity,xfers);
                   
                   /* rserv and wserv are allways empty */
                   printf("%10.2lf %8llu ",reads,statpB[i].rserv);
                   printf("%10.2lf %8llu\n",writes,statpB[i].wserv);
          
                   strcpy(hdisk_alt,hdisk_name);
               }
               memcpy(statpA,statpB,sizeof(perfstat_diskpath_t) * pcount);                               
           }     
    }

    Thanks in advance
    Ron

  • nagger
    nagger
    1686 Posts

    Re: ryo perfstat_diskpath statistik

    ‏2013-04-25T06:51:35Z  
    • dpxray
    • ‏2013-04-23T08:14:14Z

    Hi Nigel,

    thanks for your reply.

    Could you look over the code?

    /* gcc -g -l perfstat -o pathstat pathstat.c */
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <libperfstat.h>
    #include <sys/var.h>

    int main(int argc, char* argv[]) {

        char * pointer;
        char IOSTAT[5];
           char hdisk[20];
           char hdisk_name[20];
           char hdisk_alt[20];
           int i, pcount, length;
           unsigned int step;
           double reads,writes,xfers,activity;
           perfstat_id_t first;
           perfstat_diskpath_t *statpA, *statpB;

        if(argc < 2) {printf("\nBitte Intervall in Sekunden uebergeben\t[./%s 2]\n\n",argv[0]);exit(-1);}
        step = atoi(argv[1]);
        
           pcount = perfstat_diskpath(NULL,NULL,sizeof(perfstat_diskpath_t),0);
           if (pcount < 0)     {perror("perfstat_diskpath");exit(-1);}
           if (pcount == 0)    {printf("No Paths found in System\n");exit(-1);}
           /* allocate enough memory for all the structures */
           statpA = calloc(pcount, sizeof(perfstat_diskpath_t));
           statpB = calloc(pcount, sizeof(perfstat_diskpath_t));
       
           strcpy(first.name, FIRST_DISKPATH);
           perfstat_diskpath(&first, statpA, sizeof(perfstat_diskpath_t),pcount);
               
              
           while (1) {
               #define DELTA(member) (statpB[i].member - statpA[i].member)
               sleep(step);
           
            
               strcpy(first.name, FIRST_DISKPATH);
               perfstat_diskpath(&first, statpB, sizeof(perfstat_diskpath_t),pcount);
               
               printf("\n%-8s %-8s %-9s ","HDisk","Pfad","Adapter");
               printf("%6s %8s ","%Activ","Xfers");
               printf("%10s %8s ","Kb_read","rserv");
               printf("%10s %8s\n","Kb_wrtn","wserv");
               
               printf("%-8s %-8s %-9s ","------","--------","---------");
               printf("%6s %8s ","------","--------");
               printf("%10s %8s ","----------","--------");
               printf("%10s %8s\n","----------","--------");
               
                          
               for (i = 0; i < pcount; i++) {
               
                  pointer = strstr(statpB[i].name, "Path");
                   if (pointer == NULL) {return (-1);}
                   length = pointer - statpB[i].name -1;
                   strncpy(hdisk,statpB[i].name, length);
                   if (hdisk == NULL) {return (-1);}
                   hdisk[length] = '\0';
                   
                   strcpy(hdisk_name,hdisk);            
                                                 
                if (strcmp(hdisk_alt,hdisk_name) == 0) {strcpy(hdisk_name,NULL);}        

                writes         = (double)DELTA(wblks)  / (step * 2);
                reads        = (double)DELTA(rblks)  / (step * 2);  
                xfers        = (double)DELTA(xfers)  / step;                    
                activity     = (double)DELTA(time)   / step;    
                                
                   printf("%-8s %-8s %-9s ",hdisk_name,pointer,statpB[i].adapter);
                   printf("%6.2lf %8.2lf ",activity,xfers);
                   
                   /* rserv and wserv are allways empty */
                   printf("%10.2lf %8llu ",reads,statpB[i].rserv);
                   printf("%10.2lf %8llu\n",writes,statpB[i].wserv);
          
                   strcpy(hdisk_alt,hdisk_name);
               }
               memcpy(statpA,statpB,sizeof(perfstat_diskpath_t) * pcount);                               
           }     
    }

    Thanks in advance
    Ron

    Beautify! More interesting would be what happens when you compile & run it?

  • dpxray
    dpxray
    2 Posts

    Re: ryo perfstat_diskpath statistik

    ‏2013-04-25T08:25:10Z  
    • nagger
    • ‏2013-04-25T06:51:35Z

    Beautify! More interesting would be what happens when you compile & run it?

    Hi Nigel,

    the compile  works without any warnings/errors. This is the output from the program:

    HDisk    Pfad     Adapter   %Activ    Xfers    Kb_read    rserv    Kb_wrtn    wserv
    ------   -------- --------- ------ -------- ---------- -------- ---------- --------
    hdisk10  Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.00     0.00       0.00        0       0.00        0
    hdisk5   Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.50     0.50       0.00        0       2.00        0
    hdisk0   Path0    fcs0        0.00     0.00       0.00        0       0.00        0
    hdisk6   Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.00     0.00       0.00        0       0.00        0
    hdisk13  Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.00     0.00       0.00        0       0.00        0
    hdisk2   Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.00     0.00       0.00        0       0.00        0
    hdisk9   Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.00     0.00       0.00        0       0.00        0
    hdisk8   Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.00     0.50       0.00        0       2.00        0
    hdisk7   Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.00     0.50       0.00        0       2.00        0
    hdisk1   Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        7.00   135.50   19968.00        0    5008.00        0
    hdisk4   Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.00     2.50       0.00        0      10.00        0
    hdisk11  Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.00     0.00       0.00        0       0.00        0
    hdisk3   Path0    fcs1        0.00     0.00       0.00        0       0.00        0
    hdisk12  Path1    fcs1        0.00     0.00       0.00        0       0.00        0
             Path0    fcs0        0.00     0.50       0.00        0       2.00        0

    The program works with the exception that the Servicetimes (rserv and wserv) are not shown. I tested the program on AIX 5.3/Power5 and 7.1/Power7 with the same result. I have no idea whats going wrong.

    Maybe  Servicetimes for a Path are not supported - only for Disks?

     

    Updated on 2013-04-25T08:30:08Z at 2013-04-25T08:30:08Z by dpxray