Monitoring resource entitlements and minimum resource share

The resource entitlement for a service class can be monitored by examining the resource_entitlement monitor element reported in the statistics event monitor, and by the MON_GET_SERVICE_SUPERCLASS_STATS and MON_GET_SERVICE_SUBCLASS_STATS table functions. The resource entitlements for service classes can also be computed by examining the resource share values defined for service classes in the catalogs, excluding any service classes that are not accessible.

For example, the following query shows how to compute the resource entitlements for service superclasses using the resource share values stored in the catalogs.
with totalsupershares(shares) as
       (select sum(resourceshares)
        from syscat.serviceclasses a
        where a.parentid = 0 and (a.serviceclassname in (select parentserviceclassname
          from syscat.workloads where enabled = 'Y' and serviceclassname = 'SYSDEFAULTSUBCLASS' and workloadname != 'SYSDEFAULTADMWORKLOAD') or
            a.serviceclassname in (select serviceclassname from syscat.workloads where enabled = 'Y' and parentserviceclassname is null and workloadname != 'SYSDEFAULTADMWORKLOAD'))),
     totalsubshares (superid, subshares) as
       (select a.parentid, sum(a.resourceshares)
        from syscat.serviceclasses a
        where a.parentid != 0 group by parentid),
     superreserve(superid, reserve) as
       (select b.serviceclassid, sum((float(a.resourceshares)/float(c.subshares)) * float(a.minresourcesharepct) / float(100))
        from syscat.serviceclasses a, syscat.serviceclasses b, totalsubshares c
        where a.parentid = b.serviceclassid and c.superid = b.serviceclassid group by b.serviceclassid)
select substr(a.serviceclassname, 1, 30) as serviceclass,
       a.resourceshares,
       case when (a.resourcesharetype = 'S') then 'SOFT' else 'HARD' end as entitlement_type,
       decimal(float(a.resourceshares) * 100 / float(b.shares), 5, 2) as entitlement_pct,
       max(decimal(float(a.resourceshares) * 100 / float(b.shares) * float(a.minresourcesharepct) / float(100), 5, 2),
           decimal( (float(c.reserve) * float(a.resourceshares)) * 100 / float(b.shares), 5, 2)) as reserve_pct
from syscat.serviceclasses a,
     totalsupershares b,
     superreserve c
where a.serviceclassid = c.superid and
     (a.serviceclassname in
          (select parentserviceclassname
           from syscat.workloads
           where enabled = 'Y' and serviceclassname = 'SYSDEFAULTSUBCLASS' and workloadname != 'SYSDEFAULTADMWORKLOAD') or
      a.serviceclassname in
          (select serviceclassname
           from syscat.workloads
           where enabled = 'Y' and parentserviceclassname is null and workloadname != 'SYSDEFAULTADMWORKLOAD')
Sample output:
SERVICECLASS                   RESOURCESHARES ENTITLEMENT_TYPE ENTITLEMENT_PCT RESERVE_PCT
------------------------------ -------------- ---------------- --------------- -----------
MYINTERACTIVESC                          2500 SOFT                       25.00        6.25
MYBATCHSC                                2500 HARD                       25.00        0.00
MYMIXEDSC                                5000 SOFT                       50.00        6.25
Similarly, the following query can be used to compute the resource entitlements for each service subclass.
with totalsupershares(shares) as
       (select sum(resourceshares)
        from syscat.serviceclasses a
        where a.parentid = 0 and (a.serviceclassname in (select parentserviceclassname
          from syscat.workloads where enabled = 'Y' and serviceclassname = 'SYSDEFAULTSUBCLASS' and workloadname != 'SYSDEFAULTADMWORKLOAD') or
            a.serviceclassname in (select serviceclassname from syscat.workloads where enabled = 'Y' and parentserviceclassname is null and workloadname != 'SYSDEFAULTADMWORKLOAD'))),
     totalsubshares (superid, subshares) as
       (select a.parentid, sum(a.resourceshares)
        from syscat.serviceclasses a
        where a.parentid != 0 group by parentid),
     superreserve(superid, reserve) as
       (select b.serviceclassid, sum((float(a.resourceshares)/float(c.subshares)) * float(a.minresourcesharepct) / float(100))
        from syscat.serviceclasses a, syscat.serviceclasses b, totalsubshares c
        where a.parentid = b.serviceclassid and c.superid = b.serviceclassid group by b.serviceclassid),
     superclassentitlement(superid,
                           resourceshares,
                           resourcesharetype,
                           entitlement_pct,
                           reserve_pct) as
      (select a.serviceclassid,
       a.resourceshares,
       a.resourcesharetype,
       decimal(float(a.resourceshares) * 100 / float(b.shares), 5, 2) as entitlement_pct,
       max(decimal(float(a.resourceshares) * 100 / float(b.shares) * float(a.minresourcesharepct) / float(100), 5, 2),
           decimal( (float(c.reserve) * float(a.resourceshares)) * 100 / float(b.shares), 5, 2)) as reserve_pct
     from syscat.serviceclasses a,
     totalsupershares b,
     superreserve c
     where a.serviceclassid = c.superid and
     (a.serviceclassname in
          (select parentserviceclassname
           from syscat.workloads
           where enabled = 'Y' and serviceclassname = 'SYSDEFAULTSUBCLASS' and workloadname != 'SYSDEFAULTADMWORKLOAD') or
      a.serviceclassname in
          (select serviceclassname
           from syscat.workloads
           where enabled = 'Y' and parentserviceclassname is null and workloadname != 'SYSDEFAULTADMWORKLOAD')))
select substr(a.parentserviceclassname, 1, 20) as superclass,
       substr(a.serviceclassname, 1, 20) as subclass,
       b.resourceshares as sup_shares,
       case when (b.resourcesharetype = 'S') then 'SOFT' else 'HARD' end as sup_ent_type,
       b.entitlement_pct as sup_ent_pct,
       a.resourceshares as sub_shares,
       case when (a.resourcesharetype = 'S') then 'SOFT' else 'HARD' end as sub_ent_type,
       decimal((float(a.resourceshares) / float(c.subshares)) * b.entitlement_pct, 5, 2) as sub_ent_pct,
       decimal((float(a.resourceshares) / float(c.subshares)) * b.entitlement_pct * (a.minresourcesharepct / float(100)), 5, 2) as sub_reserve_pct
from syscat.serviceclasses a,
     superclassentitlement as b,
     totalsubshares as c
where a.parentid = b.superid and
      a.parentid = c.superid
order by a.parentserviceclassname, a.serviceclassname   asc
Sample output:
SUPERCLASS           SUBCLASS             SUP_SHARES  SUP_ENT_TYPE SUP_ENT_PCT SUB_SHARES  SUB_ENT_TYPE SUB_ENT_PCT SUB_RESERVE_PCT
-------------------- -------------------- ----------- ------------ ----------- ----------- ------------ ----------- ---------------
MYBATCHSC            SYSDEFAULTSUBCLASS          2500 HARD               25.00        1000 SOFT               25.00            0.00
MYINTERACTIVESC      SYSDEFAULTSUBCLASS          2500 SOFT               25.00        1000 SOFT               25.00            6.25
MYMIXEDSC            COMPLEXSUBCLASS             5000 SOFT               50.00        3500 SOFT               17.50            0.00
MYMIXEDSC            LOADSUBCLASS                5000 SOFT               50.00        1500 SOFT                7.50            0.00
MYMIXEDSC            MEDIUMSUBCLASS              5000 SOFT               50.00        2500 SOFT               12.50            3.75
MYMIXEDSC            SYSDEFAULTSUBCLASS          5000 SOFT               50.00        2500 SOFT               12.50            2.50