Skip to content
Snippets Groups Projects
Commit dcae34e8 authored by Danny Auble's avatar Danny Auble
Browse files

updated report with start and end time header

parent 836e7ef2
No related branches found
No related tags found
No related merge requests found
......@@ -207,6 +207,7 @@ plugin_load_and_link(const char *type_name, int n_syms,
file_name = xstrdup_printf("%s/%s", head, so_name);
debug3("Trying to load plugin %s", file_name);
if ((stat(file_name, &st) < 0) || (!S_ISREG(st.st_mode))) {
debug4("No Good.");
xfree(file_name);
} else {
plug = plugin_load_from_file(file_name);
......
......@@ -59,6 +59,9 @@ static int _set_cond(int *start, int argc, char *argv[],
int i;
int set = 0;
int end = 0;
time_t my_time = time(NULL);
struct tm start_tm;
struct tm end_tm;
for (i=(*start); i<argc; i++) {
end = parse_option_end(argv[i]);
......@@ -89,6 +92,51 @@ static int _set_cond(int *start, int argc, char *argv[],
}
}
(*start) = i;
/* Default is going to be the last day */
if(!cluster_cond->usage_end) {
if(!localtime_r(&my_time, &end_tm)) {
error("Couldn't get localtime from end %d",
my_time);
return SLURM_ERROR;
}
end_tm.tm_hour = 0;
cluster_cond->usage_end = mktime(&end_tm);
} else {
if(!localtime_r((time_t *)&cluster_cond->usage_end, &end_tm)) {
error("Couldn't get localtime from user end %d",
my_time);
return SLURM_ERROR;
}
}
end_tm.tm_sec = 0;
end_tm.tm_min = 0;
end_tm.tm_isdst = -1;
cluster_cond->usage_end = mktime(&end_tm);
if(!cluster_cond->usage_start) {
if(!localtime_r(&my_time, &start_tm)) {
error("Couldn't get localtime from start %d",
my_time);
return SLURM_ERROR;
}
start_tm.tm_hour = 0;
start_tm.tm_mday--;
cluster_cond->usage_start = mktime(&start_tm);
} else {
if(!localtime_r((time_t *)&cluster_cond->usage_start,
&start_tm)) {
error("Couldn't get localtime from user start %d",
my_time);
return SLURM_ERROR;
}
}
start_tm.tm_sec = 0;
start_tm.tm_min = 0;
start_tm.tm_isdst = -1;
cluster_cond->usage_start = mktime(&start_tm);
if(cluster_cond->usage_end-cluster_cond->usage_start < 3600)
cluster_cond->usage_end = cluster_cond->usage_start + 3600;
return set;
}
......@@ -192,6 +240,21 @@ static List _get_cluster_list(int argc, char *argv[], List format_list)
_set_cond(&i, argc, argv, cluster_cond, format_list);
cluster_list = acct_storage_g_get_clusters(db_conn, cluster_cond);
if(print_fields_have_header) {
char start_char[20];
char end_char[20];
cluster_cond->usage_end-=1;
slurm_make_time_str((time_t *)&cluster_cond->usage_start,
start_char, sizeof(start_char));
slurm_make_time_str((time_t *)&cluster_cond->usage_end,
end_char, sizeof(end_char));
printf("----------------------------------------"
"----------------------------------------\n");
printf("\tCluster Utilization Report %s - %s\n",
start_char, end_char);
printf("----------------------------------------"
"----------------------------------------\n");
}
destroy_acct_cluster_cond(cluster_cond);
if(!cluster_list)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment