[BACK]Return to vmstat.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / vmstat

Diff for /src/usr.bin/vmstat/vmstat.c between version 1.52 and 1.53

version 1.52, 2001/05/11 06:46:40 version 1.53, 2001/05/11 14:35:29
Line 84 
Line 84 
 #endif  #endif
   
 struct nlist namelist[] = {  struct nlist namelist[] = {
 #define X_CPTIME        0  
         { "_cp_time" },  
 #if defined(UVM)  #if defined(UVM)
 #define X_UVMEXP        1  #define X_UVMEXP        0
         { "_uvmexp" },          { "_uvmexp" },
 #else  #else
 #define X_SUM           1  #define X_SUM           0
         { "_cnt" },          { "_cnt" },
 #endif  #endif
 #define X_BOOTTIME      2  #define X_BOOTTIME      1
         { "_boottime" },          { "_boottime" },
 #define X_HZ            3  #define X_NCHSTATS      2
         { "_hz" },  
 #define X_STATHZ        4  
         { "_stathz" },  
 #define X_NCHSTATS      5  
         { "_nchstats" },          { "_nchstats" },
 #define X_INTRNAMES     6  #define X_INTRNAMES     3
         { "_intrnames" },          { "_intrnames" },
 #define X_EINTRNAMES    7  #define X_EINTRNAMES    4
         { "_eintrnames" },          { "_eintrnames" },
 #define X_INTRCNT       8  #define X_INTRCNT       5
         { "_intrcnt" },          { "_intrcnt" },
 #define X_EINTRCNT      9  #define X_EINTRCNT      6
         { "_eintrcnt" },          { "_eintrcnt" },
 #define X_KMEMSTAT      10  #define X_KMEMSTAT      7
         { "_kmemstats" },          { "_kmemstats" },
 #define X_KMEMBUCKETS   11  #define X_KMEMBUCKETS   8
         { "_bucket" },          { "_bucket" },
 #define X_ALLEVENTS     12  #define X_ALLEVENTS     9
         { "_allevents" },          { "_allevents" },
 #define X_FORKSTAT      13  #define X_FORKSTAT      10
         { "_forkstat" },          { "_forkstat" },
 #define X_POOLHEAD      14  #define X_POOLHEAD      11
         { "_pool_head" },          { "_pool_head" },
 #define X_NSELCOLL      15  #define X_NSELCOLL      12
         { "_nselcoll" },          { "_nselcoll" },
 #define X_END           16  #define X_END           13
 #if defined(__pc532__)  
 #define X_IVT           (X_END)  
         { "_ivt" },  
 #endif  
 #if defined(__i386__)  #if defined(__i386__)
 #define X_INTRHAND      (X_END)  #define X_INTRHAND      (X_END)
         { "_intrhand" },          { "_intrhand" },
Line 364 
Line 354 
                         mib[1] = KERN_BOOTTIME;                          mib[1] = KERN_BOOTTIME;
                         if (sysctl(mib, 2, &boottime, &size, NULL, 0) < 0) {                          if (sysctl(mib, 2, &boottime, &size, NULL, 0) < 0) {
                                 printf("Can't get kerninfo: %s\n",                                  printf("Can't get kerninfo: %s\n",
                                        strerror(errno));                                      strerror(errno));
                                 bzero(&boottime, sizeof(boottime));                                  bzero(&boottime, sizeof(boottime));
                         }                          }
                 }                  }
Line 418 
Line 408 
                         mib[1] = VM_UVMEXP;                          mib[1] = VM_UVMEXP;
                         if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) {                          if (sysctl(mib, 2, &uvmexp, &size, NULL, 0) < 0) {
                                 printf("Can't get kerninfo: %s\n",                                  printf("Can't get kerninfo: %s\n",
                                        strerror(errno));                                      strerror(errno));
                                 bzero(&uvmexp, sizeof(uvmexp));                                  bzero(&uvmexp, sizeof(uvmexp));
                         }                          }
                 }                  }
Line 786 
Line 776 
         (void)printf("%2.0f", cur.cp_time[CP_IDLE] * pct);          (void)printf("%2.0f", cur.cp_time[CP_IDLE] * pct);
 }  }
   
 #if defined(__pc532__)  #if defined(__i386__)
 /* To get struct iv ...*/  
 #define _KERNEL  
 #include <machine/psl.h>  
 #undef _KERNEL  
 void  
 dointr()  
 {  
         register long i, j, inttotal;  
         time_t uptime;  
         static char iname[64];  
         struct iv ivt[32], *ivp = ivt;  
   
         iname[63] = '\0';  
         uptime = getuptime();  
         kread(X_IVT, ivp, sizeof(ivt));  
   
         for (i = 0; i < 2; i++) {  
                 (void)printf("%sware interrupts:\n", i ? "\nsoft" : "hard");  
                 (void)printf("interrupt         total     rate\n");  
                 inttotal = 0;  
                 for (j = 0; j < 16; j++, ivp++) {  
                         if (ivp->iv_vec && ivp->iv_use && ivp->iv_cnt) {  
                                 if (kvm_read(kd, (u_long)ivp->iv_use, iname, 63) != 63) {  
                                         errx(1, "iv_use: %s", kvm_geterr(kd));  
                                 }  
                                 (void)printf("%-12s %10ld %8ld\n", iname,  
                                     ivp->iv_cnt, ivp->iv_cnt / uptime);  
                                 inttotal += ivp->iv_cnt;  
                         }  
                 }  
                 (void)printf("Total        %10ld %8ld\n",  
                     inttotal, inttotal / uptime);  
         }  
 }  
 #elif defined(__i386__)  
 /* To get struct intrhand */  /* To get struct intrhand */
 #define _KERNEL  #define _KERNEL
 #include <machine/psl.h>  #include <machine/psl.h>
Line 860 
Line 815 
         for (i = 0; i < 16; i++)          for (i = 0; i < 16; i++)
                 if (intrstray[i]) {                  if (intrstray[i]) {
                         printf("Stray irq %-2d     %10lu %8lu\n",                          printf("Stray irq %-2d     %10lu %8lu\n",
                                i, intrstray[i], intrstray[i] / uptime);                              i, intrstray[i], intrstray[i] / uptime);
                         inttotal += intrstray[i];                          inttotal += intrstray[i];
                 }                  }
         printf("Total            %10lu %8lu\n", inttotal, inttotal / uptime);          printf("Total            %10lu %8lu\n", inttotal, inttotal / uptime);
Line 940 
Line 895 
         char buf[BUFSIZ], *bufp, *ap;          char buf[BUFSIZ], *bufp, *ap;
   
         if (memf == NULL && nlistf == NULL) {          if (memf == NULL && nlistf == NULL) {
                 mib[0] = CTL_KERN;                  mib[0] = CTL_KERN;
                 mib[1] = KERN_MALLOCSTATS;                  mib[1] = KERN_MALLOCSTATS;
                 mib[2] = KERN_MALLOC_BUCKETS;                  mib[2] = KERN_MALLOC_BUCKETS;
                 siz = sizeof(buf);                  siz = sizeof(buf);
                 if (sysctl(mib, 3, buf, &siz, NULL, 0) < 0) {                  if (sysctl(mib, 3, buf, &siz, NULL, 0) < 0) {
                         printf("Could not acquire information on kernel memory bucket sizes.\n");                          printf("Could not acquire information on kernel memory bucket sizes.\n");
                         return;                          return;
                 }                  }
   
Line 954 
Line 909 
                 siz = sizeof(struct kmembuckets);                  siz = sizeof(struct kmembuckets);
                 i = 0;                  i = 0;
                 while ((ap = strsep(&bufp, ",")) != NULL) {                  while ((ap = strsep(&bufp, ",")) != NULL) {
                         mib[3] = atoi(ap);                          mib[3] = atoi(ap);
   
                         if (sysctl(mib, 4, &buckets[MINBUCKET + i], &siz,                          if (sysctl(mib, 4, &buckets[MINBUCKET + i], &siz,
                                    NULL, 0) < 0) {                              NULL, 0) < 0) {
                                 printf("Failed to read statistics for bucket %d.\n", mib[3]);                                  printf("Failed to read statistics for bucket %d.\n",
                                       mib[3]);
                                 return;                                  return;
                         }                          }
                         i++;                          i++;
                 }                  }
         } else {          } else {
                 kread(X_KMEMBUCKETS, buckets, sizeof(buckets));                  kread(X_KMEMBUCKETS, buckets, sizeof(buckets));
         }          }
   
         for (first = 1, i = MINBUCKET, kp = &buckets[i]; i < MINBUCKET + 16;          for (first = 1, i = MINBUCKET, kp = &buckets[i]; i < MINBUCKET + 16;
Line 998 
Line 954 
         if (memf == NULL && nlistf == NULL) {          if (memf == NULL && nlistf == NULL) {
                 bzero(kmemstats, sizeof(kmemstats));                  bzero(kmemstats, sizeof(kmemstats));
                 for (i = 0; i < M_LAST; i++) {                  for (i = 0; i < M_LAST; i++) {
                         mib[0] = CTL_KERN;                          mib[0] = CTL_KERN;
                         mib[1] = KERN_MALLOCSTATS;                          mib[1] = KERN_MALLOCSTATS;
                         mib[2] = KERN_MALLOC_KMEMSTATS;                          mib[2] = KERN_MALLOC_KMEMSTATS;
                         mib[3] = i;                          mib[3] = i;

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.53