/* gcc -I /cm/shared/apps/slurm/current/include -L /cm/shared/apps/slurm/current/lib64 -lslurm -o spartition spartition.c */ /* Source-Code-Quellen: scr/api/partition_info.c src/common/parse_time.c (enthaelt die Definition von: secs2time_str) */ #include #include #include #include void secs2time_str(time_t time, char *string, int size) { if (time == INFINITE) { snprintf(string, size, "UNLIMITED"); } else { long days, hours, minutes, seconds; seconds = time % 60; minutes = (time / 60) % 60; hours = (time / 3600) % 24; days = time / 86400; if ((days < 0) || (hours < 0) || (minutes < 0) || (seconds < 0)) { snprintf(string, size, "INVALID"); } else if (days) { snprintf(string, size, "%ld-%2.2ld:%2.2ld:%2.2ld", days, hours, minutes, seconds); } else { snprintf(string, size, "%2.2ld:%2.2ld:%2.2ld", hours, minutes, seconds); } } } int main (int argc, char *argv[]) { int i; partition_info_msg_t *part_info_ptr = NULL; partition_info_t *part_ptr; char time_line[32], max_time_str[32]; /* get and dump some partition information */ if (slurm_load_partitions((time_t)NULL, &part_info_ptr, SHOW_ALL)) { slurm_perror ("slurm_load_partitions error"); exit (1); } /* sehe für 'default_time' und 'max_time' nach 'struct partiion_into {' in slurm.h */ printf("\nPartitionName DefaultTime MaxTime\n\n"); for (i = 0; i < part_info_ptr->record_count; i++) { secs2time_str(part_info_ptr->partition_array[i].default_time * 60, time_line, sizeof(time_line)); secs2time_str(part_info_ptr->partition_array[i].max_time * 60, max_time_str, sizeof(max_time_str)); printf ("%13s %11s %11s\n", part_info_ptr->partition_array[i].name, time_line, max_time_str); if (i == 3) printf("\n"); } printf("\n"); slurm_free_partition_info_msg(part_info_ptr); exit (0); }