Skip to content

Instantly share code, notes, and snippets.

@kinichiro
Created August 13, 2014 08:05
Show Gist options
  • Save kinichiro/4bd44c2f164efafa079a to your computer and use it in GitHub Desktop.
Save kinichiro/4bd44c2f164efafa079a to your computer and use it in GitHub Desktop.
sample code for pstat_getvminfo()
/* test_pstat_getvminfo.c */
#include <stdio.h>
#include <sys/pstat.h>
int main() {
struct pst_vminfo buf;
if(pstat_getvminfo(&buf, sizeof(buf), 1, 0) != 1) {
perror("pstat_getvminfo()");
return -1;
}
printf("++++++++++----------++++++++++----------++++++++++----------\n");
printf("rate: cpages freed by daemon = %d\n", buf.psv_rdfree);
printf("device interrupts = %d\n", buf.psv_rintr);
printf("pages paged in = %d\n", buf.psv_rpgpgin);
printf("pages paged out = %d\n", buf.psv_rpgpgout);
printf("total page reclaims = %d\n", buf.psv_rpgrec);
printf("tlb flushes - 800 only = %d\n", buf.psv_rpgtlb);
printf("scans in pageout daemon = %d\n", buf.psv_rscan);
printf("context switches = %d\n", buf.psv_rswtch);
printf("calls to syscall() = %d\n", buf.psv_rsyscall);
printf("found in freelist rather than in filesys = %d\n", buf.psv_rxifrec);
printf("found in freelist rather than on swapdev = %d\n", buf.psv_rxsfrec);
printf("number of characters read from ttys = %d\n", buf.psv_tknin);
printf("number of characters written to ttys = %d\n", buf.psv_tknout);
printf("Rate pages swapped in = %d\n", buf.psv_rpswpin);
printf("Rate pages swapped out = %d\n", buf.psv_rpswpout);
printf("Rate pageins = %d\n", buf.psv_rpgin);
printf("Rate pageouts = %d\n", buf.psv_rpgout);
printf("Rate faults taken = %d\n", buf.psv_rfaults);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment