/* Assumes num argument will be NULL for a host RRD. */
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 process_time, ganglia_slope_t slope)
{
   char rrd[ PATHSIZE ];
   char *summary_dir = "__SummaryInfo__";

   /* Build the path to our desired RRD file. Assume the rootdir exists. */
   strcpy(rrd, gmetad_config.rrd_rootdir);

   if (source) {
      strncat(rrd, "/", PATHSIZE);
      strncat(rrd, source, PATHSIZE);
      my_mkdir( rrd );
   }

   if (host) {
      strncat(rrd, "/", PATHSIZE);
      strncat(rrd, host, PATHSIZE);
      my_mkdir( rrd );
   }
   else {
      strncat(rrd, "/", PATHSIZE);
      strncat(rrd, summary_dir, PATHSIZE);
      my_mkdir( rrd );
   }

   strncat(rrd, "/", PATHSIZE);
   strncat(rrd, metric, PATHSIZE);
   strncat(rrd, ".rrd", PATHSIZE);

   return push_data_to_rrd( rrd, sum, num, step, process_time, slope);
}
Example #2
0
/* Assumes num argument will be NULL for a host RRD. */
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 process_time, ganglia_slope_t slope)
{
   apr_time_t start = apr_time_now(), now;
   char rrd[ PATHSIZE + 1 ];
   char *summary_dir = "__SummaryInfo__";
   int i;
   int ret;

   /* Build the path to our desired RRD file. Assume the rootdir exists. */
   strncpy(rrd, gmetad_config.rrd_rootdir, PATHSIZE);

   if (source) {
      strncat(rrd, "/", PATHSIZE-strlen(rrd));
      strncat(rrd, source, PATHSIZE-strlen(rrd));
      my_mkdir( rrd );
   }

   if (host) {
      strncat(rrd, "/", PATHSIZE-strlen(rrd));
      i = strlen(rrd);
      strncat(rrd, host, PATHSIZE-strlen(rrd));
      if(gmetad_config.case_sensitive_hostnames == 0) {
         /* Convert the hostname to lowercase */
         for( ; rrd[i] != 0; i++)
            rrd[i] = tolower(rrd[i]);
      }
      my_mkdir( rrd );
   }
   else {
      strncat(rrd, "/", PATHSIZE-strlen(rrd));
      strncat(rrd, summary_dir, PATHSIZE-strlen(rrd));
      my_mkdir( rrd );
   }

   strncat(rrd, "/", PATHSIZE-strlen(rrd));
   strncat(rrd, metric, PATHSIZE-strlen(rrd));
   strncat(rrd, ".rrd", PATHSIZE-strlen(rrd));

   ret = push_data_to_rrd( rrd, sum, num, step, process_time, slope);
   now = apr_time_now();
   ganglia_scoreboard_incby(METS_ALL_DURATION, now - start);
   ganglia_scoreboard_incby(METS_RRDTOOLS_DURATION, now - start);
   return ret;
}