24
Sun, Nov
1 New Articles

How Much Storage Is Left in Your Main Storage Pools?

RPG
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Learn an easy and efficient way to determine the amount of unallocated main storage.

 

There's no doubt that knowing the amount of unallocated storage in the main storage pools is important to system operators. But how to do that?

The Work with System Status (WRKSYSSTS) command and the Work with Shared Storage Pools (WRKSHRPOOL) command allow operators to manage main storage pools, but neither of them reports the information we're looking for.

At V5R4, as an improvement to Collection Services, a new field called the Unallocated Pool Space (POUNAL) was added to the performance data file QAPMPOOLB generated by the Create Performance Data (CRTPFRDTA) command. The POUNAL field is set to the value of the amount of pool storage (in KB) available to be used for new transfers into a main storage pool without displacing any virtual data already in the pool. However, the performance data collected by Collection Services is collected at sampling intervals; therefore, you cannot get real-time data out of it.

The Set Object Access (SETOBJACC) command brings an object into a main storage pool or purges it from all main storage pools. After a SETOBJACC command completes, it sends a completion message to the call message queue of the current job; this message reports the amount of unused storage remaining in the target main storage pool (in KB) before it brings an object to the pool. So it's a workable way to bring an object into a main storage pool and then retrieve the value of unallocated pool storage of the pool. Yes, it's an easy and workable approach, but not efficient enough!

Note: Using the SETOBJACC approach can be an interesting exercise. For your convenience, in Appendix A below, I list an example CL program that retrieves the amount of unallocated pool storage following the SETOBJACC approach.

An easy, yet efficient, method of gathering main storage information (especially the amount of unallocated pool storage) is via the Materialize Resource Management Data (MATRMD) MI instruction with option hex 2D (Materialize main storage pool information). Option hex 2D was added to the MATRMD instruction as of V5R4 as an improvement to option hex 09, and a major enhancement expanded the size of the returned pool data from 4-byte binaries to 8-byte binaries. The prototype of MATRMD and the materialization template for option hex 2D are defined in mih-stgrsc.rpgle (see below). The materialization template for option hex 2D consists of a base portion (defined by data structure matrmd_tmpl2d_t) followed by an array of up to 64 entries of individual main storage pool information (defined by data structure msp_info2_t). The main storage pool information entries in the array are in the same order that they appear in the WRKSYSSTS display.

     /* Selection option for MATRMD */

     d matrmd_option_t...

     d                 ds                  qualified

     d       val                       1a

     d                               7a

     /* Materialization template for MATRMD   */

     d matrmd_tmpl_t   ds                 qualified

     d       bytes_in                 10i 0

     d       bytes_out                 10i 0

     d       time_of_day...

     d                               20u 0

     * Resource management data

     /**

     * @BIF _MATRMD (Materialize Resource   Management Data (MATRMD))

     */

     d matrmd         pr                  extproc('_MATRMD')

     d       receiver                         likeds(matrmd_tmpl_t)

     d       opt                               likeds(matrmd_option_t)

     /**

     * Materialization template for MATRMD   with option hex 2D --

     * Materialize main storage pool   information.

     *

     * @remark Option "Main Storage   Pool Information (Hex 2D)" is the

     * preferred method of materializing   main storage pool

     * information because some of the   fields for this option may

     * overflow without any indication of   error.

     */

     d matrmd_tmpl2d_t...

     d                 ds                 qualified

     d                                       based(dummy_ptr)

     d       bytes_in                 10i 0

     d       bytes_out               10i 0

     d       time_of_day...

     d                               20u 0

     *

     * Machine minimum transfer size is the   smallest number of bytes

     * that may be transferred as a block to   or from main storage. A

     * typical value of this field is 4K.

     *

     d       machine_minimum_transfer_size...

     d                               10u 0

     d       maximum_number_of_pools...

     d                               10u 0

     d       current_number_of_pools...

     d                              10u 0

     d                               4a

     *

     * Main storage size is the amount of   main storage, in units

     * equal to the machine minimum transfer   size, which may be

     * apportioned among main storage pools.

     *

     d     main_storage_size...

     d                               20u 0

     d       pool_1_minimum_size...

     d                               20u 0

     *

     * Array of individual main storage pool   information DS of type

     * msp_info2_t (repeated once for each   pool, up to the current

     * number of pools)

     *

     /* Main storage pool information (for   option hex 2D). */

     d msp_info2_t     ds                 qualified

     d       pool_size...

     d                               20u 0

     d      pool_maintenance...

     d                               20u 0

     d       thread_interruptions_database...

     d                               20u 0

     d       thread_interruptions_nondatabase...

     d                               20u 0

     d       data_transferred_to_pool_database...

     d                               20u 0

     d       data_transferred_to_pool_nondatabase...

     d                               20u 0

     * Unallocated pool storage

     d       unal                     20u 0

     * Alias of @var unal

     d       amount_of_pool_not_assigned_to_virtual_addresses...

     d                               20u 0   overlay(unal)

     d                               8a

Fields directly related with our goal are the following:

  • matrmd_tmpl2d_t.machine_minimum_transfer_sizeMachine minimum transfer size is defined to be the smallest number of bytes that may be transferred as a block to and from main storage. Here it is used as the unit of storage size fields such as pool size and unallocated pool storage in the materialization template. The typical value of this field is 4KB.
  • matrmd_tmpl2d_t.current_number_of_poolsThis is the number of main storage pools currently being utilized.
  • msp_info2_t.pool_sizeThis is the size of the storage assigned to a main storage pool in units of machine minimum transfer size (zero if the main storage pool isn't currently being utilized).
  • msp_info2_t.unalThis is the unallocated pool storage in a main storage pool in units of the machine minimum transfer size. To calculate a pool's unallocated pool storage in KB, use the formula: unused_in_KB = msp_info2_t.unal * matrmd_tmpl2d_t.machine_minimum_transfer_size / 1024.

The following is an RPG example, t181.rpgle. It reports the amount of unallocated pool storage (in KB) in each main storage pool:

     /**

     * @file t181.rpgle

     *

     * Test of MATRMD -- Retrieve amount of   unallocated pool storage.

     */

     h dftactgrp(*no)

     /copy mih-stgrsc

     d @tmpl           s               *

     d tmpl           ds                 likeds(matrmd_tmpl2d_t)

     d                                       based(@tmpl)

     d @mspe           s              *

     d mspe           ds                 likeds(msp_info2_t)

     d                                       based(@mspe)

     d opt             ds                 likeds(matrmd_option_t)

     d len             s             10u 0

     d num            s             10u 0

     d unal           s             20u 0

     /free

           opt = *allx'00';

           opt.val = x'2D';

           // Get length of necessary buffer

           @tmpl =   %alloc(%size(matrmd_tmpl2d_t));

           tmpl.bytes_in =   %size(matrmd_tmpl2d_t);

           matrmd(tmpl : opt);

           len = tmpl.bytes_out;

           // Allocate buffer for   materialization template

           @tmpl = %realloc(@tmpl : len);

           tmpl.bytes_in = len;

           // Actually materialize main   storage pool info

           matrmd(tmpl : opt);

           // Report amount of unallocated   pool storage in each MSP

           @mspe = @tmpl +   %size(matrmd_tmpl2d_t);

           num = 1;

           dow num <=   tmpl.current_number_of_pools

              and

               mspe.pool_size > 0; //   Ignore empty pools

               // Amount of unallocated pool   storage in 1KB units

               unal = mspe.unal

                     *   tmpl.machine_minimum_transfer_size

                     / 1024;

               dsply num '' unal;

               // Offset to next msp_info2_t   structure

               num += 1;

               @mspe += %size(msp_info2_t);

           enddo;

           dealloc @tmpl;

           *inlr = *on;

     /end-free

Appendix A: CL Example of Retrieving the Amount of Unallocated Pool Storage via SETOBJACC

After a SETOBJACC command completes successfully, it sends a completion message to the call message queue of the current job. The message ID is CPC1140 for a file object (*FILE) and CPC1141 for a program object (*PGM), respectively. Either of these two CPC messages reports the amount of unused storage remaining in the target main storage pool (in KB) before an object is brought to the pool via the sixth message data field (of type BIN(4)). The offset of the sixth message data field from the beginning of the message data of either message is 41.

The following ILE CL example, unalloc.clle, retrieves the amount of unallocated storage in a specific main storage pool through the following steps:

  1. 1.Bring whatever program (UNALLOC itself in this example) to the target main storage pool via the SETOBJACC command.
  2. 2.Receive the CPC1141 message sent by the previous SETOBJACC command and save the value of the sixth message data field (amount of unallocated pool storage).
  3. 3.Report the amount of unallocated pool storage of the target main storage pool.
  4. 4.Purge itself out of the main storage via a SETOBJACC POOL(*PURGE) command.

UNALLOC

             PGM       PARM(&SBSNAM &POOLID)

             DCL       VAR(&SBSNAM) TYPE(*CHAR) LEN(10)

             DCL       VAR(&POOLID) TYPE(*INT) LEN(2)

             DCL       VAR(&MSGDTA) TYPE(*CHAR) LEN(256)

             DCL       VAR(&UNUSED) TYPE(*INT)   STG(*DEFINED) LEN(4) +

                         DEFVAR(&MSGDTA   42)

             DCL       VAR(&MSG) TYPE(*CHAR) LEN(80) +

                         VALUE('Unallocated   storage in target main +

                          storage pool in KB: ')

             DCL       VAR(&ZND) TYPE(*CHAR)   STG(*DEFINED) LEN(11) +

                         DEFVAR(&MSG 61)

             DCL       VAR(&ZNDATTR) TYPE(*CHAR) LEN(7)   +

                           VALUE(X'02000B00000000')

             DCL       VAR(&BIN4ATTR) TYPE(*CHAR) LEN(7)   +

                         VALUE(X'0A000400000000')

             IF         COND(&POOLID *EQ 0)   THEN(SETOBJACC +

                         OBJ(UNALLOC)   OBJTYPE(*PGM) POOL(&SBSNAM))

             ELSE       CMD(SETOBJACC OBJ(UNALLOC)   OBJTYPE(*PGM) +

                         POOL(&SBSNAM   &POOLID))

             RCVMSG     PGMQ(*SAME) MSGQ(*PGMQ) MSGTYPE(*COMP) +

                         MSGDTA(&MSGDTA)

             CALLPRC   PRC('_LBCPYNV') PARM((&ZND)   (&ZNDATTR) +

                         (&UNUSED)   (&BIN4ATTR))

             SNDPGMMSG MSG(&MSG)

             SETOBJACC OBJ(UNALLOC) OBJTYPE(*PGM) POOL(*PURGE)

             ENDPGM

The Copy Numeric Value (CPYNV) MI instruction is used in this example to convert the BIN(4) &UNUSED variable to zoned decimal.

To retrieve the amount of unallocated pool storage of a private pool (e.g., a private pool created in a subsystem called OCT with subsystem-related pool ID 2), call UNALLOC as shown:

4 > X UNALLOC (OCT X'0002')                                                

     Unallocated storage in target main   storage pool in KB:     00000007140

     Object UNALLOC purged from main   storage.                              

To retrieve the amount of unallocated pool storage of the *BASE pool, call UNALLOC like the following:

4 > X UNALLOC (*BASE X'0000')                                              

     Unallocated storage in target main   storage pool in KB:     00000481364

     Object UNALLOC purged from main   storage.                              

Junlei Li

Junlei Li is a programmer from Tianjin, China, with 10 years of experience in software design and programming. Junlei Li began programming under i5/OS (formerly known as AS/400, iSeries) in late 2005. He is familiar with most programming languages available on i5/OS—from special-purpose languages such as OPM/ILE RPG to CL to general-purpose languages such as C, C++, Java; from strong-typed languages to script languages such as QShell and REXX. One of his favorite programming languages on i5/OS is machine interface (MI) instructions, through which one can discover some of the internal behaviors of i5/OS and some of the highlights of i5/OS in terms of operating system design.

 

Junlei Li's Web site is http://i5toolkit.sourceforge.net/, where his open-source project i5/OS Programmer's Toolkit (https://sourceforge.net/projects/i5toolkit/) is documented.

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: