0

I want to calculate Input output performance using /proc/vmstat file?

When I run command cat /proc/vmstat | grep pgpg

The answer is

pgpgin 726854
pgpgout 1010677

I don't want to use command like vmstat or iostat.

By using above values how do I calculate.

  • What I/O performance, disk or network? – pmverma Aug 19 '15 at 8:13
  • I/O performance, like input/output throughput or input/output latency – shas Aug 19 '15 at 9:20
  • pgpgin - Number of kilobytes the system has paged in from disk per second. pgpgout - Number of kilobytes the system has paged out to disk per second. – andr3w Aug 19 '15 at 10:32
  • @andr3w this i know. – shas Aug 19 '15 at 10:34
0

Got answer for Throughput, from this program I can collect read/write throughput.

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/sysinfo.h>

int main(int argc, char **argv)
{
    struct sysinfo si;
    sysinfo (&si);
    const double xdt = 1024;
    float  pagein,pageout, oldvalin = 0, oldvalout = 0, res;
    for(;;) {
        FILE *fp=fopen("/proc/vmstat","r");
        char  tmp[256];
        char  subbuff[256];
        while(fp!=NULL && fgets(tmp, sizeof(tmp),fp)!=NULL)
        {
            if (strstr(tmp, "pgpgin")) {
                memcpy( subbuff, &tmp[7], 40);
                subbuff[40] = '\0';
                pagein = atoi(subbuff);
            }
            if (strstr(tmp, "pgpgout")) {
                printf("\n\n%s", tmp);
                memcpy( subbuff, &tmp[7], 40);
                subbuff[40] = '\0';
                pageout = atoi(subbuff);
            }
        }
        printf("Res : %.2f \t %.2f",pagein-oldvalin,pageout-oldvalout);
        oldvalin = pagein;
        oldvalout = pageout;
        if(fp!=NULL) fclose(fp);
        sleep(1);
    }
}

Compare with vmstat command. Anything wrong in this code, please comment it. If any one knows about how to calculate latency time, please help me.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.