|
Right, I think the only remaing one using double to store
system_jiffies is the cygwin. I'm attatching a patch for cygwin (based on the linux changes). <- NOT tested Att,
On 05-05-2010 19:47, Jesse Becker wrote: I also looked at similar code for several other operating systems. At least some of them already store the counters as 'unsigned long long', and do a conversion right before returning the data. | ||||||||
Index: metrics.c
===================================================================
--- metrics.c (revisão 2294)
+++ metrics.c (cópia de trabalho)
@@ -23,7 +23,9 @@
#include <mntent.h>
#include <sys/vfs.h>
#include <psapi.h>
+#define JT unsigned long long
+
/* From old ganglia 2.5.x... */
#include "file.h"
#include "libmetrics.h"
@@ -470,11 +472,11 @@
/*
* A helper function to return the total number of cpu jiffies
*/
-unsigned long
+JT
total_jiffies_func ( void )
{
char *p;
- unsigned long user_jiffies, nice_jiffies, system_jiffies, idle_jiffies;
+ JT user_jiffies, nice_jiffies, system_jiffies, idle_jiffies;
p = update_file(&proc_stat);
p = skip_token(p);
@@ -496,8 +498,8 @@
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;
+ static JT 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) &&
@@ -511,7 +513,7 @@
diff = user_jiffies - last_user_jiffies;
if ( diff )
- val.f = (diff/(total_jiffies - last_total_jiffies))*100;
+ val.f = ((double)diff/(double)(total_jiffies - last_total_jiffies)) * 100.0;
else
val.f = 0.0;
@@ -528,8 +530,8 @@
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;
+ static JT 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) &&
@@ -544,7 +546,7 @@
diff = (nice_jiffies - last_nice_jiffies);
if ( diff )
- val.f = (diff/(total_jiffies - last_total_jiffies))*100;
+ val.f = ((double)diff/(double)(total_jiffies - last_total_jiffies)) * 100.0;
else
val.f = 0.0;
@@ -561,8 +563,8 @@
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;
+ static JT 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) &&
@@ -586,7 +588,7 @@
diff = system_jiffies - last_system_jiffies;
if ( diff )
- val.f = (diff/(total_jiffies - last_total_jiffies))*100;
+ val.f = ((double)diff/(double)(total_jiffies - last_total_jiffies)) * 100.0;
else
val.f = 0.0;
@@ -603,8 +605,8 @@
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;
+ static JT 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) &&
@@ -621,7 +623,7 @@
diff = idle_jiffies - last_idle_jiffies;
if ( diff )
- val.f = (diff/(total_jiffies - last_total_jiffies))*100;
+ val.f = ((double)diff/(double)(total_jiffies - last_total_jiffies)) * 100.0;
else
val.f = 0.0;
------------------------------------------------------------------------------
_______________________________________________ Ganglia-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ganglia-developers


MM17 Hortolândia-SP, Brazil


MM17
Hortolândia-SP, Brazil