| Summary: | Perl API access to list of assigned CPUs on nodes | ||
|---|---|---|---|
| Product: | Slurm | Reporter: | Josko Plazonic <plazonic> |
| Component: | Other | Assignee: | Brian Christiansen <brian> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | 5 - Enhancement | ||
| Priority: | --- | CC: | brian, da, dmcr |
| Version: | 14.03.7 | ||
| Hardware: | Linux | ||
| OS: | Linux | ||
| Site: | Princeton (PICSciE) | Alineos Sites: | --- |
| Atos/Eviden Sites: | --- | Confidential Site: | --- |
| Coreweave sites: | --- | Cray Sites: | --- |
| DS9 clusters: | --- | HPCnow Sites: | --- |
| HPE Sites: | --- | IBM Sites: | --- |
| NOAA SIte: | --- | OCF Sites: | --- |
| Recursion Pharma Sites: | --- | SFW Sites: | --- |
| SNIC sites: | --- | Linux Distro: | --- |
| Machine Name: | CLE Version: | ||
| Version Fixed: | 15.08.0pre2 15.08.0pre7 | Target Release: | --- |
| DevPrio: | --- | Emory-Cloud Sites: | --- |
|
Description
Josko Plazonic
2014-10-24 02:05:45 MDT
The information required is in the C job data structure, in this field:
job_resources_t *job_resrcs; /* opaque data type, job resources */
It is currently available using the scontrol -d show job command, but not in the Perl API:
JobId=21470 Name=scontrol
UserId=jette(1001) GroupId=jette(1001)
....
Nodes=tux1 CPU_IDs=0-3 Mem=128
Nodes=tux[2-3] CPU_IDs=0-1 Mem=128
Hi, I wanted to touch base on this one - we knew about scontrol way of getting to it but that's a very inefficient way for us to do that (slurmtop is ran by multiple users and would do that multiple times per minute for 1000+ jobs we have in the queue). Any plans on exposing this info via perl API directly? Thanks! (In reply to Josko Plazonic from comment #2) > Hi, > > I wanted to touch base on this one - we knew about scontrol way of getting > to it but that's a very inefficient way for us to do that (slurmtop is ran > by multiple users and would do that multiple times per minute for 1000+ jobs > we have in the queue). > > Any plans on exposing this info via perl API directly? > > Thanks! We'll try to get this into the v15.08 release. This has been added to 15.08 and the commit 4e15ddc1b04 should work with previous versions of Slurm.
A Simple script like
#! /usr/bin/perl -w
use strict;
use Slurm ':all';
my $job_flags = SHOW_ALL | SHOW_DETAIL;
my $resp = Slurm->load_jobs(0, $job_flags);
foreach my $job (@{$resp->{job_array}}) {
if ($job->{'node_rescrs'}) {
foreach my $rescrs (@{$job->{'node_rescrs'}}) {
printf("\tNodes = %s CPU_IDS = %s Mem = %s\n",
$rescrs->{'nodes'}, $rescrs->{'cpu_ids'},
$rescrs->{'mem'});
}
}
}
should get you what you want. SHOW_DETAIL is the key here in the flags.
Hi,
one minor issue (pointed out by our Dennis who is starting to use this feature so he wants to make sure the correct name sticks) - shouldn't it be
node_resrcs
rather then node_rescrs?
It's a trivial change/fix:
--- ./contribs/perlapi/libslurm/perl/job.c.original 2015-07-21 15:51:01.882759414 -0400
+++ ./contribs/perlapi/libslurm/perl/job.c 2015-07-21 16:26:12.234828155 -0400
@@ -168,7 +168,7 @@
}
slurm_hostlist_destroy(hl);
slurm_hostlist_destroy(hl_last);
- hv_store_sv(hv, "node_rescrs", newRV_noinc((SV*)av));
+ hv_store_sv(hv, "node_resrcs", newRV_noinc((SV*)av));
return 0;
}
Thanks!
Corrected in: https://github.com/SchedMD/slurm/commit/dad397f926ade6d7322bfeff7eb119055b86a171 THanks! |