1Slurm API(3) Slurm partition information functions Slurm API(3)
2
3
4
6 slurm_free_partition_info_msg, slurm_load_partitions, slurm_print_par‐
7 tition_info, slurm_print_partition_info_msg - Slurm partition informa‐
8 tion reporting functions
9
11 #include <stdio.h>
12 #include <slurm/slurm.h>
13
14 void slurm_free_partition_info_msg (
15 partition_info_msg_t *partition_info_msg_ptr
16 );
17
18 int slurm_load_partitions (
19 time_t update_time,
20 partition_info_msg_t **partition_info_msg_pptr,
21 uint16_t show_flags
22 );
23
24 void slurm_print_partition_info (
25 FILE *out_file,
26 partition_info_t *partition_ptr,
27 int one_liner
28 );
29
30 void slurm_print_partition_info_msg (
31 FILE *out_file,
32 partition_info_msg_t *partition_info_msg_ptr,
33 int one_liner
34 );
35
37 one_liner
38 Print one record per line if non-zero.
39
40 out_file
41 Specifies the file to print data to.
42
43 partition_info_msg_pptr
44 Specifies the double pointer to the structure to be created and
45 filled with the time of the last partition update, a record
46 count, and detailed information about each partition. Detailed
47 partition information is written to fixed sized records and
48 includes: name, state, job time limit, job size limit, node
49 names, indexes into the node table, etc. In the case of indexes
50 into the node table, this is an array of integers with pairs of
51 start and end index number into the node information records and
52 the data is terminated with a value of -1. See slurm.h for full
53 details on the data structure's contents.
54
55 partition_info_msg_ptr
56 Specifies the pointer to the structure created by
57 slurm_load_partitions.
58
59 show_flags
60 Job filtering flags, may be ORed. Information about partitions
61 that are configured as hidden and partitions that the user's
62 group is unable to utilize are not reported by default. The
63 SHOW_ALL flag will cause information about partitions to be dis‐
64 played. Only information about partitions on the local cluster
65 will be returned unless the cluster is in a federation and the
66 SHOW_ALL flag is set.
67
68
69 update_time
70 For all of the following informational calls, if update_time is
71 equal to or greater than the last time changes where made to
72 that information, new information is not returned. Otherwise
73 all the configuration. job, node, or partition records are
74 returned.
75
77 slurm_free_partition_info_msg Release the storage generated by the
78 slurm_load_partitions function.
79
80 slurm_load_partitions Returns a partition_info_msg_t that contains an
81 update time, record count, and array of partition_table records for all
82 partitions.
83
84 slurm_print_partition_info Prints the contents of the data structure
85 describing a single partition records from the data loaded by the
86 slurm_load_partitions function.
87
88 slurm_print_partition_info_msg Prints the contents of the data struc‐
89 ture describing all partition records loaded by the slurm_load_parti‐
90 tions function.
91
93 On success, zero is returned. On error, -1 is returned, and Slurm error
94 code is set appropriately.
95
97 SLURM_NO_CHANGE_IN_DATA Data has not changed since update_time.
98
99 SLURM_PROTOCOL_VERSION_ERROR Protocol version has changed, re-link your
100 code.
101
102 SLURM_PROTOCOL_SOCKET_IMPL_TIMEOUT Timeout in communicating with Slurm
103 controller.
104
106 #include <stdio.h>
107 #include <stdlib.h>
108 #include <slurm/slurm.h>
109 #include <slurm/slurm_errno.h>
110
111 int main (int argc, char *argv[])
112 {
113 int i;
114 partition_info_msg_t *part_info_ptr = NULL;
115 partition_info_t *part_ptr;
116
117 /* get and dump some partition information */
118 if (slurm_load_partitions((time_t)NULL,
119 &part_info_ptr, SHOW_ALL)) {
120 slurm_perror ("slurm_load_partitions error");
121 exit (1);
122 }
123
124 /* The easy way to print... */
125 slurm_print_partition_info_msg (stdout,
126 part_info_ptr, 0);
127
128 /* A harder way.. */
129 for (i = 0; i < part_info_ptr->record_count; i++) {
130 part_ptr = &part_info_ptr->partition_array[i];
131 slurm_print_partition_info(stdout, part_ptr, 0);
132 }
133
134 /* The hardest way. */
135 printf("Partitions updated at %lx, records=%d\n",
136 part_info_ptr->last_update,
137 part_info_ptr->record_count);
138 for (i = 0; i < part_info_ptr->record_count; i++) {
139 printf ("PartitionName=%s Nodes=%s\n",
140 part_info_ptr->partition_array[i].name,
141 part_info_ptr->partition_array[i].nodes );
142 }
143
144 slurm_free_partition_info_msg (part_info_ptr);
145 exit (0);
146 }
147
148
150 These functions are included in the libslurm library, which must be
151 linked to your process for use (e.g. "cc -lslurm myprog.c").
152
153 Some data structures contain index values to cross-reference each
154 other. If the show_flags argument is not set to SHOW_ALL when getting
155 this data, these index values will be invalid.
156
157 The slurm_hostlist_ functions can be used to convert Slurm node list
158 expressions into a collection of individual node names.
159
160
162 Copyright (C) 2002-2006 The Regents of the University of California.
163 Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
164 CODE-OCEC-09-009. All rights reserved.
165
166 This file is part of Slurm, a resource management program. For
167 details, see <https://slurm.schedmd.com/>.
168
169 Slurm is free software; you can redistribute it and/or modify it under
170 the terms of the GNU General Public License as published by the Free
171 Software Foundation; either version 2 of the License, or (at your
172 option) any later version.
173
174 Slurm is distributed in the hope that it will be useful, but WITHOUT
175 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
176 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
177 for more details.
178
179
181 scontrol(1), sinfo(1), squeue(1), slurm_hostlist_create(3),
182 slurm_hostlist_shift(3), slurm_hostlist_destroy(3), slurm_get_errno(3),
183 slurm_load_node(3), slurm_perror(3), slurm_strerror(3)
184
185
186
187
188May 2017 Slurm partition information functions Slurm API(3)