A handle that will have memory allocated and filled with the array of nodes. This memory must be freed by the caller.
The user identifier number
A pointer to a list of group identifier numbers
The number of elements in the previous arguments array
beostat_get_avail_nodes_by_id will provide a list of nodes that are available to the given user identifier number who also is a member of the group identifer numbers listed. Memory allocated by the function for node_list must be freed by the caller.
int cnt, *node_list, gid_size, i; uid_t uid; gid_t *gid_list; uid = getuid(); gid_size = getgroups (0, gid_list); gid_list = malloc (sizeof (gid_t) * gid_size); getgroups (gid_size, gid_list); cnt = beostat_get_avail_nodes_by_id (&node_list, uid, gid_list, gid_size); printf ("You may run jobs on nodes: "); for (i = 0; i < cnt; i++) printf ("%d ", node_list[i]); printf ("\n"); free (gid_list); free (node_list);
This function relies on the Beostat subsystem, which consists of the proc filesystem on the remote node, the sendstatsdaemon on the remote node, the recvstats daemon on the master node, and two shared memory files in the directory /var/shm. If any part of the system breaks down, this function could fail.