slurm_get_jobinfo.pm

use strict;
use Slurm ':all';

sub slurm_get_jobinfo{

    my ($jobid) = @_;

    my $slurm = Slurm::new();

    my $resp = $slurm->load_job($jobid, SHOW_DETAIL);

    die "Couldn't get information for job $jobid" if(!$resp);
    my $job = shift(@{$resp->{job_array}});

    return $job;
}1;


batch.pl

#!/usr/bin/env perl
require "slurm_get_jobinfo.pm

my $sjob_info = &slurm_get_jobinfo($ENV{SLURM_JOB_ID});

print $sjob_info->{'command'};

Here's a key dump of the hash above for a random job.

key: command : /home/oper/tar_extract_kraken_cdp.com
key: start_time : 1390197146
key: time_limit : 4294967295
key: pn_min_cpus : 1
key: node_inx : ARRAY(0x28f9448)
key: resize_time : 0
key: pn_min_tmp_disk : 0
key: threads_per_core : 4294967294
key: array_task_id : 65534
key: partition : tapes
key: exit_code : 0
key: time_min : 0
key: select_jobinfo : Slurm::dynamic_plugin_data_t=SCALAR(0x28f9670)
key: ntasks_per_core : 4294967295
key: eligible_time : 1390197146
key: end_time : 1421733146
key: pn_min_memory : 0
key: assoc_id : 0
key: cores_per_socket : 4294967294
key: state_reason : 0
key: max_nodes : 0
key: sockets_per_node : 4294967294
key: priority : 4294900558
key: alloc_node : tape1
key: user_id : 1431
key: alloc_sid : 2737
key: requeue : 1
key: max_cpus : 0
key: wait4switch : 0
key: nice : 10000
key: array_job_id : 0
key: derived_ec : 0
key: name : tar_extract_kraken_cdp.com
key: contiguous : 0
key: restart_cnt : 0
key: show_flags : 3
key: req_switch : 0
key: group_id : 200
key: num_cpus : 1
key: ntasks_per_socket : 4294967295
key: cpus_per_task : 1
key: req_node_inx : ARRAY(0x28f95c8)
key: nodes : tape1
key: exc_node_inx : ARRAY(0x28f92e0)
key: suspend_time : 0
key: job_resrcs : Slurm::job_resources_t=SCALAR(0x28f96a0)
key: batch_flag : 1
key: job_state : 1
key: pre_sus_time : 0
key: qos : normal
key: num_nodes : 1
key: ntasks_per_node : 0
key: work_dir : /home/oper
key: submit_time : 1390197146
key: profile : 0
key: shared : 2
key: job_id : 12791



On Mon, 2014-01-20 at 13:46 -0800, Ulf Markwardt wrote: 
> @ Franco:
> 
> > You can get it using scontrol show job or from the perl api which is
> > what we do.
> Would you please send me your perl code?
> Thanks!
> 
> @ SchedMD:
> 
> > It would be useful to set an environment variable and
> > include the partition name too...   please.
> Yes, please...!
> 
> Thanks
> Ulf
> 

Reply via email to