Last active
November 2, 2023 14:27
-
-
Save sriedmue79/d3e58f96143348bd46920adcaae322d5 to your computer and use it in GitHub Desktop.
IBM i - Estimating the date when the system "temporary addresses" would reach 100%
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- !!IMPORTANT!! This query assumes that the temporary addresses were reset to 0% at the last IPL. | |
-- This assumption is only safe in i 7.4 and later releases. | |
-- Refer to this IBM doc for full details: https://www.ibm.com/support/pages/temporary-addresses | |
-- This query also assumes that the timestamp of the QCTL subsystem startup is an accurate representation of the last IPL. | |
-- | |
-- Description: When temporary address usage reaches 100% in an LPAR, the LPAR will end abnormally. | |
-- This query estimates the date when this LPAR will reach 100% temp address usage, based on the temp address usage | |
-- that has occurred since the last IPL date (using the start date of QCTL subsystem) and the current temp address | |
-- percentage. It calculates the average temp address percentage increase per day since the last IPL, and uses that | |
-- to project the number of days before 100% will be reached. | |
-- | |
--Description: based on the start date of the QCTL subsystem and the current temp address percentage, estimate the date when temp addresses would reach 100% causing a crash of the LPAR | |
SELECT (A.TEMPORARY_ADDRESS_RATE) / (TIMESTAMPDIFF(16, CHAR(CURRENT TIMESTAMP - B.JOB_ACTIVE_TIME))) AS AVG_TEMP_ADDRESS_PERCENT_PER_DAY, | |
(100-A.TEMPORARY_ADDRESS_RATE) AS TEMP_ADDRESS_PERCENT_REMAINING, | |
(100-A.TEMPORARY_ADDRESS_RATE) / ((A.TEMPORARY_ADDRESS_RATE)/(TIMESTAMPDIFF(16, CHAR(CURRENT TIMESTAMP - B.JOB_ACTIVE_TIME)))) AS DAYS_BEFORE_CRASH, | |
(CURRENT DATE + ((100-A.TEMPORARY_ADDRESS_RATE) / ((A.TEMPORARY_ADDRESS_RATE)/(TIMESTAMPDIFF(16, CHAR(CURRENT TIMESTAMP - B.JOB_ACTIVE_TIME))))) DAYS) AS PROJECTED_CRASH_DATE | |
FROM QSYS2.SYSTEM_STATUS_INFO_BASIC A | |
CROSS JOIN | |
TABLE ( | |
QSYS2.ACTIVE_JOB_INFO( | |
JOB_NAME_FILTER => 'QCTL', DETAILED_INFO => 'WORK') ) B | |
WHERE JOB_TYPE = 'SBS'; | |
-- Line 14: Calculate the average temp address percent increase per day (current temp address percentage DIVIDED BY the number of days since QCTL was started) | |
-- Line 15: Calculate the remaining available temp address percentage (100 percent MINUS the current temp address percent) | |
-- Line 16: Calculate the number of days before the system will reach 100% temp address usage (remaining temp address percentage DIVIDED BY the observed daily percentage increase) | |
-- Line 17: Calculate the date upon which the system will reach 100% temp address usage (current date PLUS the number of days before the system is expected to reach 100%) | |
-- Line 18: Bring in data (the current temp address percentage) from the SYSTEM_STATUS_INFO_BASIC view | |
-- Lines 19-23: Bring in data (the start time of QCTL subsystem) from the ACTIVE_JOB_INFO table function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment