Example #1
0
/* Parse the file assuming there are multiple summaries in it. Summary
   boundaries are lines starting with # */
struct list *rmsummary_parse_file_multiple(char *filename)
{
	FILE *stream;
	stream = fopen(filename, "r");
	if(!stream)
	{
		debug(D_NOTICE, "Cannot open resources summary file: %s : %s\n", filename, strerror(errno));
		return NULL;
	}

	struct list      *lst = list_create(0);
	struct rmsummary *s;

	do
	{
		s = rmsummary_parse_next(stream);

		if(s)
			list_push_tail(lst, s);
	} while(s);

	fclose(stream);

	return lst;
}
Example #2
0
/* Parse the file, assuming there is a single summary in it. */
struct rmsummary *rmsummary_parse_file_single(const char *filename)
{
	FILE *stream;
	stream = fopen(filename, "r");

	if(!stream)
	{
		debug(D_NOTICE, "Cannot open resources summary file: %s : %s\n", filename, strerror(errno));
		return NULL;
	}

	struct rmsummary *s = rmsummary_parse_next(stream);
	fclose(stream);

	return s;
}
Example #3
0
struct rmDsummary *parse_summary(FILE *stream, char *filename, struct hash_table *categories)
{
	static FILE *last_stream = NULL;
	static int   summ_id     = 1;

	if(last_stream != stream)
	{
		last_stream = stream;
		summ_id     = 1;
	}
	else
	{
		summ_id++;
	}

	struct rmsummary  *so = rmsummary_parse_next(stream);
	if(!so)
		return NULL;

	if(categories) {
		struct category *c = category_lookup_or_create(categories, ALL_SUMMARIES_CATEGORY);
		category_accumulate_summary(c, so, NULL);
		if(so->category) {
			c = category_lookup_or_create(categories, so->category);
			category_accumulate_summary(c, so, NULL);
		}
	}

	struct rmDsummary *s  = rmsummary_to_rmDsummary(so);

	s->file = xxstrdup(filename);
	if(!s->task_id) {
		s->task_id = get_rule_number(filename);
	}

	rmsummary_delete(so);

	return s;
}
Example #4
0
struct rmDsummary *parse_summary(FILE *stream, char *filename)
{
	static FILE *last_stream = NULL;
	static int   summ_id     = 1;

	if(last_stream != stream)
	{
		last_stream = stream;
		summ_id     = 1;
	}
	else
	{
		summ_id++;
	}

	struct rmsummary  *so = rmsummary_parse_next(stream);

	if(!so)
		return NULL;

	struct rmDsummary *s  = malloc(sizeof(struct rmDsummary));

	s->command    = so->command;

	s->file       = xxstrdup(filename);

	if(so->category)
	{
		s->category   = so->category;
	}
	else if(so->command)
	{
		s->category   = parse_executable_name(so->command);
	}
	else
	{
		s->category   = xxstrdup(DEFAULT_CATEGORY);
		s->command    = xxstrdup(DEFAULT_CATEGORY);
	}

	s->start     = usecs_to_secs(so->start);
	s->end       = usecs_to_secs(so->end);
	s->wall_time = usecs_to_secs(so->wall_time);
	s->cpu_time  = usecs_to_secs(so->cpu_time);

	s->cores = so->cores;
	s->total_processes = so->total_processes;
	s->max_concurrent_processes = so->max_concurrent_processes;

	s->virtual_memory = so->virtual_memory;
	s->resident_memory = so->resident_memory;
	s->swap_memory = so->swap_memory;

	s->bytes_read    = bytes_to_Mbytes(so->bytes_read);
	s->bytes_written = bytes_to_Mbytes(so->bytes_written);

	s->workdir_num_files = so->workdir_num_files;
	s->workdir_footprint = so->workdir_footprint;

	s->task_id = so->task_id;
	if(s->task_id < 0)
	{
		s->task_id = get_rule_number(filename);
	}

	struct field *f;
	for(f = &fields[WALL_TIME]; f->name != NULL; f++)
	{
		if(value_of_field(s, f) < 0)
		{
			assign_to_field(s, f, 0);
		}
	}

	free(so); //we do not free so->command on purpouse.

	return s;
}