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

Diff for /src/usr.bin/systat/vmstat.c between version 1.66 and 1.67

version 1.66, 2008/11/01 00:56:25 version 1.67, 2008/12/07 02:56:06
Line 493 
Line 493 
 static float  static float
 cputime(int indx)  cputime(int indx)
 {  {
         double t;          double tm;
         int i;          int i;
   
         t = 0;          tm = 0;
         for (i = 0; i < CPUSTATES; i++)          for (i = 0; i < CPUSTATES; i++)
                 t += s.time[i];                  tm += s.time[i];
         if (t == 0.0)          if (tm == 0.0)
                 t = 1.0;                  tm = 1.0;
         return (s.time[indx] * 100.0 / t);          return (s.time[indx] * 100.0 / tm);
 }  }
   
 void  void
Line 565 
Line 565 
 }  }
   
 static void  static void
 getinfo(struct Info *s)  getinfo(struct Info *si)
 {  {
         static int cp_time_mib[] = { CTL_KERN, KERN_CPTIME };          static int cp_time_mib[] = { CTL_KERN, KERN_CPTIME };
         static int nchstats_mib[2] = { CTL_KERN, KERN_NCHSTATS };          static int nchstats_mib[2] = { CTL_KERN, KERN_NCHSTATS };
Line 581 
Line 581 
                 mib[1] = KERN_INTRCNT;                  mib[1] = KERN_INTRCNT;
                 mib[2] = KERN_INTRCNT_CNT;                  mib[2] = KERN_INTRCNT_CNT;
                 mib[3] = i;                  mib[3] = i;
                 size = sizeof(s->intrcnt[i]);                  size = sizeof(si->intrcnt[i]);
                 if (sysctl(mib, 4, &s->intrcnt[i], &size, NULL, 0) < 0) {                  if (sysctl(mib, 4, &si->intrcnt[i], &size, NULL, 0) < 0) {
                         s->intrcnt[i] = 0;                          si->intrcnt[i] = 0;
                 }                  }
         }          }
   
         size = sizeof(s->time);          size = sizeof(si->time);
         if (sysctl(cp_time_mib, 2, &s->time, &size, NULL, 0) < 0) {          if (sysctl(cp_time_mib, 2, &si->time, &size, NULL, 0) < 0) {
                 error("Can't get KERN_CPTIME: %s\n", strerror(errno));                  error("Can't get KERN_CPTIME: %s\n", strerror(errno));
                 bzero(&s->time, sizeof(s->time));                  bzero(&si->time, sizeof(si->time));
         }          }
   
         size = sizeof(s->nchstats);          size = sizeof(si->nchstats);
         if (sysctl(nchstats_mib, 2, &s->nchstats, &size, NULL, 0) < 0) {          if (sysctl(nchstats_mib, 2, &si->nchstats, &size, NULL, 0) < 0) {
                 error("Can't get KERN_NCHSTATS: %s\n", strerror(errno));                  error("Can't get KERN_NCHSTATS: %s\n", strerror(errno));
                 bzero(&s->nchstats, sizeof(s->nchstats));                  bzero(&si->nchstats, sizeof(si->nchstats));
         }          }
   
         size = sizeof(s->uvmexp);          size = sizeof(si->uvmexp);
         if (sysctl(uvmexp_mib, 2, &s->uvmexp, &size, NULL, 0) < 0) {          if (sysctl(uvmexp_mib, 2, &si->uvmexp, &size, NULL, 0) < 0) {
                 error("Can't get VM_UVMEXP: %s\n", strerror(errno));                  error("Can't get VM_UVMEXP: %s\n", strerror(errno));
                 bzero(&s->uvmexp, sizeof(s->uvmexp));                  bzero(&si->uvmexp, sizeof(si->uvmexp));
         }          }
   
         size = sizeof(s->Total);          size = sizeof(si->Total);
         if (sysctl(vmtotal_mib, 2, &s->Total, &size, NULL, 0) < 0) {          if (sysctl(vmtotal_mib, 2, &si->Total, &size, NULL, 0) < 0) {
                 error("Can't get VM_METER: %s\n", strerror(errno));                  error("Can't get VM_METER: %s\n", strerror(errno));
                 bzero(&s->Total, sizeof(s->Total));                  bzero(&si->Total, sizeof(si->Total));
         }          }
 }  }
   
 static void  static void
 allocinfo(struct Info *s)  allocinfo(struct Info *si)
 {  {
         memset(s, 0, sizeof(*s));          memset(si, 0, sizeof(*si));
         s->intrcnt = (u_quad_t *) calloc(nintr, sizeof(u_quad_t));          si->intrcnt = (u_quad_t *) calloc(nintr, sizeof(u_quad_t));
         if (s->intrcnt == NULL)          if (si->intrcnt == NULL)
                 errx(2, "out of memory");                  errx(2, "out of memory");
 }  }
   

Legend:
Removed from v.1.66  
changed lines
  Added in v.1.67