Let’s summarize the operation of these two commands:
In the absence of anything more flexible and dynamic, most system administrators have used them over time to monitor disk occupancy.
Fortunately IBM starting from V7R2 has enriched the QSYS2 library with functions capable of retrieving information on the health of the server including the OBJECT_STATISTICS.
This UDTF allows you to quickly trace the content of a library or a part of it simply with a SQL selection query and therefore allows a more detailed and clearly faster control of what happens inside the libraries.
Index
The syntax for using this function is as follows
OBJECT_STATISTICS (libraryName, ObjectType list, ObjectName)
In detail the parameters for the use of this UDTF are:
Here are some usage examples:
SELECT SUM (OBJSIZE) FROM TABLE (QSYS2.OBJECT_STATISTICS ('PETRIS', 'ALL')) T
SELECT OBJNAME, OBJTEXT, OBJOWNER FROM TABLE (QSYS2.OBJECT_STATISTICS ('PETRIS', 'FILE')) T WHERE OBJATTRIBUTE = 'PF' ORDER BY OBJOWNER
SELECT * FROM TABLE (QSYS2.OBJECT_STATISTICS ('USRLIBL', 'ALL')) T WHERE DAYS_USED_COUNT <= 1 ORDER BY OBJSIZE DESC
For a complete control of all that is installed on the server it is also possible to create a table to be populated with the contents of each individual library and then also reason with Business Intelligence tools to create a dashboard of control of our IBMi.
We create a table that will contain all the information
CREATE TABLE PETRIS.OBJECTS ( NAME VARCHAR (10) NOT NULL DEFAULT '', TYPE VARCHAR (8) NOT NULL DEFAULT '', OWNER VARCHAR (10) NOT NULL DEFAULT '', CREATOR VARCHAR (10) NOT NULL DEFAULT '', CREATED TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, SIZE DECIMAL (15, 0) NOT NULL DEFAULT 0, TEXT VARCHAR (50) DEFAULT NULL, SQL_NAME VARCHAR (128) DEFAULT NULL, USED TIMESTAMP DEFAULT NULL, DAYS_USED DECIMAL (10, 0) NOT NULL DEFAULT 0, RESET TIMESTAMP DEFAULT NULL, ASP_NUMBER DECIMAL (5, 0) NOT NULL DEFAULT 0, ATTRIBUTE VARCHAR (10) NOT NULL DEFAULT '', SQL_SCHEMA VARCHAR (128) NOT NULL DEFAULT '', LIBRARY_TEXT VARCHAR (50) DEFAULT NULL, SQL_TYPE VARCHAR (9) DEFAULT NULL)
Then we create a new program that:
TRUNCATE TABLE PETRIS.OBJECTS
SELECT SCHEMA_NAME FROM QSYS2.SYSSCHEMAS
and for each library read perform the population by extracting the data from OBJECT_STATISTICS
INSERT INTO PETRIS.OBJECTS (SELECT OBJNAME, OBJTYPE, OBJOWNER, OBJDEFINER, OBJCREATED, OBJSIZE, OBJTEXT, OBJLONGNAME, LAST_USED_TIMESTAMP, DAYS_USED_COUNT, LAST_RESET_TIMESTAMP, IASP_NUMBER, OBJATTRIBUTE, OBJLONGSCHEMA, TEXT, SQL_OBJECT_TYPE FROM TABLE (QSYS2.OBJECT_STATISTICS ('libraryname', '* ALL')))
NB: at the limit we can consider excluding the libraries owned by the user QSYS to avoid extracting those of the operating system (SELECT SCHEMA_NAME FROM QSYS2.SYSSCHEMAS WHERE SCHEMA_OWNER <> ‘QSYS’)
Once the complete list of objects is obtained, it is easy to find objects that occupy more space, heavier libraries, etc.
SELECT SQL_SCHEMA, SUM (SIZE) FROM PETRIS.OBJECTS GROUP BY SQL_SCHEMA ORDER BY 2 DESC
For more information, the official IBM documentation is available (https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/rzajq/rzajqudfobjectstat.htm)
We are pleased to receive and share this "tip & trick" from Patrick Rizzi, which introduces a technique that allows…
I take inspiration from a response by Michael Mayer on the Midrange.com mailing lists to someone who asked how to…
Businesses are increasingly seeking tools to enhance efficiency, collaboration, and resource management. Enterprise Resource Planning (ERP) systems provide a comprehensive…
Early April saw the release of the "Spring Version" of ACS Access Client Solution, version 1.1.9.5 Interesting new features especially…
If the packed agenda of sessions at Common Europe Congress 2024, June 3-6 Milan, wasn't enough for you, here's another…
Debugging functions with Visual Studio Code have been available for some time but this new version 2.10.0 simplifies the handling…