Thanks Mark.   I only added the ability for backwards compatibility to 
the pack/unpack.  The patch will be in the next 2.4 here is the 
committed patch.

https://github.com/SchedMD/slurm/commit/d1ae3d81d9708b28ed39b7e885951bd7764c2d9d

Danny

On 03/19/12 22:05, Mark Nelson wrote:
> Hi All,
>
> This is a (hopefully) simple patch to get sshare to also output the
> GrpCPUMins
> limit set on an account. It's useful for us as we're running with hard
> limits
> and fixed quarterly boundaries for rollover and this allows users to see how
> much "quota" they've got left in the current quarter.
>
> Any comments would be greatly appreciated!
>
> Thanks!
> Mark
>
>
>
> [RFC][PATCH] sshare: add ability to output GrpCPUMins
>
> Add the grp_cpu_mins limit to association_shares_object_t so that it can be
> displayed by sshare.
>
> This is useful for deployments using hard limits because both the GrpCPUMins
> limit and the raw usage together are needed to give users an insight into
> how many CPU-minutes they've still got remaining on their account.
>
> Hide it behind the --long option
>
> Signed-off-by: Mark Nelson<[email protected]>
> ---
>    doc/man/man1/sshare.1            |    7 ++++++-
>    src/common/assoc_mgr.c           |    2 ++
>    src/common/slurm_protocol_defs.h |    2 ++
>    src/common/slurm_protocol_pack.c |    6 ++++++
>    src/sshare/process.c             |   13 ++++++++++++-
>    5 files changed, 28 insertions(+), 2 deletions(-)
>
> Index: slurm-2.4.0-0.pre4/doc/man/man1/sshare.1
> ===================================================================
> --- slurm-2.4.0-0.pre4.orig/doc/man/man1/sshare.1
> +++ slurm-2.4.0-0.pre4/doc/man/man1/sshare.1
> @@ -14,7 +14,8 @@ being provided by \fBslurmdbd\fR (SLURM
>    read in from the slurmctld and used to process the shares available
>    to a given association.  sshare provides SLURM share information of
>    Account, User, Raw Shares, Normalized Shares, Raw Usage, Normalized
> -Usage, Effective Usage, and the Fair-share factor for each association.
> +Usage, Effective Usage, the Fair-share factor, and the GrpCPUMins limit
> +for each association.
>
>
>    .SH "OPTIONS"
> @@ -105,6 +106,10 @@ from sibling accounts.
>    The Fair-Share factor, based on a user or account's assigned shares and
>    the effective usage charged to them or their accounts.
>
> +.TP
> +\f3GrpCPUMins\fP
> +The CPU-minutes limit set on the account.
> +
>    .SH "EXAMPLES"
>    .eo
>    .br
> Index: slurm-2.4.0-0.pre4/src/common/assoc_mgr.c
> ===================================================================
> --- slurm-2.4.0-0.pre4.orig/src/common/assoc_mgr.c
> +++ slurm-2.4.0-0.pre4/src/common/assoc_mgr.c
> @@ -2115,6 +2115,8 @@ extern List assoc_mgr_get_shares(void *d
>               share->shares_norm = assoc->usage->shares_norm;
>               share->usage_raw = (uint64_t)assoc->usage->usage_raw;
>
> +             share->grp_cpu_mins = assoc->grp_cpu_mins;
> +
>               if (assoc->user) {
>                       /* We only calculate user effective usage when
>                        * we need it
> Index: slurm-2.4.0-0.pre4/src/common/slurm_protocol_defs.h
> ===================================================================
> --- slurm-2.4.0-0.pre4.orig/src/common/slurm_protocol_defs.h
> +++ slurm-2.4.0-0.pre4/src/common/slurm_protocol_defs.h
> @@ -430,6 +430,8 @@ typedef struct association_shares_object
>       double usage_norm;      /* normalized usage */
>       uint64_t usage_raw;     /* measure of resource usage */
>
> +     uint64_t grp_cpu_mins;  /* cpu-minute limit */
> +
>       uint16_t user;          /* 1 if user association 0 if account
>                                * association */
>    } association_shares_object_t;
> Index: slurm-2.4.0-0.pre4/src/common/slurm_protocol_pack.c
> ===================================================================
> --- slurm-2.4.0-0.pre4.orig/src/common/slurm_protocol_pack.c
> +++ slurm-2.4.0-0.pre4/src/common/slurm_protocol_pack.c
> @@ -1795,6 +1795,8 @@ static void _pack_assoc_shares_object(vo
>               packdouble(0, buffer);
>               pack64(0, buffer);
>
> +             pack64(0, buffer);
> +
>               pack16(0, buffer);
>
>               return;
> @@ -1813,6 +1815,8 @@ static void _pack_assoc_shares_object(vo
>       packdouble(object->usage_norm, buffer);
>       pack64(object->usage_raw, buffer);
>
> +     pack64(object->grp_cpu_mins, buffer);
> +
>       pack16(object->user, buffer);
>    }
>
> @@ -1837,6 +1841,8 @@ static int _unpack_assoc_shares_object(v
>       safe_unpackdouble(&object_ptr->usage_norm, buffer);
>       safe_unpack64(&object_ptr->usage_raw, buffer);
>
> +     safe_unpack64(&object_ptr->grp_cpu_mins, buffer);
> +
>       safe_unpack16(&object_ptr->user, buffer);
>
>       return SLURM_SUCCESS;
> Index: slurm-2.4.0-0.pre4/src/sshare/process.c
> ===================================================================
> --- slurm-2.4.0-0.pre4.orig/src/sshare/process.c
> +++ slurm-2.4.0-0.pre4/src/sshare/process.c
> @@ -70,6 +70,7 @@ extern int process(shares_response_msg_t
>               PRINT_RAWS,
>               PRINT_RAWU,
>               PRINT_USER,
> +             PRINT_CPUMINS,
>       };
>
>       if (!resp)
> @@ -82,7 +83,7 @@ extern int process(shares_response_msg_t
>               slurm_addto_char_list(format_list,
>                                     "A,User,RawShares,NormShares,"
>                                     "RawUsage,NormUsage,EffUsage,"
> -                                   "FSFctr");
> +                                   "FSFctr,GrpCPUMins");
>       } else {
>               slurm_addto_char_list(format_list,
>                                     "A,User,RawShares,NormShares,"
> @@ -148,6 +149,11 @@ extern int process(shares_response_msg_t
>                       field->name = xstrdup("User");
>                       field->len = 10;
>                       field->print_routine = print_fields_str;
> +             } else if (!strncasecmp("GrpCPUMins", object, 1)) {
> +                     field->type = PRINT_CPUMINS;
> +                     field->name = xstrdup("GrpCPUMins");
> +                     field->len = 11;
> +                     field->print_routine = print_fields_uint64;
>               } else {
>                       exit_code=1;
>                       fprintf(stderr, "Unknown field '%s'\n", object);
> @@ -268,6 +274,11 @@ extern int process(shares_response_msg_t
>                                                    tmp_char,
>                                                    (curr_inx == field_count));
>                               break;
> +                     case PRINT_CPUMINS:
> +                             field->print_routine(field,
> +                                                  share->grp_cpu_mins,
> +                                                  (curr_inx == field_count));
> +                             break;
>                       default:
>                               field->print_routine(
>                                       field, NULL,

Reply via email to