*** libmetrics/linux/metrics.c.ORIG	Tue May  4 17:16:42 2010
--- libmetrics/linux/metrics.c	Wed May  5 08:47:25 2010
***************
*** 616,648 ****
  /*
   * A helper function to return the total number of cpu jiffies
   */
! unsigned long
  total_jiffies_func ( void )
  {
     char *p;
!    unsigned long user_jiffies, nice_jiffies, system_jiffies, idle_jiffies,
!                  wio_jiffies, irq_jiffies, sirq_jiffies;
  
     p = update_file(&proc_stat);
     p = skip_token(p);
     p = skip_whitespace(p);
!    user_jiffies = strtod( p, &p );
     p = skip_whitespace(p);
!    nice_jiffies = strtod( p, &p ); 
     p = skip_whitespace(p);
!    system_jiffies = strtod( p , &p ); 
     p = skip_whitespace(p);
!    idle_jiffies = strtod( p , &p );
  
     if(num_cpustates == NUM_CPUSTATES_24X)
       return user_jiffies + nice_jiffies + system_jiffies + idle_jiffies;
  
     p = skip_whitespace(p);
!    wio_jiffies = strtod( p , &p );
     p = skip_whitespace(p);
!    irq_jiffies = strtod( p , &p );
     p = skip_whitespace(p);
!    sirq_jiffies = strtod( p , &p );
    
     return user_jiffies + nice_jiffies + system_jiffies + idle_jiffies +
            wio_jiffies + irq_jiffies + sirq_jiffies; 
--- 616,648 ----
  /*
   * A helper function to return the total number of cpu jiffies
   */
! unsigned long long
  total_jiffies_func ( void )
  {
     char *p;
!    unsigned long long user_jiffies, nice_jiffies, system_jiffies, idle_jiffies,
!                       wio_jiffies, irq_jiffies, sirq_jiffies;
  
     p = update_file(&proc_stat);
     p = skip_token(p);
     p = skip_whitespace(p);
!    user_jiffies = strtoll( p, &p, 10 );
     p = skip_whitespace(p);
!    nice_jiffies = strtoll( p, &p, 10 ); 
     p = skip_whitespace(p);
!    system_jiffies = strtoll( p , &p, 10 ); 
     p = skip_whitespace(p);
!    idle_jiffies = strtoll( p , &p, 10 );
  
     if(num_cpustates == NUM_CPUSTATES_24X)
       return user_jiffies + nice_jiffies + system_jiffies + idle_jiffies;
  
     p = skip_whitespace(p);
!    wio_jiffies = strtoll( p , &p, 10 );
     p = skip_whitespace(p);
!    irq_jiffies = strtoll( p , &p, 10 );
     p = skip_whitespace(p);
!    sirq_jiffies = strtoll( p , &p, 10 );
    
     return user_jiffies + nice_jiffies + system_jiffies + idle_jiffies +
            wio_jiffies + irq_jiffies + sirq_jiffies; 
***************
*** 655,662 ****
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static double last_user_jiffies,  user_jiffies, 
!                  last_total_jiffies, total_jiffies, diff;
     
     p = update_file(&proc_stat);
     if((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
--- 655,662 ----
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static long long last_user_jiffies,  user_jiffies, 
!                     last_total_jiffies, total_jiffies, diff;
     
     p = update_file(&proc_stat);
     if((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
***************
*** 664,676 ****
       stamp = proc_stat.last_read;
       
       p = skip_token(p);
!      user_jiffies  = strtod( p , (char **)NULL );
       total_jiffies = total_jiffies_func();
       
       diff = user_jiffies - last_user_jiffies; 
       
!      if ( diff )
!        val.f = (diff/(total_jiffies - last_total_jiffies))*100;
       else
         val.f = 0.0;
       
--- 664,676 ----
       stamp = proc_stat.last_read;
       
       p = skip_token(p);
!      user_jiffies  = strtoll( p, (char **)NULL, 10 );
       total_jiffies = total_jiffies_func();
       
       diff = user_jiffies - last_user_jiffies; 
       
!      if ( diff > 0LL )
!        val.f = ((double)diff)/(double)(total_jiffies - last_total_jiffies)*100.0;
       else
         val.f = 0.0;
       
***************
*** 687,694 ****
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static double last_nice_jiffies,  nice_jiffies,
!                  last_total_jiffies, total_jiffies, diff;
   
     p = update_file(&proc_stat);
     if((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
--- 687,694 ----
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static long long last_nice_jiffies,  nice_jiffies,
!                     last_total_jiffies, total_jiffies, diff;
   
     p = update_file(&proc_stat);
     if((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
***************
*** 697,709 ****
   
       p = skip_token(p);
       p = skip_token(p);
!      nice_jiffies  = strtod( p , (char **)NULL );
       total_jiffies = total_jiffies_func();
  
!      diff = (nice_jiffies  - last_nice_jiffies);
   
!      if ( diff )
!        val.f = (diff/(total_jiffies - last_total_jiffies))*100;
       else
         val.f = 0.0;
   
--- 697,709 ----
   
       p = skip_token(p);
       p = skip_token(p);
!      nice_jiffies  = strtoll( p, (char **)NULL, 10 );
       total_jiffies = total_jiffies_func();
  
!      diff = nice_jiffies - last_nice_jiffies;
   
!      if ( diff > 0LL )
!        val.f = ((double)diff)/(double)(total_jiffies - last_total_jiffies)*100.0;
       else
         val.f = 0.0;
   
***************
*** 720,727 ****
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static double last_system_jiffies,  system_jiffies,
!                  last_total_jiffies, total_jiffies, diff;
   
     p = update_file(&proc_stat);
     if((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
--- 720,727 ----
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static long long last_system_jiffies,  system_jiffies,
!                     last_total_jiffies, total_jiffies, diff;
   
     p = update_file(&proc_stat);
     if((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
***************
*** 731,751 ****
       p = skip_token(p);
       p = skip_token(p);
       p = skip_token(p);
!      system_jiffies = strtod( p , (char **)NULL );
       if (num_cpustates > NUM_CPUSTATES_24X) {
         p = skip_token(p);
         p = skip_token(p);
         p = skip_token(p);
!        system_jiffies += strtod( p , (char **)NULL ); /* "intr" counted in system */
         p = skip_token(p);
!        system_jiffies += strtod( p , (char **)NULL ); /* "sintr" counted in system */
         }
!      total_jiffies  = total_jiffies_func();
  
!      diff = system_jiffies  - last_system_jiffies;
   
!      if ( diff )
!        val.f = (diff/(total_jiffies - last_total_jiffies))*100;
       else
         val.f = 0.0;
   
--- 731,751 ----
       p = skip_token(p);
       p = skip_token(p);
       p = skip_token(p);
!      system_jiffies = strtoll( p , (char **)NULL, 10 );
       if (num_cpustates > NUM_CPUSTATES_24X) {
         p = skip_token(p);
         p = skip_token(p);
         p = skip_token(p);
!        system_jiffies += strtoll( p, (char **)NULL, 10 ); /* "intr" counted in system */
         p = skip_token(p);
!        system_jiffies += strtoll( p, (char **)NULL, 10 ); /* "sintr" counted in system */
         }
!      total_jiffies = total_jiffies_func();
  
!      diff = system_jiffies - last_system_jiffies;
   
!      if ( diff > 0LL )
!        val.f = ((double)diff)/(double)(total_jiffies - last_total_jiffies)*100.0;
       else
         val.f = 0.0;
   
***************
*** 762,769 ****
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static double last_idle_jiffies,  idle_jiffies,
!                  last_total_jiffies, total_jiffies, diff;
   
     p = update_file(&proc_stat);
     if((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
--- 762,769 ----
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static long long last_idle_jiffies,  idle_jiffies,
!                     last_total_jiffies, total_jiffies, diff;
   
     p = update_file(&proc_stat);
     if((proc_stat.last_read.tv_sec != stamp.tv_sec) &&
***************
*** 774,786 ****
       p = skip_token(p);
       p = skip_token(p);
       p = skip_token(p);
!      idle_jiffies  = strtod( p , (char **)NULL );
       total_jiffies = total_jiffies_func();
       
       diff = idle_jiffies - last_idle_jiffies;
       
!      if ( diff ) 
!        val.f = (diff/(total_jiffies - last_total_jiffies))*100;
       else
         val.f = 0.0;
       
--- 774,786 ----
       p = skip_token(p);
       p = skip_token(p);
       p = skip_token(p);
!      idle_jiffies  = strtoll( p, (char **)NULL, 10 );
       total_jiffies = total_jiffies_func();
       
       diff = idle_jiffies - last_idle_jiffies;
       
!      if ( diff > 0LL ) 
!        val.f = ((double)diff)/(double)(total_jiffies - last_total_jiffies)*100.0;
       else
         val.f = 0.0;
       
***************
*** 797,803 ****
  {
     char *p;
     g_val_t val;
!    double idle_jiffies, total_jiffies;
     
     p = update_file(&proc_stat);
  
--- 797,803 ----
  {
     char *p;
     g_val_t val;
!    long long idle_jiffies, total_jiffies;
     
     p = update_file(&proc_stat);
  
***************
*** 805,814 ****
     p = skip_token(p);
     p = skip_token(p);
     p = skip_token(p);
!    idle_jiffies  = strtod( p , (char **)NULL );
     total_jiffies = total_jiffies_func();
     
!    val.f = (idle_jiffies/total_jiffies)*100;
     return val;
  }
  
--- 805,814 ----
     p = skip_token(p);
     p = skip_token(p);
     p = skip_token(p);
!    idle_jiffies  = strtoll( p, (char **)NULL, 10 );
     total_jiffies = total_jiffies_func();
     
!    val.f = ((double)idle_jiffies/total_jiffies)*100.0;
     return val;
  }
  
***************
*** 818,825 ****
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static double last_wio_jiffies,  wio_jiffies,
!                  last_total_jiffies, total_jiffies, diff;
   
     if (num_cpustates == NUM_CPUSTATES_24X) {
       val.f = 0.;
--- 818,825 ----
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static long long last_wio_jiffies,  wio_jiffies,
!                     last_total_jiffies, total_jiffies, diff;
   
     if (num_cpustates == NUM_CPUSTATES_24X) {
       val.f = 0.;
***************
*** 836,848 ****
       p = skip_token(p);
       p = skip_token(p);
       p = skip_token(p);
!      wio_jiffies  = strtod( p , (char **)NULL );
       total_jiffies = total_jiffies_func();
       
       diff = wio_jiffies - last_wio_jiffies;
       
!      if ( diff ) 
!        val.f = (diff/(total_jiffies - last_total_jiffies))*100;
       else
         val.f = 0.0;
       
--- 836,848 ----
       p = skip_token(p);
       p = skip_token(p);
       p = skip_token(p);
!      wio_jiffies   = strtoll( p, (char **)NULL, 10 );
       total_jiffies = total_jiffies_func();
       
       diff = wio_jiffies - last_wio_jiffies;
       
!      if ( diff > 0LL ) 
!        val.f = ((double)diff)/(double)(total_jiffies - last_total_jiffies)*100.0;
       else
         val.f = 0.0;
       
***************
*** 860,867 ****
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static double last_intr_jiffies,  intr_jiffies,
!                  last_total_jiffies, total_jiffies, diff;
   
     if (num_cpustates == NUM_CPUSTATES_24X) {
       val.f = 0.;
--- 860,867 ----
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static long long last_intr_jiffies,  intr_jiffies,
!                     last_total_jiffies, total_jiffies, diff;
   
     if (num_cpustates == NUM_CPUSTATES_24X) {
       val.f = 0.;
***************
*** 879,891 ****
       p = skip_token(p);
       p = skip_token(p);
       p = skip_token(p);
!      intr_jiffies  = strtod( p , (char **)NULL );
       total_jiffies = total_jiffies_func();
       
       diff = intr_jiffies - last_intr_jiffies;
       
!      if ( diff ) 
!        val.f = (diff/(total_jiffies - last_total_jiffies))*100;
       else
         val.f = 0.0;
       
--- 879,891 ----
       p = skip_token(p);
       p = skip_token(p);
       p = skip_token(p);
!      intr_jiffies  = strtoll( p, (char **)NULL, 10 );
       total_jiffies = total_jiffies_func();
       
       diff = intr_jiffies - last_intr_jiffies;
       
!      if ( diff  > 0LL) 
!        val.f = ((double)diff)/(double)(total_jiffies - last_total_jiffies)*100.0;
       else
         val.f = 0.0;
       
***************
*** 903,910 ****
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static double last_sintr_jiffies,  sintr_jiffies,
!                  last_total_jiffies, total_jiffies, diff;
   
     if (num_cpustates == NUM_CPUSTATES_24X) {
       val.f = 0.;
--- 903,910 ----
     char *p;
     static g_val_t val;
     static struct timeval stamp={0,0};
!    static long long last_sintr_jiffies, sintr_jiffies,
!                     last_total_jiffies, total_jiffies, diff;
   
     if (num_cpustates == NUM_CPUSTATES_24X) {
       val.f = 0.;
***************
*** 923,935 ****
       p = skip_token(p);
       p = skip_token(p);
       p = skip_token(p);
!      sintr_jiffies  = strtod( p , (char **)NULL );
       total_jiffies = total_jiffies_func();
       
       diff = sintr_jiffies - last_sintr_jiffies;
       
!      if ( diff ) 
!        val.f = (diff/(total_jiffies - last_total_jiffies))*100;
       else
         val.f = 0.0;
       
--- 923,935 ----
       p = skip_token(p);
       p = skip_token(p);
       p = skip_token(p);
!      sintr_jiffies = strtoll( p, (char **)NULL, 10 );
       total_jiffies = total_jiffies_func();
       
       diff = sintr_jiffies - last_sintr_jiffies;
       
!      if ( diff > 0LL ) 
!        val.f = ((double)diff)/(double)(total_jiffies - last_total_jiffies)*100.0;
       else
         val.f = 0.0;
       
*** ./scripts/fixconfig.in.ORIG	Fri May  7 11:46:05 2010
--- ./scripts/fixconfig.in	Fri May  7 11:46:24 2010
***************
*** 47,53 ****
  
  # We can probably just assume sed is on the path, but since we have it, we may
  # as well use it.
! SED="@SED@"
  
  input="$1"
  if [ -z "$input" ] ; then
--- 47,53 ----
  
  # We can probably just assume sed is on the path, but since we have it, we may
  # as well use it.
! SED="/bin/sed"
  
  input="$1"
  if [ -z "$input" ] ; then
