Пример #1
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;
}
Пример #2
0
struct summary *parse_summary_file(char *filename)
{
	FILE           *f;
	char            line[MAX_LINE], key[MAX_LINE], value[MAX_LINE];

	struct summary *s = calloc(1, sizeof(struct summary));

	debug(D_RMON, "parsing summary %s\n", filename);

	f = fopen(filename, "r");
	if(!f)
		fatal("cluster: could not open summary: %s\n", filename);

	s->rule = get_rule_number(filename);

	debug(D_RMON, "rule %d\n", s->rule);

	while(fgets(line, MAX_LINE, f))
	{
		sscanf(line, "%[^:]:%s[\n]", key, value);
		assign_field_summ(s, max_concurrent_processes,  key, value);
		assign_field_summ(s, cpu_time,                  key, value);
		assign_field_summ(s, wall_time,                 key, value);
		assign_field_summ(s, virtual_memory,            key, value);
		assign_field_summ(s, resident_memory,           key, value);
		assign_field_summ(s, bytes_read,                key, value);
		assign_field_summ(s, bytes_written,             key, value);
		assign_field_summ(s, workdir_number_files_dirs, key, value);
		assign_field_summ(s, workdir_footprint,         key, value);

		assign_field_summ(s, start, key, value);
		assign_field_summ(s, end,   key, value);
	}

	fclose(f);

	return s;
}
Пример #3
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;
}