Slurm API(3)

NAME
slurm_free_job_info_msg, slurm_load_jobs, slurm_print_job_info, slurm_print_job_info_msg - Slurm job information reporting functions

SYNTAX

#include <stdio.h>
#include <slurm.h>
#include <sys/types.h>

void slurm_free_job_info_msg (
    job_info_msg_t *job_info_msg_ptr
);

int slurm_load_jobs (
    time_t update_time,
    job_info_msg_t **job_info_msg_pptr
);

int slurm_pid2jobid (
    pid_t job_pid,
    uint32_t *job_id_ptr
);

void slurm_print_job_info (
    FILE *out_file,
    job_info_t *job_ptr,
    int one_linerfP
);

void slurm_print_job_info_msg (
    FILE *out_file,
    job_info_msg_t *job_info_msg_ptr,
    int one_linerfP
);

ARGUMENTS

job_info_msg_pptr
    Specifies the double pointer to the structure to be created and filled with the time of the last job update, a record count, and detailed information about each job. Detailed job information is written to fixed sized records and includes: ID number, name, user ID, state, assigned or requested node names, indexes into the node table, etc. In the case of indexes into the node table, this is an array of integers with pairs of start and end index number into the node information records and the data is terminated with a value of -1. See slurm.h for full details on the data structure's contents.

job_id_ptr
    Specifies a pointer to a storage location into which a Slurm job id may be placed.

job_info_msg_ptr
    Specifies the pointer to the structure created by slurm_load_jobs.

job_pid
    Specifies a process id of some process on the current node.

job_ptr
    Specifies a pointer to a single job records from the job_info_msg_ptr data structure.

one_liner
    Print one record per line if non-zero.

out_file
    Specifies the file to print data to.

update_time
    For all of the following informational calls, if update_time is equal to or greater than the last time changes where made to that information, new information is not returned. Otherwise all the configuration. job, node, or partition records are returned.

DESCRIPTION

slurm_free_job_info_msg Release the storage generated by the slurm_load_jobs function.

slurm_load_jobs Returns a job_info_msg_t that contains an update time, record count, and array of job_table records for all jobs.

slurm_pid2jobid Returns a Slurm job id corresponding to the supplied local process id.

slurm_print_job_info Prints the contents of the data structure describing a single job records from the data loaded by the slurm_load_node function.

slurm_print_job_info_msg Prints the contents of the data structure describing all job records loaded by the slurm_load_node function.

RETURN VALUE

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

ERRORS

SLURM_NO_CHANGE_IN_DATA Data has not changed since update_time.

SLURM_PROTOCOL_VERSION_ERROR Protocol version has changed, re-link your code.

ESLURM_INVALID_JOB_ID Request for information about a non-existent job.

EXAMPLE

#include <stdio.h>
#include <slurm.h>
#include <sys/types.h>

int main (int argc, char *argv[])
{
    int i;
    job_info_msg_t    * job_info_msg = NULL;
    job_info_t * job_ptr;
    uint32_t job_id;

    /* get and dump some job information */
    if ( slurm_load_jobs ((time_t) NULL,
                        &job_buffer_ptr) ) {
        slurm_perror ("slurm_load_jobs error");
        exit (1);
    }

    /* The easy way to print... */
    slurm_print_job_info_msg (stdout, job_buffer_ptr);

    /* A harder way.. */
    for (i = 0; i < job_buffer_ptr->record_count; i++) {
        job_ptr = &job_buffer_ptr->job_array[i];
        slurm_print_job_info(stdout, job_ptr);
    }

    /* The hardest way. */
    printf ("Jobs updated at %lx, record count %d\n",
            job_buffer_ptr->last_update,
            job_buffer_ptr->record_count);
    for (i = 0; i < job_buffer_ptr->record_count; i++) {
        printf ("JobId=%u UserId=%u\n",
            job_buffer_ptr->job_array[i].job_id,
            job_buffer_ptr->job_array[i].user_id);
    }

    slurm_free_job_info_msg (job_buffer_ptr);

    if (slurm_pid2jobid (getpid(), &job_id))
        slurm_perror ("slurm_load_jobs error");
    else
        printf ("Slurm job id = %u\n", job_id);
    exit (0);
}

COPYING
Copyright (C) 2002 The Regents of the University of California. Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). UCRL-CODE-2002-040.

This file is part of SLURM, a resource management program. For details, see <http://www.llnl.gov/linux/slurm/>.

SLURM is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

SLURM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

SEE ALSO

scontrol(1), squeue(1), slurm_confirm_allocation(3), slurm_get_errno(3), slurm_perror(3), slurm_strerror(3)