1. drmaa2_msession_get_all_machines(3)
  2. DRMAA2
  3. drmaa2_msession_get_all_machines(3)

NAME

drmaa2_msession_get_all_machines - drmaa2_msession_get_all_machines, Returns all Univa(R) Grid Engine(TM) hosts

SYNOPSIS

#include "drmaa2.h"

drmaa2_machineinfo_list drmaa2_msession_get_all_machines(const drmaa2_msession monitoring_session, const drmaa2_string_list filter);

DESCRIPTION

Returns a list of all execution hosts currently managed by Univa(R) Grid Engine(TM) in a drmaa2_machineinfo_list.

The second argument defines a filter for the hosts to be returned. Only hosts with names given by the filter are returned if filter is != NULL. If filter is NULL all available hosts are returned.

The drmaa2_machineinfo_list consists of drmaa2_machineinfo elements which are pointers to the drmaa2_machineinfo_s struct. The struct offers at least following elements:

typedef struct {
   drmaa2_string   name;
   drmaa2_bool     available;
   long long       sockets;
   long long       coresPerSocket;
   long long       threadsPerCore;
   float           load;
   long long       physMemory;
   long long       virtMemory;
   drmaa2_cpu      machineArch;
   drmaa2_version  machineOSVersion;
   drmaa2_os       machineOS;
} drmaa2_machineinfo_s;

typedef drmaa2_machineinfo_s *drmaa2_machineinfo;

All values, but especially allocated values like drmaa2_string name and drmaa2_version, which can be NULL needs to be tested if they are not UNSET or != NULL before they are used. The UNSET defines can be found in the drmaa2.h file.

The availability of additional values can be queried with the drmaa2_machineinfo_impl_spec(3) function.

RETURN VALUES

Returns a newly allocated list of hosts in a drmaa2_machineinfo_list structure or NULL in case of an error. The machine list was initialized with an appropriate callback function so that drmaa2_list_free(&result) frees the complete list with all drmaa2_machineinfo objects inside. In case of an error the error number and error message can be fetched with drmaa2_lasterror(3) and drmaa2_lasterror_text().

EXAMPLE

drmaa2_msession monitoring_session = drmaa2_open_msession(NULL);

if (ms != NULL) {       
   drmaa2_machineinfo_list mi_list = drmaa2_msession_get_all_machines(monitoring_session, NULL);

   if (mi_list == NULL) {
      /* handle error */
      drmaa2_string error = drmaa2_lasterror_text();
      fprintf(stderr, "Error during fetching the machineinfo list from the monitoring session: %s\n", error);
      drmaa2_string_free(&error);
   } else {
      int i;
      size_t size = drmaa2_list_size(mi_list);

      fprintf(stdout, "There are %lld machines in the system:\n", size); 
      for (i = 0; i < size; i++) {
          drmaa2_machineinfo mi = (drmaa2_machineinfo) drmaa2_list_get(mi_list, i);
          fprintf(stdout, "machine name: %s\n", (mi->name==DRMAA2_UNSET_STRING)?"UNSET":mi->name);
          fprintf(stdout, "amount of sockets: %lld\n", mi->sockets);
          fprintf(stdout, "amount of cores per socket: %lld\n", mi->coresPerSocket);
          fprintf(stdout, "amount of threads per core: %lld\n", mi->threadsPerCore);
          fprintf(stdout, "1 min. avg. load on machine: %f\n", mi->load);
          fprintf(stdout, "physical memory in kilobyte: %lld\n", mi->physMemory);
          fprintf(stdout, "virtual memory in kilobyte: %lld\n", mi->virtMemory);
          fprintf(stdout, "OS: %s\n", drmaa2_os_to_string(mi->machineOS));
          fprintf(stdout, "CPU architecture as enum: %d\n", mi->machineArch);
      }
      drmaa2_list_free(&mi_list);
   }

   ...
   drmaa2_close_msession(monitoring_session);
   drmaa2_msession_free(&monitoring_session);
}
...

Example for the convertion from a drmaa2_os object into a string:

static char* drmaa2_os_to_string(const drmaa2_os os)
{
     switch (os) {
        case DRMAA2_OTHER_OS:
           return "DRMAA2_OTHER_OS";
        case DRMAA2_AIX:
           return "DRMAA2_AIX";
        case DRMAA2_BSD:
           return "DRMAA2_BSD";
        case DRMAA2_LINUX:
           return "DRMAA2_LINUX";
        case DRMAA2_HPUX:
           return "DRMAA2_HPUX";
        case DRMAA2_IRIX:
           return "DRMAA2_IRIX";
        case DRMAA2_MACOS:
           return "DRMAA2_MACOS";
        case DRMAA2_SUNOS:
           return "DRMAA2_SUNOS";
        case DRMAA2_TRU64:
           return "DRMAA2_TRU64";
        case DRMAA2_UNIXWARE:
           return "DRMAA2_UNIXWARE";
        case DRMAA2_WIN:
           return "DRMAA2_WIN";
        case DRMAA2_WINNT:
           return "DRMAA2_WINNT";
        default:
           return "UNKNOWN";
     }
     return "UNKNOWN";
}

SEE ALSO

drmaa2_open_msession(3), drmaa2_close_msession(3), drmaa2_msession_free(3), drmaa2_msession_get_all_jobs(3), drmaa2_msession_get_all_queues(3), drmaa2_list_free(3), drmaa2_machineinfo_impl_spec(3) )

AUTHOR

Copyright Univa Corporation 2013

  1. Univa Corporation
  2. October 2013
  3. drmaa2_msession_get_all_machines(3)