Marcelo,

That is my code, and you may be right. I cannot tell what is your new logic. Can you send me a diff to the original (2.5.7) code?

Federico

On Jan 2, 2005, at 2:38 PM, Marcelo Veiga Neves wrote:

hi,

i think i found a bug in gmetad (latest version 2.5.7).

write_root_summary() writes data to RRD forever! and gmetad never
clean up metric summaries (root.metric_summary). i think that if a
metric was not modified (by do_root_summary()), then it does not have
to be written to RRD.


I do it in gmetad/gmetad.c:

static int
delete_metric(datum_t *key, datum_t *val
, void *arg)
{
   Metric_t *metric = (Metric_t*)val->data;
   struct cleanup_arg *cleanup = (struct cleanup_arg*)arg;

   if(metric->num == 0) {
        cleanup->key=key;
        return 1;
   }

   return 0;
}

static int
cleanup_root_summary(hash_t *metric_summary)
{
   datum_t *rv;
   struct cleanup_arg clean;
   clean.key=0;

   while (hash_walkfrom(metric_summary, clean.hashval, delete_metric,
(void*)&clean)) {
      if (clean.key) {
         clean.hashval = hashval(clean.key, metric_summary);
         rv=hash_delete(clean.key, metric_summary);
         if (rv) datum_free(rv);
         clean.key=0;
      }
   }
}

 /* Meta data */
   for(;;)
      {
         /* Do at a random interval between 10 and 30 sec. */
         sleep_time = 10 + ((30-10)*1.0) * rand()/(RAND_MAX + 1.0);
         sleep(sleep_time);

         /* Flush the old values */
         hash_foreach(root.metric_summary, zero_out_summary, NULL);
         root.hosts_up = 0;
         root.hosts_down = 0;
        
         /* Sum the new values */
         hash_foreach(root.authority, do_root_summary, NULL );
        
        /* Delete dead metrics */
        cleanup_root_summary(root.metric_summary);
        
         /* Save them to RRD */
         hash_foreach(root.metric_summary, write_root_summary, NULL);
      }


Am I Right?


Marcelo Veiga Neves
http://www.inf.ufsm.br/~veiga

--
-- "talk is cheap, show me the code"


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Ganglia-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ganglia-developers

Federico

Rocks Cluster Group, San Diego Supercomputer Center, CA


Reply via email to