diff -Naur ganglia-monitor-core-2.5.7/gmetad/cleanup.c ganglia-monitor-core-2.5.7-mod/gmetad/cleanup.c --- ganglia-monitor-core-2.5.7/gmetad/cleanup.c 2004-09-09 20:55:05.000000000 -0300 +++ ganglia-monitor-core-2.5.7-mod/gmetad/cleanup.c 2005-02-09 03:14:21.000000000 -0200 @@ -175,6 +175,41 @@ } +/* For cleaning a summary of unused metrics */ +static int +cleanup_unused_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; +} + + +int cleanup_summary(hash_t *metric_summary) +{ + datum_t *rv; + struct cleanup_arg cleanup; + + cleanup.key = 0; + while (hash_walkfrom(metric_summary, cleanup.hashval, + cleanup_unused_metric, (void*) &cleanup)) { + + if (cleanup.key) { + cleanup.hashval = hashval(cleanup.key, metric_summary); + rv = hash_delete(cleanup.key, metric_summary); + if (rv) datum_free(rv); + } + } + return 0; +} + + void * cleanup_thread(void *arg) { diff -Naur ganglia-monitor-core-2.5.7/gmetad/data_thread.c ganglia-monitor-core-2.5.7-mod/gmetad/data_thread.c --- ganglia-monitor-core-2.5.7/gmetad/data_thread.c 2003-09-11 17:58:46.000000000 -0300 +++ ganglia-monitor-core-2.5.7-mod/gmetad/data_thread.c 2005-02-09 02:58:05.000000000 -0200 @@ -158,10 +158,25 @@ g_tcp_socket_delete(sock); gettimeofday(&end, NULL); - /* Sleep somewhere between (step +/- 5sec.) */ - sleep_time = (d->step - 5) + (10 * (rand()/(float)RAND_MAX)) - (end.tv_sec - start.tv_sec); - if( sleep_time > 0 ) - sleep(sleep_time); + if(d->step >= 5) + { + /* Sleep somewhere between (step +/- 5sec.) */ + sleep_time = (d->step - 5) + (10 * (rand () / (float) RAND_MAX)) - (end.tv_sec - start.tv_sec); + debug_msg ("Sleeping... sleep_time = %d, d->step=%d", sleep_time, d->step); + if (sleep_time > 0) + sleep (sleep_time); + } + else + { + /* Sleep somewhere between (step +/- step/4 sec.) */ + sleep_time = 1000000 * ((d->step - d->step / 4.0) + (rand () / (float) (RAND_MAX)) * d->step / 2.0); + debug_msg("Sleeping... sleep_time = %d, d->step=%d", sleep_time, d->step); + if(sleep_time >= 1000000) + usleep(sleep_time); + else + sleep (1); + } + } return NULL; } diff -Naur ganglia-monitor-core-2.5.7/gmetad/gmetad.c ganglia-monitor-core-2.5.7-mod/gmetad/gmetad.c --- ganglia-monitor-core-2.5.7/gmetad/gmetad.c 2004-09-09 20:55:05.000000000 -0300 +++ ganglia-monitor-core-2.5.7-mod/gmetad/gmetad.c 2005-02-09 03:15:12.000000000 -0200 @@ -31,7 +31,7 @@ extern struct type_tag* in_type_list (char *, unsigned int); extern int write_data_to_rrd( const char *source, const char *host, const char *metric, const char *sum, const char *num, unsigned int step, unsigned int time_polled); - +extern int cleanup_summary(hash_t *metric_summary); struct gengetopt_args_info args_info; extern gmetad_config_t gmetad_config; @@ -418,7 +418,10 @@ /* Sum the new values */ hash_foreach(root.authority, do_root_summary, NULL ); - + + /* Delete unused metrics */ + cleanup_summary(root.metric_summary); + /* Save them to RRD */ hash_foreach(root.metric_summary, write_root_summary, NULL); } diff -Naur ganglia-monitor-core-2.5.7/gmetad/rrd_helpers.c ganglia-monitor-core-2.5.7-mod/gmetad/rrd_helpers.c --- ganglia-monitor-core-2.5.7/gmetad/rrd_helpers.c 2003-05-29 19:13:17.000000000 -0300 +++ ganglia-monitor-core-2.5.7-mod/gmetad/rrd_helpers.c 2005-02-09 03:03:16.000000000 -0200 @@ -69,6 +69,12 @@ char s[16], start[64]; char sum[64]; char num[64]; + + char hour[64]; + char day[64]; + char week[64]; + char month[64]; + char year[64]; /* Our heartbeat is twice the step interval. */ heartbeat = 8*step; @@ -87,12 +93,29 @@ sprintf(num,"DS:num:GAUGE:%d:U:U", heartbeat); argv[argc++] = num; } + /* argv[argc++] = "RRA:AVERAGE:0.5:1:240"; argv[argc++] = "RRA:AVERAGE:0.5:24:240"; argv[argc++] = "RRA:AVERAGE:0.5:168:240"; argv[argc++] = "RRA:AVERAGE:0.5:672:240"; argv[argc++] = "RRA:AVERAGE:0.5:5760:370"; - + */ + + sprintf(hour,"RRA:AVERAGE:0.5:1:%d", 3600/step); + argv[argc++] = hour; + + sprintf(day,"RRA:AVERAGE:0.5:%d:240", (15*24)/step ); + argv[argc++] = day; + + sprintf(week,"RRA:AVERAGE:0.5:%d:240", (15*168)/step); + argv[argc++] = week; + + sprintf(month,"RRA:AVERAGE:0.5:%d:240", (15*672)/step); + argv[argc++] = month; + + sprintf(year,"RRA:AVERAGE:0.5:%d:240", (15*5760)/step); + argv[argc++] = year; + pthread_mutex_lock( &rrd_mutex ); optind=0; opterr=0; rrd_clear_error();