1Slurm API(3)          Slurm node informational functions          Slurm API(3)
2
3
4

NAME

6       slurm_free_node_info_msg,    slurm_load_node,   slurm_load_node_single,
7       slurm_print_node_info_msg,                      slurm_print_node_table,
8       slurm_sprint_node_table - Slurm node information reporting functions
9

SYNTAX

11       #include <stdio.h>
12       #include <slurm/slurm.h>
13
14       void slurm_free_node_info_msg (
15            node_info_msg_t *node_info_msg_ptr
16       );
17
18       int slurm_load_node (
19            time_t update_time,
20            node_info_msg_t **node_info_msg_pptr,
21            uint16_t show_flags
22       );
23
24       int slurm_load_node_single (
25            node_info_msg_t **node_info_msg_pptr,
26            char *node_name,
27            uint16_t show_flags
28       );
29
30       void slurm_print_node_info_msg (
31            FILE *out_file,
32            node_info_msg_t *node_info_msg_ptr,
33            int one_liner
34       );
35
36       void slurm_print_node_table (
37            FILE *out_file,
38            node_info_t *node_ptr,
39            int one_liner
40       );
41
42       char *slurm_sprint_node_table (
43            node_info_t *node_ptr,
44            int one_liner
45       );
46

ARGUMENTS

48       node_info_msg_ptr
49              Specifies    the   pointer   to   the   structure   created   by
50              slurm_load_node.
51
52       node_info_msg_pptr
53              Specifies the double pointer to the structure to be created  and
54              filled  with  the  time of the last node update, a record count,
55              and detailed information about each node. Detailed node informa‐
56              tion  is  written  to  fixed  sized  records and includes: name,
57              state, processor count, memory size, etc. See slurm.h  for  full
58              details on the data structure's contents.
59
60       node_name
61              Name of the node for which information is requested.
62
63       node_ptr
64              Specifies   a   pointer   to  a  single  node  record  from  the
65              node_info_msg_ptr data structure.
66
67       one_liner
68              Print one record per line if non-zero.
69
70       out_file
71              Specifies the file to print data to.
72
73       show_flags
74              Job filtering flags, may be ORed.  Information  about  nodes  in
75              partitions that are configured as hidden and partitions that the
76              user's group is unable to utilize are not reported  by  default.
77              The SHOW_ALL flag will cause information about nodes in all par‐
78              titions to be displayed.  Only information about  nodes  on  the
79              local cluster will be returned unless the cluster is in a feder‐
80              ation and the SHOW_ALL flag is set.
81
82
83       update_time
84              For all of the following informational calls, if update_time  is
85              equal  to  or  greater  than the last time changes where made to
86              that information, new information is  not  returned.   Otherwise
87              all  the  configuration.  job,  node,  or  partition records are
88              returned.
89

DESCRIPTION

91       slurm_free_node_info_msg  Release  the   storage   generated   by   the
92       slurm_load_node function.
93
94       slurm_load_node_single issue RPC to get slurm configuration information
95       for a specific node.
96
97       slurm_load_node Returns a node_info_msg_t that contains an update time,
98       record count, and array of node_table records for all nodes.  Note that
99       nodes which are hidden for any reason  will  have  a  NULL  node  name.
100       Other  fields associated with the node will be filled in appropriately.
101       Reasons for a node being hidden include: a node state of FUTURE, a node
102       in the CLOUD that is powered down, or a node in a hidden partition.
103
104       slurm_print_node_info_msg  Prints  the  contents  of the data structure
105       describing all node records from the data loaded by the slurm_load_node
106       function.
107
108       slurm_print_node_table  Prints  the  contents  of  the  data  structure
109       describing a single node record loaded by the slurm_load_node function.
110

RETURN VALUE

112       On success, zero is returned. On error, -1 is returned, and Slurm error
113       code is set appropriately.
114

ERRORS

116       SLURM_NO_CHANGE_IN_DATA Data has not changed since update_time.
117
118       SLURM_PROTOCOL_VERSION_ERROR Protocol version has changed, re-link your
119       code.
120
121       SLURM_PROTOCOL_SOCKET_IMPL_TIMEOUT Timeout in communicating with  Slurm
122       controller.
123

EXAMPLE

125       #include <stdio.h>
126       #include <stdlib.h>
127       #include <slurm/slurm.h>
128       #include <slurm/slurm_errno.h>
129
130       int main (int argc, char *argv[])
131       {
132            int i, j, k;
133            partition_info_msg_t *part_buffer_ptr = NULL;
134            partition_info_t *part_ptr;
135            node_info_msg_t *node_buffer_ptr = NULL;
136            node_info_t *node_ptr;
137
138            /* get and dump some node information */
139            if ( slurm_load_node ((time_t) NULL,
140                                  &node_buffer_ptr, SHOW_ALL) ) {
141                 slurm_perror ("slurm_load_node error");
142                 exit (1);
143            }
144
145            /* The easy way to print... */
146            slurm_print_node_info_msg (stdout, node_buffer_ptr, 0);
147
148            /* A harder way.. */
149            for (i = 0; i < node_buffer_ptr->record_count; i++) {
150                 node_ptr = &node_buffer_ptr->node_array[i];
151                 slurm_print_node_table(stdout, node_ptr, 0, 0);
152            }
153
154            /* The hardest way. */
155            for (i = 0; i < node_buffer_ptr->record_count; i++) {
156                 printf ("NodeName=%s CPUs=%u\n",
157                      node_buffer_ptr->node_array[i].name,
158                      node_buffer_ptr->node_array[i].cpus);
159            }
160
161            /* get and dump some partition information */
162            /* note that we use the node information loaded */
163            /* above and we assume the node table entries have */
164            /* not changed since */
165            if ( slurm_load_partitions ((time_t) NULL,
166                                        &part_buffer_ptr, 0) ) {
167                 slurm_perror ("slurm_load_partitions error");
168                 exit (1);
169            }
170            for (i = 0; i < part_buffer_ptr->record_count; i++) {
171                 part_ptr = &part_buffer_ptr->partition_array[i];
172                 printf ("PartitionName=%s Nodes=",
173                      part_ptr->name);
174                 for (j = 0; part_ptr->node_inx; j+=2) {
175                      if (part_ptr->node_inx[j] == -1)
176                           break;
177                      for (k = part_ptr->node_inx[j];
178                           k <= part_ptr->node_inx[j+1];
179                           k++) {
180                           printf ("%s ", node_buffer_ptr->
181                                   node_array[k].name);
182                      }
183                 }
184                 printf("\n\n");
185            }
186            slurm_free_node_info_msg (node_buffer_ptr);
187            slurm_free_partition_info_msg (part_buffer_ptr);
188            exit (0);
189       }
190
191

NOTES

193       These  functions  are  included  in the libslurm library, which must be
194       linked to your process for use (e.g. "cc -lslurm myprog.c").
195
196       Some data structures  contain  index  values  to  cross-reference  each
197       other.   If the show_flags argument is not set to SHOW_ALL when getting
198       this data, these index values will be invalid.
199
200

COPYING

202       Copyright (C) 2002-2006 The Regents of the  University  of  California.
203       Produced  at  Lawrence  Livermore National Laboratory (cf, DISCLAIMER).
204       CODE-OCEC-09-009. All rights reserved.
205
206       This file is  part  of  Slurm,  a  resource  management  program.   For
207       details, see <https://slurm.schedmd.com/>.
208
209       Slurm  is free software; you can redistribute it and/or modify it under
210       the terms of the GNU General Public License as published  by  the  Free
211       Software  Foundation;  either  version  2  of  the License, or (at your
212       option) any later version.
213
214       Slurm is distributed in the hope that it will be  useful,  but  WITHOUT
215       ANY  WARRANTY;  without even the implied warranty of MERCHANTABILITY or
216       FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General  Public  License
217       for more details.
218

SEE ALSO

220       scontrol(1), squeue(1), slurm_allocation_lookup(3), slurm_get_errno(3),
221       slurm_load_partitions(3), slurm_perror(3), slurm_strerror(3)
222
223
224
225
226May 2017              Slurm node informational functions          Slurm API(3)
Impressum